expo-iap 6.4.2 → 6.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +17 -0
- package/build/ExpoIapModule.d.ts +1 -1
- package/build/ExpoIapModule.d.ts.map +1 -1
- package/build/ExpoIapModule.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +6 -3
- package/build/index.js.map +1 -1
- package/build/index.kepler.d.ts +1 -0
- package/build/index.kepler.d.ts.map +1 -1
- package/build/index.kepler.js +1 -0
- package/build/index.kepler.js.map +1 -1
- package/build/modules/android.d.ts +2 -0
- package/build/modules/android.d.ts.map +1 -1
- package/build/modules/android.js +5 -0
- package/build/modules/android.js.map +1 -1
- package/build/modules/ios.d.ts +1 -1
- package/build/modules/ios.js +2 -2
- package/build/modules/ios.js.map +1 -1
- package/build/purchase-flow-confirmers.d.ts +10 -2
- package/build/purchase-flow-confirmers.d.ts.map +1 -1
- package/build/purchase-flow-confirmers.js +32 -15
- package/build/purchase-flow-confirmers.js.map +1 -1
- package/build/types.d.ts +13 -2
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/build/useIAP.d.ts +1 -0
- package/build/useIAP.d.ts.map +1 -1
- package/build/useIAP.js +21 -6
- package/build/useIAP.js.map +1 -1
- package/bun.lock +2 -2
- package/ios/ExpoIapModule.swift +1 -1
- package/openiap-versions.json +3 -3
- package/osv-scanner.toml +6 -6
- package/package.json +2 -2
- package/src/ExpoIapModule.ts +1 -0
- package/src/index.kepler.ts +5 -0
- package/src/index.ts +7 -3
- package/src/modules/android.ts +8 -0
- package/src/modules/ios.ts +2 -2
- package/src/purchase-flow-confirmers.ts +45 -22
- package/src/types.ts +13 -2
- package/src/useIAP.ts +20 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.kepler.js","sourceRoot":"","sources":["../src/index.kepler.ts"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n type PurchaseFlowPurchase,\n} from './purchase-flow-core';\nimport {\n createIapkitConfirmation,\n type IapkitConfirmationOptions,\n} from './purchase-flow-confirmers';\nimport {\n clearRequested,\n createSdkPurchaseFlow,\n markRequested,\n type PurchaseFlowSdk,\n type SdkPurchaseFlowOptions,\n} from './utils/purchaseFlowBinding';\nimport type {\n MutationField,\n ProductQueryType,\n ProductRequest,\n Purchase,\n PurchaseError,\n PurchaseOptions,\n PurchaseUpdatedListenerOptions,\n QueryField,\n RequestPurchasePropsByPlatforms,\n RequestSubscriptionPropsByPlatforms,\n} from './types';\nimport {decodeAndroidPurchases} from './utils/availablePurchases';\nimport {createPurchaseError} from './utils/errorMapping';\n\nexport * from './types';\nexport {isRecoverableError} from './utils/errorMapping';\nexport * from './vega';\nexport * from './useIAP';\nexport {kitApi, KitApiError, resolveLocalizedPayload} from './kit-api';\nexport type {\n EntitlementsResponse,\n KitApiOptions,\n KitClientPayloadCache,\n KitClientPayloadOptions,\n KitClientPayloadResponse,\n KitLocalizedClientPayload,\n KitLocalizedClientPayloadOptions,\n KitLocalizedPayloadOptions,\n KitProduct,\n KitProductClientPayload,\n KitProductOffer,\n KitProductPlatform,\n KitProductsOptions,\n KitProductsResponse,\n KitSubscription,\n StatusResponse,\n} from './kit-api';\nexport {\n describePurchaseFlowStatus,\n toPurchaseConfirmationRequest,\n} from './purchase-flow-core';\nexport type {\n PurchaseConfirmation,\n PurchaseConfirmationRequest,\n PurchaseFlow,\n PurchaseFlowGuidance,\n PurchaseFlowGuidanceKey,\n PurchaseFlowOptions,\n PurchaseFlowOutcome,\n PurchaseFlowPurchase,\n PurchaseFlowStatus,\n RecoverPurchasesOptions,\n} from './purchase-flow-core';\nexport type {IapkitConfirmationOptions} from './purchase-flow-confirmers';\nexport type {SdkPurchaseFlowOptions} from './utils/purchaseFlowBinding';\n\nexport enum OpenIapEvent {\n PurchaseUpdated = 'purchase-updated',\n PurchaseError = 'purchase-error',\n PromotedProductIOS = 'promoted-product-ios',\n UserChoiceBillingAndroid = 'user-choice-billing-android',\n DeveloperProvidedBillingAndroid = 'developer-provided-billing-android',\n SubscriptionBillingIssue = 'subscription-billing-issue',\n}\n\nexport type ProductTypeInput = ProductQueryType;\n\nexport interface EventSubscription {\n remove(): void;\n}\n\nconst getModule = () => {\n const module = getVegaIapModule();\n if (!module) {\n throw new Error(\n 'Amazon Vega IAP module is unavailable. Install @amazon-devices/keplerscript-appstore-iap-lib in the Vega app target and build with the React Native for Vega kepler platform.',\n );\n }\n return module;\n};\n\nconst unsupported = (feature: string): never => {\n throw new Error(`${feature} is not supported on Amazon Vega.`);\n};\n\nconst normalizeProductType = (\n type?: ProductTypeInput | null,\n): ProductQueryType => {\n if (type == null || type === 'in-app') return 'in-app';\n if (type === 'subs' || type === 'all') return type;\n throw new Error(\n `Unsupported product type: ${String(type)}. Use in-app, subs, or all.`,\n );\n};\n\nconst normalizePurchaseArray = (purchases: Purchase[]): Purchase[] =>\n decodeAndroidPurchases(purchases);\n\nconst getAndroidRequest = (\n request?:\n | RequestPurchasePropsByPlatforms\n | RequestSubscriptionPropsByPlatforms\n | null,\n) => {\n return request?.google;\n};\n\nconst createPurchaseTokenError = (purchase: Purchase): Error => {\n const error = new Error(\n 'Purchase token is required to finish Amazon Vega transaction',\n ) as Error & PurchaseError;\n error.code = ErrorCode.DeveloperError;\n error.productId = purchase.productId;\n return error;\n};\n\nexport const emitter = {\n addListener(\n eventName: OpenIapEvent,\n listener: (payload: Purchase | PurchaseError) => void,\n ): EventSubscription {\n return getModule().addListener(eventName, listener);\n },\n removeListener(\n eventName: OpenIapEvent,\n listener: (payload: Purchase | PurchaseError) => void,\n ): void {\n return getModule().removeListener(eventName, listener);\n },\n};\n\nexport const purchaseUpdatedListener = (\n listener: (event: Purchase) => void,\n options?: PurchaseUpdatedListenerOptions | null,\n): EventSubscription => {\n return getModule().addListener(OpenIapEvent.PurchaseUpdated, (purchase) => {\n listener(purchase as Purchase);\n });\n};\n\nexport const purchaseErrorListener = (\n listener: (error: PurchaseError) => void,\n): EventSubscription => {\n return getModule().addListener(OpenIapEvent.PurchaseError, (error) => {\n listener(error as PurchaseError);\n });\n};\n\nexport const initConnection: MutationField<'initConnection'> = async (\n config,\n) => {\n return getModule().initConnection(config ?? null);\n};\n\nexport const endConnection: MutationField<'endConnection'> = async () => {\n return getModule().endConnection();\n};\n\nexport const fetchProducts = async (\n request: Omit<ProductRequest, 'type'> & {\n type?: ProductTypeInput | null;\n },\n): ReturnType<QueryField<'fetchProducts'>> => {\n const {skus, type} = request;\n return getModule().fetchProducts(normalizeProductType(type), skus);\n};\n\nexport const requestPurchase: MutationField<'requestPurchase'> = async (\n args,\n) => {\n markRequested(args.request.google?.skus ?? []);\n try {\n return await requestPurchaseFromStore(args);\n } catch (error) {\n clearRequested();\n throw error;\n }\n};\n\nconst requestPurchaseFromStore: MutationField<'requestPurchase'> = async (\n args,\n) => {\n const type = normalizeProductType(args.type);\n if (type === 'all') {\n throw createPurchaseError({\n code: ErrorCode.DeveloperError,\n message: 'Product type all is only supported for product queries.',\n });\n }\n const androidRequest = getAndroidRequest(args.request);\n if (!androidRequest?.skus?.length) {\n throw new Error(\n 'Invalid request for Amazon Vega. The `request.google.skus` property is required and must be a non-empty array.',\n );\n }\n\n return normalizePurchaseArray(\n await getModule().requestPurchase({\n skus: androidRequest.skus,\n type,\n }),\n );\n};\n\nexport const getAvailablePurchases: QueryField<\n 'getAvailablePurchases'\n> = async (options) => {\n return normalizePurchaseArray(\n await getModule().getAvailableItems((options ?? {}) as PurchaseOptions),\n );\n};\n\nexport const finishTransaction: MutationField<'finishTransaction'> = async ({\n purchase,\n isConsumable = false,\n}) => {\n const token = purchase.purchaseToken ?? undefined;\n if (!token) {\n throw createPurchaseTokenError(purchase);\n }\n\n if (isConsumable) {\n await getModule().consumePurchaseAndroid(token);\n return;\n }\n\n await getModule().acknowledgePurchaseAndroid(token);\n};\n\nexport const restorePurchases: MutationField<'restorePurchases'> = async () => {\n await getAvailablePurchases({\n includeSuspendedAndroid: false,\n });\n};\n\nexport const getActiveSubscriptions: QueryField<\n 'getActiveSubscriptions'\n> = async (subscriptionIds) => {\n return getModule().getActiveSubscriptions(subscriptionIds ?? null);\n};\n\nexport const hasActiveSubscriptions: QueryField<\n 'hasActiveSubscriptions'\n> = async (subscriptionIds) => {\n return getModule().hasActiveSubscriptions(subscriptionIds ?? null);\n};\n\nexport const getStorefront: QueryField<'getStorefront'> = async () => {\n return getModule().getStorefront();\n};\n\nexport const verifyPurchaseWithProvider: MutationField<\n 'verifyPurchaseWithProvider'\n> = async (options) => {\n return getModule().verifyPurchaseWithProvider(options);\n};\n\nexport const verifyPurchase: MutationField<'verifyPurchase'> = async () =>\n unsupported('verifyPurchase');\n\nexport const acknowledgePurchaseAndroid: MutationField<\n 'acknowledgePurchaseAndroid'\n> = async (purchaseToken) => {\n await getModule().acknowledgePurchaseAndroid(purchaseToken);\n return true;\n};\n\nexport const consumePurchaseAndroid: MutationField<\n 'consumePurchaseAndroid'\n> = async (purchaseToken) => {\n await getModule().consumePurchaseAndroid(purchaseToken);\n return true;\n};\n\nexport const syncIOS: MutationField<'syncIOS'> = async () =>\n unsupported('syncIOS');\nexport const verifyAppOwnership: QueryField<\n 'verifyAppOwnership'\n> = async () => ({status: 'unknown', reason: 'unsupported', storeId: 'amazon'});\n\nexport const getAppTransactionIOS: QueryField<\n 'getAppTransactionIOS'\n> = async () => null;\nexport const getPromotedProductIOS: QueryField<\n 'getPromotedProductIOS'\n> = async () => null;\n\nexport const showManageSubscriptionsIOS: MutationField<\n 'showManageSubscriptionsIOS'\n> = async () => [];\nexport const presentExternalPurchaseLinkIOS: MutationField<\n 'presentExternalPurchaseLinkIOS'\n> = async () => unsupported('presentExternalPurchaseLinkIOS');\n\nexport const deepLinkToSubscriptions: MutationField<\n 'deepLinkToSubscriptions'\n> = async () => unsupported('deepLinkToSubscriptions');\n// Vega has no offer-code redemption surface; resolve null without launching.\nexport const openRedeemOfferCode: MutationField<\n 'openRedeemOfferCode'\n> = async () => null;\n\nexport const promotedProductListenerIOS = (): EventSubscription => ({\n remove: () => {},\n});\nexport const userChoiceBillingListenerAndroid = (): EventSubscription => ({\n remove: () => {},\n});\nexport const developerProvidedBillingListenerAndroid =\n (): EventSubscription => ({\n remove: () => {},\n });\nexport const subscriptionBillingIssueListener = (): EventSubscription => ({\n remove: () => {},\n});\n\nexport const isBillingProgramAvailableAndroid: MutationField<\n 'isBillingProgramAvailableAndroid'\n> = async () => unsupported('isBillingProgramAvailableAndroid');\nexport const getBillingChoiceInfoAndroid: QueryField<\n 'getBillingChoiceInfoAndroid'\n> = async () => unsupported('getBillingChoiceInfoAndroid');\nexport const launchExternalLinkAndroid: MutationField<\n 'launchExternalLinkAndroid'\n> = async () => unsupported('launchExternalLinkAndroid');\nexport const createBillingProgramReportingDetailsAndroid: MutationField<\n 'createBillingProgramReportingDetailsAndroid'\n> = async () => unsupported('createBillingProgramReportingDetailsAndroid');\nexport const showBillingProgramInformationDialogAndroid: MutationField<\n 'showBillingProgramInformationDialogAndroid'\n> = async () => unsupported('showBillingProgramInformationDialogAndroid');\nexport const showInAppMessagesAndroid: MutationField<\n 'showInAppMessagesAndroid'\n> = async () => unsupported('showInAppMessagesAndroid');\n\nconst purchaseFlowSdk: PurchaseFlowSdk = {\n finishTransaction: (args) => finishTransaction(args),\n getAvailablePurchases: () => getAvailablePurchases(),\n getPendingTransactionsIOS: undefined,\n purchaseUpdatedListener: (listener) => purchaseUpdatedListener(listener),\n purchaseErrorListener: (listener) => purchaseErrorListener(listener),\n};\n\n/**\n * Creates the app's purchase flow on Amazon Vega. Create one per signed-in\n * account, dispose it when the account changes, and pass it to\n * `useIAP({purchaseFlow})`.\n * @see {@link https://kit.openiap.dev/docs/purchase-flow}\n */\nexport function createPurchaseFlow(\n options: SdkPurchaseFlowOptions,\n): PurchaseFlow<Purchase>;\nexport function createPurchaseFlow<P extends PurchaseFlowPurchase>(\n options: PurchaseFlowOptions<P>,\n): PurchaseFlow<P>;\nexport function createPurchaseFlow(\n options: SdkPurchaseFlowOptions,\n): PurchaseFlow<Purchase> {\n return createSdkPurchaseFlow(purchaseFlowSdk, options);\n}\n\n/**\n * Confirms purchases with IAPKit from the app, for apps without a backend:\n * pass it as `confirmWithBackend` with a publishable key. Credit consumables\n * in `grant`, which runs before the purchase is consumed.\n */\nexport function confirmWithIapkit(\n options: IapkitConfirmationOptions<Purchase>,\n): PurchaseFlowOptions<Purchase>['confirmWithBackend'] {\n return createIapkitConfirmation(verifyPurchaseWithProvider, options);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.kepler.js","sourceRoot":"","sources":["../src/index.kepler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AAClC,OAAO,EAIN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,wBAAwB,GAEzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,aAAa,GAGd,MAAM,6BAA6B,CAAC;AAarC,OAAO,EAAC,sBAAsB,EAAC,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAC,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AAEzD,cAAc,SAAS,CAAC;AACxB,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,uBAAuB,EAAC,MAAM,WAAW,CAAC;AAmBvE,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,sBAAsB,CAAC;AAgB9B,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,oDAAoC,CAAA;IACpC,gDAAgC,CAAA;IAChC,2DAA2C,CAAA;IAC3C,wEAAwD,CAAA;IACxD,sFAAsE,CAAA;IACtE,uEAAuD,CAAA;AACz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,uBAAuB,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,uBAAuB,CAAC,QAAQ,CAAC;IACxE,qBAAqB,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,qBAAqB,CAAC,QAAQ,CAAC;CACrE,CAAC;AAcF,MAAM,UAAU,kBAAkB,CAChC,OAA+B;IAE/B,OAAO,qBAAqB,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAA4C;IAE5C,OAAO,wBAAwB,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import {getVegaIapModule} from './vega';\nimport {ErrorCode} from './types';\nimport {\n type PurchaseFlow,\n type PurchaseFlowOptions,\n type PurchaseFlowPurchase,\n} from './purchase-flow-core';\nimport {\n createIapkitConfirmation,\n type IapkitConfirmationOptions,\n} from './purchase-flow-confirmers';\nimport {\n clearRequested,\n createSdkPurchaseFlow,\n markRequested,\n type PurchaseFlowSdk,\n type SdkPurchaseFlowOptions,\n} from './utils/purchaseFlowBinding';\nimport type {\n MutationField,\n ProductQueryType,\n ProductRequest,\n Purchase,\n PurchaseError,\n PurchaseOptions,\n PurchaseUpdatedListenerOptions,\n QueryField,\n RequestPurchasePropsByPlatforms,\n RequestSubscriptionPropsByPlatforms,\n} from './types';\nimport {decodeAndroidPurchases} from './utils/availablePurchases';\nimport {createPurchaseError} from './utils/errorMapping';\n\nexport * from './types';\nexport {isRecoverableError} from './utils/errorMapping';\nexport * from './vega';\nexport * from './useIAP';\nexport {kitApi, KitApiError, resolveLocalizedPayload} from './kit-api';\nexport type {\n EntitlementsResponse,\n KitApiOptions,\n KitClientPayloadCache,\n KitClientPayloadOptions,\n KitClientPayloadResponse,\n KitLocalizedClientPayload,\n KitLocalizedClientPayloadOptions,\n KitLocalizedPayloadOptions,\n KitProduct,\n KitProductClientPayload,\n KitProductOffer,\n KitProductPlatform,\n KitProductsOptions,\n KitProductsResponse,\n KitSubscription,\n StatusResponse,\n} from './kit-api';\nexport {\n describePurchaseFlowStatus,\n toPurchaseConfirmationRequest,\n} from './purchase-flow-core';\nexport type {\n PurchaseConfirmation,\n PurchaseConfirmationRequest,\n PurchaseFlow,\n PurchaseFlowGuidance,\n PurchaseFlowGuidanceKey,\n PurchaseFlowOptions,\n PurchaseFlowOutcome,\n PurchaseFlowPurchase,\n PurchaseFlowStatus,\n RecoverPurchasesOptions,\n} from './purchase-flow-core';\nexport type {IapkitConfirmationOptions} from './purchase-flow-confirmers';\nexport type {SdkPurchaseFlowOptions} from './utils/purchaseFlowBinding';\n\nexport enum OpenIapEvent {\n PurchaseUpdated = 'purchase-updated',\n PurchaseError = 'purchase-error',\n PromotedProductIOS = 'promoted-product-ios',\n UserChoiceBillingAndroid = 'user-choice-billing-android',\n DeveloperProvidedBillingAndroid = 'developer-provided-billing-android',\n SubscriptionBillingIssue = 'subscription-billing-issue',\n}\n\nexport type ProductTypeInput = ProductQueryType;\n\nexport interface EventSubscription {\n remove(): void;\n}\n\nconst getModule = () => {\n const module = getVegaIapModule();\n if (!module) {\n throw new Error(\n 'Amazon Vega IAP module is unavailable. Install @amazon-devices/keplerscript-appstore-iap-lib in the Vega app target and build with the React Native for Vega kepler platform.',\n );\n }\n return module;\n};\n\nconst unsupported = (feature: string): never => {\n throw new Error(`${feature} is not supported on Amazon Vega.`);\n};\n\nconst normalizeProductType = (\n type?: ProductTypeInput | null,\n): ProductQueryType => {\n if (type == null || type === 'in-app') return 'in-app';\n if (type === 'subs' || type === 'all') return type;\n throw new Error(\n `Unsupported product type: ${String(type)}. Use in-app, subs, or all.`,\n );\n};\n\nconst normalizePurchaseArray = (purchases: Purchase[]): Purchase[] =>\n decodeAndroidPurchases(purchases);\n\nconst getAndroidRequest = (\n request?:\n | RequestPurchasePropsByPlatforms\n | RequestSubscriptionPropsByPlatforms\n | null,\n) => {\n return request?.google;\n};\n\nconst createPurchaseTokenError = (purchase: Purchase): Error => {\n const error = new Error(\n 'Purchase token is required to finish Amazon Vega transaction',\n ) as Error & PurchaseError;\n error.code = ErrorCode.DeveloperError;\n error.productId = purchase.productId;\n return error;\n};\n\nexport const emitter = {\n addListener(\n eventName: OpenIapEvent,\n listener: (payload: Purchase | PurchaseError) => void,\n ): EventSubscription {\n return getModule().addListener(eventName, listener);\n },\n removeListener(\n eventName: OpenIapEvent,\n listener: (payload: Purchase | PurchaseError) => void,\n ): void {\n return getModule().removeListener(eventName, listener);\n },\n};\n\nexport const purchaseUpdatedListener = (\n listener: (event: Purchase) => void,\n options?: PurchaseUpdatedListenerOptions | null,\n): EventSubscription => {\n return getModule().addListener(OpenIapEvent.PurchaseUpdated, (purchase) => {\n listener(purchase as Purchase);\n });\n};\n\nexport const purchaseErrorListener = (\n listener: (error: PurchaseError) => void,\n): EventSubscription => {\n return getModule().addListener(OpenIapEvent.PurchaseError, (error) => {\n listener(error as PurchaseError);\n });\n};\n\nexport const initConnection: MutationField<'initConnection'> = async (\n config,\n) => {\n return getModule().initConnection(config ?? null);\n};\n\nexport const endConnection: MutationField<'endConnection'> = async () => {\n return getModule().endConnection();\n};\n\nexport const fetchProducts = async (\n request: Omit<ProductRequest, 'type'> & {\n type?: ProductTypeInput | null;\n },\n): ReturnType<QueryField<'fetchProducts'>> => {\n const {skus, type} = request;\n return getModule().fetchProducts(normalizeProductType(type), skus);\n};\n\nexport const requestPurchase: MutationField<'requestPurchase'> = async (\n args,\n) => {\n markRequested(args.request.google?.skus ?? []);\n try {\n return await requestPurchaseFromStore(args);\n } catch (error) {\n clearRequested();\n throw error;\n }\n};\n\nconst requestPurchaseFromStore: MutationField<'requestPurchase'> = async (\n args,\n) => {\n const type = normalizeProductType(args.type);\n if (type === 'all') {\n throw createPurchaseError({\n code: ErrorCode.DeveloperError,\n message: 'Product type all is only supported for product queries.',\n });\n }\n const androidRequest = getAndroidRequest(args.request);\n if (!androidRequest?.skus?.length) {\n throw new Error(\n 'Invalid request for Amazon Vega. The `request.google.skus` property is required and must be a non-empty array.',\n );\n }\n\n return normalizePurchaseArray(\n await getModule().requestPurchase({\n skus: androidRequest.skus,\n type,\n }),\n );\n};\n\nexport const getAvailablePurchases: QueryField<\n 'getAvailablePurchases'\n> = async (options) => {\n return normalizePurchaseArray(\n await getModule().getAvailableItems((options ?? {}) as PurchaseOptions),\n );\n};\n\nexport const finishTransaction: MutationField<'finishTransaction'> = async ({\n purchase,\n isConsumable = false,\n}) => {\n const token = purchase.purchaseToken ?? undefined;\n if (!token) {\n throw createPurchaseTokenError(purchase);\n }\n\n if (isConsumable) {\n await getModule().consumePurchaseAndroid(token);\n return;\n }\n\n await getModule().acknowledgePurchaseAndroid(token);\n};\n\nexport const restorePurchases: MutationField<'restorePurchases'> = async () => {\n await getAvailablePurchases({\n includeSuspendedAndroid: false,\n });\n};\n\nexport const getActiveSubscriptions: QueryField<\n 'getActiveSubscriptions'\n> = async (subscriptionIds) => {\n return getModule().getActiveSubscriptions(subscriptionIds ?? null);\n};\n\nexport const hasActiveSubscriptions: QueryField<\n 'hasActiveSubscriptions'\n> = async (subscriptionIds) => {\n return getModule().hasActiveSubscriptions(subscriptionIds ?? null);\n};\n\nexport const getStorefront: QueryField<'getStorefront'> = async () => {\n return getModule().getStorefront();\n};\n\nexport const verifyPurchaseWithProvider: MutationField<\n 'verifyPurchaseWithProvider'\n> = async (options) => {\n return getModule().verifyPurchaseWithProvider(options);\n};\n\nexport const verifyPurchase: MutationField<'verifyPurchase'> = async () =>\n unsupported('verifyPurchase');\n\nexport const acknowledgePurchaseAndroid: MutationField<\n 'acknowledgePurchaseAndroid'\n> = async (purchaseToken) => {\n await getModule().acknowledgePurchaseAndroid(purchaseToken);\n return true;\n};\n\nexport const consumePurchaseAndroid: MutationField<\n 'consumePurchaseAndroid'\n> = async (purchaseToken) => {\n await getModule().consumePurchaseAndroid(purchaseToken);\n return true;\n};\n\nexport const syncIOS: MutationField<'syncIOS'> = async () =>\n unsupported('syncIOS');\nexport const verifyAppOwnership: QueryField<\n 'verifyAppOwnership'\n> = async () => ({status: 'unknown', reason: 'unsupported', storeId: 'amazon'});\n\nexport const getAppTransactionIOS: QueryField<\n 'getAppTransactionIOS'\n> = async () => null;\nexport const getPromotedProductIOS: QueryField<\n 'getPromotedProductIOS'\n> = async () => null;\n\nexport const showManageSubscriptionsIOS: MutationField<\n 'showManageSubscriptionsIOS'\n> = async () => [];\nexport const presentExternalPurchaseLinkIOS: MutationField<\n 'presentExternalPurchaseLinkIOS'\n> = async () => unsupported('presentExternalPurchaseLinkIOS');\n\nexport const deepLinkToSubscriptions: MutationField<\n 'deepLinkToSubscriptions'\n> = async () => unsupported('deepLinkToSubscriptions');\n// Vega has no offer-code redemption surface; resolve null without launching.\nexport const openRedeemOfferCode: MutationField<\n 'openRedeemOfferCode'\n> = async () => null;\n\nexport const promotedProductListenerIOS = (): EventSubscription => ({\n remove: () => {},\n});\nexport const userChoiceBillingListenerAndroid = (): EventSubscription => ({\n remove: () => {},\n});\nexport const developerProvidedBillingListenerAndroid =\n (): EventSubscription => ({\n remove: () => {},\n });\nexport const subscriptionBillingIssueListener = (): EventSubscription => ({\n remove: () => {},\n});\n\nexport const isBillingProgramAvailableAndroid: MutationField<\n 'isBillingProgramAvailableAndroid'\n> = async () => unsupported('isBillingProgramAvailableAndroid');\nexport const getBillingChoiceInfoAndroid: QueryField<\n 'getBillingChoiceInfoAndroid'\n> = async () => unsupported('getBillingChoiceInfoAndroid');\nexport const launchExternalLinkAndroid: MutationField<\n 'launchExternalLinkAndroid'\n> = async () => unsupported('launchExternalLinkAndroid');\nexport const createBillingProgramReportingDetailsAndroid: MutationField<\n 'createBillingProgramReportingDetailsAndroid'\n> = async () => unsupported('createBillingProgramReportingDetailsAndroid');\nexport const showBillingProgramInformationDialogAndroid: MutationField<\n 'showBillingProgramInformationDialogAndroid'\n> = async () => unsupported('showBillingProgramInformationDialogAndroid');\nexport const showAlternativeBillingOnlyInformationDialogAndroid: MutationField<\n 'showAlternativeBillingOnlyInformationDialogAndroid'\n> = async () =>\n unsupported('showAlternativeBillingOnlyInformationDialogAndroid');\n\nexport const showInAppMessagesAndroid: MutationField<\n 'showInAppMessagesAndroid'\n> = async () => unsupported('showInAppMessagesAndroid');\n\nconst purchaseFlowSdk: PurchaseFlowSdk = {\n finishTransaction: (args) => finishTransaction(args),\n getAvailablePurchases: () => getAvailablePurchases(),\n getPendingTransactionsIOS: undefined,\n purchaseUpdatedListener: (listener) => purchaseUpdatedListener(listener),\n purchaseErrorListener: (listener) => purchaseErrorListener(listener),\n};\n\n/**\n * Creates the app's purchase flow on Amazon Vega. Create one per signed-in\n * account, dispose it when the account changes, and pass it to\n * `useIAP({purchaseFlow})`.\n * @see {@link https://kit.openiap.dev/docs/purchase-flow}\n */\nexport function createPurchaseFlow(\n options: SdkPurchaseFlowOptions,\n): PurchaseFlow<Purchase>;\nexport function createPurchaseFlow<P extends PurchaseFlowPurchase>(\n options: PurchaseFlowOptions<P>,\n): PurchaseFlow<P>;\nexport function createPurchaseFlow(\n options: SdkPurchaseFlowOptions,\n): PurchaseFlow<Purchase> {\n return createSdkPurchaseFlow(purchaseFlowSdk, options);\n}\n\n/**\n * Confirms purchases with IAPKit from the app, for apps without a backend:\n * pass it as `confirmWithBackend` with a publishable key. Credit consumables\n * in `grant`, which runs before the purchase is consumed.\n */\nexport function confirmWithIapkit(\n options: IapkitConfirmationOptions<Purchase>,\n): PurchaseFlowOptions<Purchase>['confirmWithBackend'] {\n return createIapkitConfirmation(verifyPurchaseWithProvider, options);\n}\n"]}
|
|
@@ -102,6 +102,8 @@ export declare function createBillingProgramReportingDetailsAndroid(program: Bil
|
|
|
102
102
|
* @see {@link https://openiap.dev/docs/apis/android/show-billing-program-information-dialog-android}
|
|
103
103
|
*/
|
|
104
104
|
export declare const showBillingProgramInformationDialogAndroid: MutationField<'showBillingProgramInformationDialogAndroid'>;
|
|
105
|
+
/** Show the mandatory Google Play Alternative Billing Only notice before checkout. */
|
|
106
|
+
export declare const showAlternativeBillingOnlyInformationDialogAndroid: MutationField<'showAlternativeBillingOnlyInformationDialogAndroid'>;
|
|
105
107
|
/**
|
|
106
108
|
* Show Play Billing in-app messages, such as transactional subscription updates.
|
|
107
109
|
* Available in Google Play Billing Library 4.1.0+.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"android.d.ts","sourceRoot":"","sources":["../../src/modules/android.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAEV,qBAAqB,EAErB,qCAAqC,EAErC,eAAe,EACf,2BAA2B,EAI3B,uDAAuD,EACvD,aAAa,EACb,UAAU,EACX,MAAM,UAAU,CAAC;AAclB,wBAAgB,gBAAgB,CAAC,CAAC,SAAS;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAC,EAC5D,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,CAAC,GAAG;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAC,CAQnC;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,8BAA8B,GACzC,UAAU,eAAe,GAAG,IAAI,KAC/B,OAAO,CAAC,IAAI,CAuBd,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAChD,wBAAwB,CA2BzB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,EAAE,aAAa,CACpD,4BAA4B,CAuB7B,CAAC;AAMF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gCAAgC,EAAE,aAAa,CAC1D,kCAAkC,CAInC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,EAAE,UAAU,CAClD,6BAA6B,CAW9B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,yBAAyB,EAAE,aAAa,CACnD,2BAA2B,CAI5B,CAAC;AAiCF,wBAAgB,2CAA2C,CACzD,IAAI,EAAE,uDAAuD,GAC5D,OAAO,CAAC,qCAAqC,CAAC,CAAC;A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AyB,EAAE,aAAa,CACnD,2BAA2B,CAI5B,CAAC;AAiCF,wBAAgB,2CAA2C,CACzD,IAAI,EAAE,uDAAuD,GAC5D,OAAO,CAAC,qCAAqC,CAAC,CAAC;AAClD,wBAAgB,2CAA2C,CACzD,OAAO,EAAE,qBAAqB,EAC9B,oBAAoB,CAAC,EAAE,2BAA2B,GAAG,IAAI,GACxD,OAAO,CAAC,qCAAqC,CAAC,CAAC;AAclD;;;;;;;;;GASG;AACH,eAAO,MAAM,0CAA0C,EAAE,aAAa,CACpE,4CAA4C,CAS7C,CAAC;AAEF,sFAAsF;AACtF,eAAO,MAAM,kDAAkD,EAAE,aAAa,CAC5E,oDAAoD,CAIrD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,EAAE,aAAa,CAClD,0BAA0B,CAM3B,CAAC"}
|
package/build/modules/android.js
CHANGED
|
@@ -218,6 +218,11 @@ export const showBillingProgramInformationDialogAndroid = async (params) => {
|
|
|
218
218
|
externalTransactionToken: params.externalTransactionToken,
|
|
219
219
|
});
|
|
220
220
|
};
|
|
221
|
+
/** Show the mandatory Google Play Alternative Billing Only notice before checkout. */
|
|
222
|
+
export const showAlternativeBillingOnlyInformationDialogAndroid = async () => {
|
|
223
|
+
requireAndroidPlatform('showAlternativeBillingOnlyInformationDialogAndroid');
|
|
224
|
+
return ExpoIapModule.showAlternativeBillingOnlyInformationDialogAndroid();
|
|
225
|
+
};
|
|
221
226
|
/**
|
|
222
227
|
* Show Play Billing in-app messages, such as transactional subscription updates.
|
|
223
228
|
* Available in Google Play Billing Library 4.1.0+.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"android.js","sourceRoot":"","sources":["../../src/modules/android.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAE/C,mBAAmB;AACnB,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EA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MAAM,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,gDAAgD,GAElD,KAAK,EACP,IAA6D,EACb,EAAE;IAClD,sBAAsB,CAAC,6CAA6C,CAAC,CAAC;IACtE,OAAO,aAAa,CAAC,2CAA2C,CAC9D,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAClC,CAAC;AACJ,CAAC,CAAC;AASF,MAAM,UAAU,2CAA2C,CACzD,aAE2D,EAC3D,oBAAyD;IAEzD,MAAM,IAAI,GACR,OAAO,aAAa,KAAK,QAAQ;QAC/B,CAAC,CAAC,EAAC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAC;QAChD,CAAC,CAAC,aAAa,CAAC;IACpB,OAAO,gDAAgD,CAAC,IAAI,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAEnD,KAAK,EACP,MAAoD,EACrB,EAAE;IACjC,sBAAsB,CAAC,4CAA4C,CAAC,CAAC;IACrE,OAAO,aAAa,CAAC,0CAA0C,CAAC;QAC9D,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,gBAAgB;QACzD,wBAAwB,EAAE,MAAM,CAAC,wBAAwB;KAC1D,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAEjC,KAAK,EACP,MAAyC,EACL,EAAE;IACtC,sBAAsB,CAAC,0BAA0B,CAAC,CAAC;IACnD,OAAO,aAAa,CAAC,wBAAwB,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC;AAChE,CAAC,CAAC","sourcesContent":["// External dependencies\nimport {Linking, Platform} from 'react-native';\n\n// Internal modules\nimport ExpoIapModule from '../ExpoIapModule';\nimport {invokeNativeWithPurchaseError} from '../utils/nativeError';\nimport {isVegaOS} from '../vega';\n\n// Types\nimport type {\n BillingChoiceInfoAndroid,\n BillingProgramAndroid,\n BillingProgramInformationDialogParamsAndroid,\n BillingProgramReportingDetailsAndroid,\n BillingResultAndroid,\n DeepLinkOptions,\n DeveloperBillingTypeAndroid,\n GetBillingChoiceInfoParamsAndroid,\n InAppMessageParamsAndroid,\n InAppMessageResultAndroid,\n MutationCreateBillingProgramReportingDetailsAndroidArgs,\n MutationField,\n QueryField,\n} from '../types';\n\n/**\n * Throws the documented Android-only error; Vega OS passes, as in\n * `isAndroidStoreRuntime`. Without it, other platforms reach the native proxy\n * and fail with an opaque `ExpoIapModule.<name> is not a function`.\n */\nconst requireAndroidPlatform = (methodName: string): void => {\n if (Platform.OS !== 'android' && !isVegaOS()) {\n throw new Error(`${methodName} is only available on Android and Vega OS`);\n }\n};\n\n// Type guards\nexport function isProductAndroid<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'android'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n typeof item.platform === 'string' &&\n item.platform.toLowerCase() === 'android'\n );\n}\n\n/**\n * Deep link to subscriptions screen on Android.\n * @param {Object} params - The parameters object\n * @param {string} params.skuAndroid - The product's SKU (on Android)\n * @param {string} params.packageNameAndroid - The package name of your Android app (e.g., 'com.example.app')\n * @returns {Promise<void>}\n *\n * @example\n * ```typescript\n * await deepLinkToSubscriptionsAndroid({\n * skuAndroid: 'subscription_id',\n * packageNameAndroid: 'com.example.app'\n * });\n * ```\n */\nexport const deepLinkToSubscriptionsAndroid = async (\n options?: DeepLinkOptions | null,\n): Promise<void> => {\n const sku = options?.skuAndroid ?? undefined;\n const packageName = options?.packageNameAndroid ?? undefined;\n\n // Prefer native deep link implementation via OpenIAP module\n if (ExpoIapModule.deepLinkToSubscriptionsAndroid) {\n return ExpoIapModule.deepLinkToSubscriptionsAndroid({\n skuAndroid: sku,\n packageNameAndroid: packageName,\n });\n }\n\n // Fallback to Linking if native method unavailable\n if (!packageName) {\n throw new Error(\n 'packageName is required for deepLinkToSubscriptionsAndroid',\n );\n }\n const base = `https://play.google.com/store/account/subscriptions?package=${encodeURIComponent(\n packageName,\n )}`;\n const url = sku ? `${base}&sku=${encodeURIComponent(sku)}` : base;\n return Linking.openURL(url);\n};\n\n/**\n * Consume a purchase token so the user can purchase the same product again\n * (Android consumable products). Prefer using `finishTransaction` with\n * `isConsumable: true`, which dispatches to this under the hood.\n *\n * @see {@link https://openiap.dev/docs/apis/android/consume-purchase-android}\n */\nexport const consumePurchaseAndroid: MutationField<\n 'consumePurchaseAndroid'\n> = async (purchaseToken) => {\n requireAndroidPlatform('consumePurchaseAndroid');\n const result = await invokeNativeWithPurchaseError(\n () => ExpoIapModule.consumePurchaseAndroid(purchaseToken),\n 'android',\n );\n\n if (typeof result === 'boolean') {\n return result;\n }\n\n if (result && typeof result === 'object') {\n const record = result as Record<string, unknown>;\n if (typeof record.success === 'boolean') {\n return record.success;\n }\n if (typeof record.responseCode === 'number') {\n return record.responseCode === 0;\n }\n }\n\n throw new Error(\n `consumePurchaseAndroid returned an unexpected response payload: ${JSON.stringify(\n result,\n )}`,\n );\n};\n\n/**\n * Acknowledge a non-consumable purchase or subscription (Android only).\n * @param {Object} params - The parameters object\n * @param {string} params.token - The product's token (on Android)\n * @returns {Promise<VoidResult | void>}\n * @throws Error if called on a non-Android platform\n *\n * @see {@link https://openiap.dev/docs/apis/android/acknowledge-purchase-android}\n */\nexport const acknowledgePurchaseAndroid: MutationField<\n 'acknowledgePurchaseAndroid'\n> = async (purchaseToken) => {\n requireAndroidPlatform('acknowledgePurchaseAndroid');\n const result = await invokeNativeWithPurchaseError(\n () => ExpoIapModule.acknowledgePurchaseAndroid(purchaseToken),\n 'android',\n );\n\n if (typeof result === 'boolean') {\n return result;\n }\n\n if (result && typeof result === 'object') {\n const record = result as Record<string, unknown>;\n if (typeof record.success === 'boolean') {\n return record.success;\n }\n if (typeof record.responseCode === 'number') {\n return record.responseCode === 0;\n }\n }\n\n return true;\n};\n\n// ============================================================================\n// Billing Programs API (Google Play Billing Library 8.2.0+)\n// ============================================================================\n\n/**\n * Check if a specific billing program is available for this user/device (Android only).\n * Available in Google Play Billing Library 8.2.0+. Billing Choice availability\n * details, including the configured renderer and external-link support, require 9.1.0+.\n *\n * @param program - The billing program to check\n * @returns Promise resolving to availability result\n *\n * @example\n * ```typescript\n * const result = await isBillingProgramAvailableAndroid('external-offer');\n * if (result.isAvailable) {\n * // Proceed with billing program flow\n * }\n * ```\n *\n * @see {@link https://openiap.dev/docs/apis/android/is-billing-program-available-android}\n */\nexport const isBillingProgramAvailableAndroid: MutationField<\n 'isBillingProgramAvailableAndroid'\n> = async (program) => {\n requireAndroidPlatform('isBillingProgramAvailableAndroid');\n return ExpoIapModule.isBillingProgramAvailableAndroid(program);\n};\n\n/**\n * Fetch Play Billing assets and loyalty text for developer-rendered Billing Choice screens.\n * Available in Google Play Billing Library 9.1.0+.\n *\n * @param params - Billing Choice info request parameters\n * @returns Promise resolving to Play Billing Choice display information\n *\n * @see {@link https://openiap.dev/docs/apis/android/get-billing-choice-info-android}\n */\nexport const getBillingChoiceInfoAndroid: QueryField<\n 'getBillingChoiceInfoAndroid'\n> = async (\n params: GetBillingChoiceInfoParamsAndroid = {},\n): Promise<BillingChoiceInfoAndroid> => {\n requireAndroidPlatform('getBillingChoiceInfoAndroid');\n return ExpoIapModule.getBillingChoiceInfoAndroid({\n billingProgram: params.billingProgram ?? 'billing-choice',\n playBillingChoiceImageLayout:\n params.playBillingChoiceImageLayout ?? 'rectangular-four-by-one',\n userLocale: params.userLocale ?? null,\n });\n};\n\n/**\n * Launch an external link for the specified billing program (Android only).\n * Available in Google Play Billing Library 8.2.0+; developer-rendered Billing\n * Choice external-link flows require 9.1.0+ and `externalTransactionToken`.\n *\n * @param params - The external link parameters\n * @returns Promise resolving to true if the link was launched successfully\n *\n * @example\n * ```typescript\n * await launchExternalLinkAndroid({\n * billingProgram: 'billing-choice',\n * externalTransactionToken: 'pre-generated-token',\n * launchMode: 'launch-in-external-browser-or-app',\n * linkType: 'link-to-digital-content-offer',\n * linkUri: 'https://your-payment-site.com',\n * });\n * ```\n *\n * @see {@link https://openiap.dev/docs/apis/android/launch-external-link-android}\n */\nexport const launchExternalLinkAndroid: MutationField<\n 'launchExternalLinkAndroid'\n> = async (params) => {\n requireAndroidPlatform('launchExternalLinkAndroid');\n return ExpoIapModule.launchExternalLinkAndroid(params);\n};\n\n/**\n * Create billing program reporting details for Google Play reporting (Android only).\n * Available in Google Play Billing Library 8.2.0+.\n *\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 * @param program - The billing program type\n * @returns Promise resolving to reporting details including the external transaction token\n *\n * @example\n * ```typescript\n * const details = await createBillingProgramReportingDetailsAndroid('external-offer');\n * // Report details.externalTransactionToken to Google Play within 24 hours\n * await reportToGooglePlay(details.externalTransactionToken);\n * ```\n *\n * @see {@link https://openiap.dev/docs/apis/android/create-billing-program-reporting-details-android}\n */\nconst createBillingProgramReportingDetailsAndroidField: MutationField<\n 'createBillingProgramReportingDetailsAndroid'\n> = async (\n args: MutationCreateBillingProgramReportingDetailsAndroidArgs,\n): Promise<BillingProgramReportingDetailsAndroid> => {\n requireAndroidPlatform('createBillingProgramReportingDetailsAndroid');\n return ExpoIapModule.createBillingProgramReportingDetailsAndroid(\n args.program,\n args.developerBillingType ?? null,\n );\n};\n\nexport function createBillingProgramReportingDetailsAndroid(\n args: MutationCreateBillingProgramReportingDetailsAndroidArgs,\n): Promise<BillingProgramReportingDetailsAndroid>;\nexport function createBillingProgramReportingDetailsAndroid(\n program: BillingProgramAndroid,\n developerBillingType?: DeveloperBillingTypeAndroid | null,\n): Promise<BillingProgramReportingDetailsAndroid>;\nexport function createBillingProgramReportingDetailsAndroid(\n programOrArgs:\n | BillingProgramAndroid\n | MutationCreateBillingProgramReportingDetailsAndroidArgs,\n developerBillingType?: DeveloperBillingTypeAndroid | null,\n): Promise<BillingProgramReportingDetailsAndroid> {\n const args =\n typeof programOrArgs === 'string'\n ? {program: programOrArgs, developerBillingType}\n : programOrArgs;\n return createBillingProgramReportingDetailsAndroidField(args);\n}\n\n/**\n * Show Google's mandatory information dialog before a developer-rendered,\n * in-app Billing Choice screen.\n * Available in Google Play Billing Library 9.1.0+.\n *\n * @param params - Dialog parameters with the external transaction token\n * @returns Promise resolving to BillingResult\n *\n * @see {@link https://openiap.dev/docs/apis/android/show-billing-program-information-dialog-android}\n */\nexport const showBillingProgramInformationDialogAndroid: MutationField<\n 'showBillingProgramInformationDialogAndroid'\n> = async (\n params: BillingProgramInformationDialogParamsAndroid,\n): Promise<BillingResultAndroid> => {\n requireAndroidPlatform('showBillingProgramInformationDialogAndroid');\n return ExpoIapModule.showBillingProgramInformationDialogAndroid({\n billingProgram: params.billingProgram ?? 'billing-choice',\n externalTransactionToken: params.externalTransactionToken,\n });\n};\n\n/**\n * Show Play Billing in-app messages, such as transactional subscription updates.\n * Available in Google Play Billing Library 4.1.0+.\n *\n * @param params - Optional in-app message categories\n * @returns Promise resolving to in-app message result\n *\n * @see {@link https://openiap.dev/docs/apis/android/show-in-app-messages-android}\n */\nexport const showInAppMessagesAndroid: MutationField<\n 'showInAppMessagesAndroid'\n> = async (\n params?: InAppMessageParamsAndroid | null,\n): Promise<InAppMessageResultAndroid> => {\n requireAndroidPlatform('showInAppMessagesAndroid');\n return ExpoIapModule.showInAppMessagesAndroid(params ?? null);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"android.js","sourceRoot":"","sources":["../../src/modules/android.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAE/C,mBAAmB;AACnB,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAC,6BAA6B,EAAC,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAmBjC;;;;GAIG;AACH,MAAM,sBAAsB,GAAG,CAAC,UAAkB,EAAQ,EAAE;IAC1D,IAAI,QAAQ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,aAAa,CAAC,2CAA2C,CAC9D,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAClC,CAAC;AACJ,CAAC,CAAC;AASF,MAAM,UAAU,2CAA2C,CACzD,aAE2D,EAC3D,oBAAyD;IAEzD,MAAM,IAAI,GACR,OAAO,aAAa,KAAK,QAAQ;QAC/B,CAAC,CAAC,EAAC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAC;QAChD,CAAC,CAAC,aAAa,CAAC;IACpB,OAAO,gDAAgD,CAAC,IAAI,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAEnD,KAAK,EACP,MAAoD,EACrB,EAAE;IACjC,sBAAsB,CAAC,4CAA4C,CAAC,CAAC;IACrE,OAAO,aAAa,CAAC,0CAA0C,CAAC;QAC9D,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,gBAAgB;QACzD,wBAAwB,EAAE,MAAM,CAAC,wBAAwB;KAC1D,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,sFAAsF;AACtF,MAAM,CAAC,MAAM,kDAAkD,GAE3D,KAAK,IAAI,EAAE;IACb,sBAAsB,CAAC,oDAAoD,CAAC,CAAC;IAC7E,OAAO,aAAa,CAAC,kDAAkD,EAAE,CAAC;AAC5E,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAEjC,KAAK,EACP,MAAyC,EACL,EAAE;IACtC,sBAAsB,CAAC,0BAA0B,CAAC,CAAC;IACnD,OAAO,aAAa,CAAC,wBAAwB,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC;AAChE,CAAC,CAAC","sourcesContent":["// External dependencies\nimport {Linking, Platform} from 'react-native';\n\n// Internal modules\nimport ExpoIapModule from '../ExpoIapModule';\nimport {invokeNativeWithPurchaseError} from '../utils/nativeError';\nimport {isVegaOS} from '../vega';\n\n// Types\nimport type {\n BillingChoiceInfoAndroid,\n BillingProgramAndroid,\n BillingProgramInformationDialogParamsAndroid,\n BillingProgramReportingDetailsAndroid,\n BillingResultAndroid,\n DeepLinkOptions,\n DeveloperBillingTypeAndroid,\n GetBillingChoiceInfoParamsAndroid,\n InAppMessageParamsAndroid,\n InAppMessageResultAndroid,\n MutationCreateBillingProgramReportingDetailsAndroidArgs,\n MutationField,\n QueryField,\n} from '../types';\n\n/**\n * Throws the documented Android-only error; Vega OS passes, as in\n * `isAndroidStoreRuntime`. Without it, other platforms reach the native proxy\n * and fail with an opaque `ExpoIapModule.<name> is not a function`.\n */\nconst requireAndroidPlatform = (methodName: string): void => {\n if (Platform.OS !== 'android' && !isVegaOS()) {\n throw new Error(`${methodName} is only available on Android and Vega OS`);\n }\n};\n\n// Type guards\nexport function isProductAndroid<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'android'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n typeof item.platform === 'string' &&\n item.platform.toLowerCase() === 'android'\n );\n}\n\n/**\n * Deep link to subscriptions screen on Android.\n * @param {Object} params - The parameters object\n * @param {string} params.skuAndroid - The product's SKU (on Android)\n * @param {string} params.packageNameAndroid - The package name of your Android app (e.g., 'com.example.app')\n * @returns {Promise<void>}\n *\n * @example\n * ```typescript\n * await deepLinkToSubscriptionsAndroid({\n * skuAndroid: 'subscription_id',\n * packageNameAndroid: 'com.example.app'\n * });\n * ```\n */\nexport const deepLinkToSubscriptionsAndroid = async (\n options?: DeepLinkOptions | null,\n): Promise<void> => {\n const sku = options?.skuAndroid ?? undefined;\n const packageName = options?.packageNameAndroid ?? undefined;\n\n // Prefer native deep link implementation via OpenIAP module\n if (ExpoIapModule.deepLinkToSubscriptionsAndroid) {\n return ExpoIapModule.deepLinkToSubscriptionsAndroid({\n skuAndroid: sku,\n packageNameAndroid: packageName,\n });\n }\n\n // Fallback to Linking if native method unavailable\n if (!packageName) {\n throw new Error(\n 'packageName is required for deepLinkToSubscriptionsAndroid',\n );\n }\n const base = `https://play.google.com/store/account/subscriptions?package=${encodeURIComponent(\n packageName,\n )}`;\n const url = sku ? `${base}&sku=${encodeURIComponent(sku)}` : base;\n return Linking.openURL(url);\n};\n\n/**\n * Consume a purchase token so the user can purchase the same product again\n * (Android consumable products). Prefer using `finishTransaction` with\n * `isConsumable: true`, which dispatches to this under the hood.\n *\n * @see {@link https://openiap.dev/docs/apis/android/consume-purchase-android}\n */\nexport const consumePurchaseAndroid: MutationField<\n 'consumePurchaseAndroid'\n> = async (purchaseToken) => {\n requireAndroidPlatform('consumePurchaseAndroid');\n const result = await invokeNativeWithPurchaseError(\n () => ExpoIapModule.consumePurchaseAndroid(purchaseToken),\n 'android',\n );\n\n if (typeof result === 'boolean') {\n return result;\n }\n\n if (result && typeof result === 'object') {\n const record = result as Record<string, unknown>;\n if (typeof record.success === 'boolean') {\n return record.success;\n }\n if (typeof record.responseCode === 'number') {\n return record.responseCode === 0;\n }\n }\n\n throw new Error(\n `consumePurchaseAndroid returned an unexpected response payload: ${JSON.stringify(\n result,\n )}`,\n );\n};\n\n/**\n * Acknowledge a non-consumable purchase or subscription (Android only).\n * @param {Object} params - The parameters object\n * @param {string} params.token - The product's token (on Android)\n * @returns {Promise<VoidResult | void>}\n * @throws Error if called on a non-Android platform\n *\n * @see {@link https://openiap.dev/docs/apis/android/acknowledge-purchase-android}\n */\nexport const acknowledgePurchaseAndroid: MutationField<\n 'acknowledgePurchaseAndroid'\n> = async (purchaseToken) => {\n requireAndroidPlatform('acknowledgePurchaseAndroid');\n const result = await invokeNativeWithPurchaseError(\n () => ExpoIapModule.acknowledgePurchaseAndroid(purchaseToken),\n 'android',\n );\n\n if (typeof result === 'boolean') {\n return result;\n }\n\n if (result && typeof result === 'object') {\n const record = result as Record<string, unknown>;\n if (typeof record.success === 'boolean') {\n return record.success;\n }\n if (typeof record.responseCode === 'number') {\n return record.responseCode === 0;\n }\n }\n\n return true;\n};\n\n// ============================================================================\n// Billing Programs API (Google Play Billing Library 8.2.0+)\n// ============================================================================\n\n/**\n * Check if a specific billing program is available for this user/device (Android only).\n * Available in Google Play Billing Library 8.2.0+. Billing Choice availability\n * details, including the configured renderer and external-link support, require 9.1.0+.\n *\n * @param program - The billing program to check\n * @returns Promise resolving to availability result\n *\n * @example\n * ```typescript\n * const result = await isBillingProgramAvailableAndroid('external-offer');\n * if (result.isAvailable) {\n * // Proceed with billing program flow\n * }\n * ```\n *\n * @see {@link https://openiap.dev/docs/apis/android/is-billing-program-available-android}\n */\nexport const isBillingProgramAvailableAndroid: MutationField<\n 'isBillingProgramAvailableAndroid'\n> = async (program) => {\n requireAndroidPlatform('isBillingProgramAvailableAndroid');\n return ExpoIapModule.isBillingProgramAvailableAndroid(program);\n};\n\n/**\n * Fetch Play Billing assets and loyalty text for developer-rendered Billing Choice screens.\n * Available in Google Play Billing Library 9.1.0+.\n *\n * @param params - Billing Choice info request parameters\n * @returns Promise resolving to Play Billing Choice display information\n *\n * @see {@link https://openiap.dev/docs/apis/android/get-billing-choice-info-android}\n */\nexport const getBillingChoiceInfoAndroid: QueryField<\n 'getBillingChoiceInfoAndroid'\n> = async (\n params: GetBillingChoiceInfoParamsAndroid = {},\n): Promise<BillingChoiceInfoAndroid> => {\n requireAndroidPlatform('getBillingChoiceInfoAndroid');\n return ExpoIapModule.getBillingChoiceInfoAndroid({\n billingProgram: params.billingProgram ?? 'billing-choice',\n playBillingChoiceImageLayout:\n params.playBillingChoiceImageLayout ?? 'rectangular-four-by-one',\n userLocale: params.userLocale ?? null,\n });\n};\n\n/**\n * Launch an external link for the specified billing program (Android only).\n * Available in Google Play Billing Library 8.2.0+; developer-rendered Billing\n * Choice external-link flows require 9.1.0+ and `externalTransactionToken`.\n *\n * @param params - The external link parameters\n * @returns Promise resolving to true if the link was launched successfully\n *\n * @example\n * ```typescript\n * await launchExternalLinkAndroid({\n * billingProgram: 'billing-choice',\n * externalTransactionToken: 'pre-generated-token',\n * launchMode: 'launch-in-external-browser-or-app',\n * linkType: 'link-to-digital-content-offer',\n * linkUri: 'https://your-payment-site.com',\n * });\n * ```\n *\n * @see {@link https://openiap.dev/docs/apis/android/launch-external-link-android}\n */\nexport const launchExternalLinkAndroid: MutationField<\n 'launchExternalLinkAndroid'\n> = async (params) => {\n requireAndroidPlatform('launchExternalLinkAndroid');\n return ExpoIapModule.launchExternalLinkAndroid(params);\n};\n\n/**\n * Create billing program reporting details for Google Play reporting (Android only).\n * Available in Google Play Billing Library 8.2.0+.\n *\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 * @param program - The billing program type\n * @returns Promise resolving to reporting details including the external transaction token\n *\n * @example\n * ```typescript\n * const details = await createBillingProgramReportingDetailsAndroid('external-offer');\n * // Report details.externalTransactionToken to Google Play within 24 hours\n * await reportToGooglePlay(details.externalTransactionToken);\n * ```\n *\n * @see {@link https://openiap.dev/docs/apis/android/create-billing-program-reporting-details-android}\n */\nconst createBillingProgramReportingDetailsAndroidField: MutationField<\n 'createBillingProgramReportingDetailsAndroid'\n> = async (\n args: MutationCreateBillingProgramReportingDetailsAndroidArgs,\n): Promise<BillingProgramReportingDetailsAndroid> => {\n requireAndroidPlatform('createBillingProgramReportingDetailsAndroid');\n return ExpoIapModule.createBillingProgramReportingDetailsAndroid(\n args.program,\n args.developerBillingType ?? null,\n );\n};\n\nexport function createBillingProgramReportingDetailsAndroid(\n args: MutationCreateBillingProgramReportingDetailsAndroidArgs,\n): Promise<BillingProgramReportingDetailsAndroid>;\nexport function createBillingProgramReportingDetailsAndroid(\n program: BillingProgramAndroid,\n developerBillingType?: DeveloperBillingTypeAndroid | null,\n): Promise<BillingProgramReportingDetailsAndroid>;\nexport function createBillingProgramReportingDetailsAndroid(\n programOrArgs:\n | BillingProgramAndroid\n | MutationCreateBillingProgramReportingDetailsAndroidArgs,\n developerBillingType?: DeveloperBillingTypeAndroid | null,\n): Promise<BillingProgramReportingDetailsAndroid> {\n const args =\n typeof programOrArgs === 'string'\n ? {program: programOrArgs, developerBillingType}\n : programOrArgs;\n return createBillingProgramReportingDetailsAndroidField(args);\n}\n\n/**\n * Show Google's mandatory information dialog before a developer-rendered,\n * in-app Billing Choice screen.\n * Available in Google Play Billing Library 9.1.0+.\n *\n * @param params - Dialog parameters with the external transaction token\n * @returns Promise resolving to BillingResult\n *\n * @see {@link https://openiap.dev/docs/apis/android/show-billing-program-information-dialog-android}\n */\nexport const showBillingProgramInformationDialogAndroid: MutationField<\n 'showBillingProgramInformationDialogAndroid'\n> = async (\n params: BillingProgramInformationDialogParamsAndroid,\n): Promise<BillingResultAndroid> => {\n requireAndroidPlatform('showBillingProgramInformationDialogAndroid');\n return ExpoIapModule.showBillingProgramInformationDialogAndroid({\n billingProgram: params.billingProgram ?? 'billing-choice',\n externalTransactionToken: params.externalTransactionToken,\n });\n};\n\n/** Show the mandatory Google Play Alternative Billing Only notice before checkout. */\nexport const showAlternativeBillingOnlyInformationDialogAndroid: MutationField<\n 'showAlternativeBillingOnlyInformationDialogAndroid'\n> = async () => {\n requireAndroidPlatform('showAlternativeBillingOnlyInformationDialogAndroid');\n return ExpoIapModule.showAlternativeBillingOnlyInformationDialogAndroid();\n};\n\n/**\n * Show Play Billing in-app messages, such as transactional subscription updates.\n * Available in Google Play Billing Library 4.1.0+.\n *\n * @param params - Optional in-app message categories\n * @returns Promise resolving to in-app message result\n *\n * @see {@link https://openiap.dev/docs/apis/android/show-in-app-messages-android}\n */\nexport const showInAppMessagesAndroid: MutationField<\n 'showInAppMessagesAndroid'\n> = async (\n params?: InAppMessageParamsAndroid | null,\n): Promise<InAppMessageResultAndroid> => {\n requireAndroidPlatform('showInAppMessagesAndroid');\n return ExpoIapModule.showInAppMessagesAndroid(params ?? null);\n};\n"]}
|
package/build/modules/ios.d.ts
CHANGED
|
@@ -241,7 +241,7 @@ export declare const isEligibleForExternalPurchaseCustomLinkIOS: QueryField<'isE
|
|
|
241
241
|
* Get external purchase token for reporting to Apple (iOS 18.1+).
|
|
242
242
|
* Use this token with Apple's External Purchase Server API to report transactions.
|
|
243
243
|
*
|
|
244
|
-
* @param tokenType -
|
|
244
|
+
* @param tokenType - Reporting token type for the app's storefront.
|
|
245
245
|
* @returns Promise resolving to the token result with token string or error
|
|
246
246
|
* @platform iOS
|
|
247
247
|
* @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/token(for:)
|
package/build/modules/ios.js
CHANGED
|
@@ -356,7 +356,7 @@ export const isEligibleForExternalPurchaseCustomLinkIOS = async () => {
|
|
|
356
356
|
* Get external purchase token for reporting to Apple (iOS 18.1+).
|
|
357
357
|
* Use this token with Apple's External Purchase Server API to report transactions.
|
|
358
358
|
*
|
|
359
|
-
* @param tokenType -
|
|
359
|
+
* @param tokenType - Reporting token type for the app's storefront.
|
|
360
360
|
* @returns Promise resolving to the token result with token string or error
|
|
361
361
|
* @platform iOS
|
|
362
362
|
* @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/token(for:)
|
|
@@ -366,7 +366,7 @@ export const isEligibleForExternalPurchaseCustomLinkIOS = async () => {
|
|
|
366
366
|
export const getExternalPurchaseCustomLinkTokenIOS = async (tokenType) => {
|
|
367
367
|
requireIosPlatform('getExternalPurchaseCustomLinkTokenIOS');
|
|
368
368
|
if (!tokenType) {
|
|
369
|
-
throw new Error(
|
|
369
|
+
throw new Error('getExternalPurchaseCustomLinkTokenIOS requires a tokenType');
|
|
370
370
|
}
|
|
371
371
|
const result = await callNativeIOS(() => ExpoIapModule.getExternalPurchaseCustomLinkTokenIOS(tokenType));
|
|
372
372
|
return result;
|
package/build/modules/ios.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAe7C,OAAO,EAAoB,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAC,6BAA6B,EAAC,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAC,oBAAoB,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CAAC,SAAS,CAAC,CAC/D,CAAC;IACF,OAAO,MAAkD,CAAC;AAC5D,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAEhD,KAAK,EAAE,UAAU,EAAE,EAAE;IACvB,kBAAkB,CAAC,yCAAyC,CAAC,CAAC;IAC9D,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,GAAG,EAAE,CACtC,aAAa,CAAC,uCAAuC,CAAC,UAAU,CAAC,CAClE,CAAC;IACF,OAAO,MAAmD,CAAC;AAC7D,CAAC,CAAC;AAEF,uEAAuE","sourcesContent":["// Internal modules\nimport ExpoIapModule from '../ExpoIapModule';\n\n// Types\nimport type {\n ExternalPurchaseCustomLinkNoticeResultIOS,\n ExternalPurchaseCustomLinkTokenResultIOS,\n ExternalPurchaseLinkResultIOS,\n ExternalPurchaseNoticeResultIOS,\n MutationField,\n ProductIOS,\n Purchase,\n PurchaseIOS,\n QueryField,\n SubscriptionStatusIOS,\n} from '../types';\nimport {type PurchaseError} from '../utils/errorMapping';\nimport {invokeNativeWithPurchaseError} from '../utils/nativeError';\nimport {decodeApplePurchases} from '../utils/availablePurchases';\nimport {Linking, Platform} from 'react-native';\n\n/**\n * Throws the documented iOS-only error. Without it, other platforms reach the\n * native proxy and fail with an opaque `ExpoIapModule.<name> is not a function`.\n */\nconst requireIosPlatform = (methodName: string): void => {\n if (Platform.OS !== 'ios') {\n throw new Error(`${methodName} is only available on iOS`);\n }\n};\n\n// iOS rejections carry the OpenIAP error envelope; rethrow them as PurchaseError.\nconst callNativeIOS = <T>(operation: () => Promise<T>): Promise<T> =>\n invokeNativeWithPurchaseError(operation, 'ios');\n\nexport type TransactionEvent = {\n transaction?: Purchase;\n error?: PurchaseError;\n};\n\n// Type guards\nexport function isProductIOS<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'ios'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n typeof item.platform === 'string' &&\n item.platform.toLowerCase() === 'ios'\n );\n}\n\n// Functions\n/**\n * Sync state with Appstore (iOS only)\n * https://developer.apple.com/documentation/storekit/appstore/3791906-sync\n *\n * @returns Promise resolving to true on success\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/sync-ios}\n */\nexport const syncIOS: MutationField<'syncIOS'> = async () => {\n requireIosPlatform('syncIOS');\n return !!(await callNativeIOS(() => ExpoIapModule.syncIOS()));\n};\n\n/**\n * Check if user is eligible for introductory offer\n *\n * @param groupId - The subscription group ID\n * @returns Promise resolving to true if eligible\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/is-eligible-for-intro-offer-ios}\n */\nexport const isEligibleForIntroOfferIOS: QueryField<\n 'isEligibleForIntroOfferIOS'\n> = async (groupId) => {\n requireIosPlatform('isEligibleForIntroOfferIOS');\n if (!groupId) {\n throw new Error('isEligibleForIntroOfferIOS requires a groupId');\n }\n return callNativeIOS(() => ExpoIapModule.isEligibleForIntroOfferIOS(groupId));\n};\n\n/**\n * Get subscription status for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to array of subscription status\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/subscription-status-ios}\n */\nexport const subscriptionStatusIOS: QueryField<\n 'subscriptionStatusIOS'\n> = async (sku) => {\n requireIosPlatform('subscriptionStatusIOS');\n if (!sku) {\n throw new Error('subscriptionStatusIOS requires a SKU');\n }\n const status = await callNativeIOS(() =>\n ExpoIapModule.subscriptionStatusIOS(sku),\n );\n return (status ?? []) as SubscriptionStatusIOS[];\n};\n\n/**\n * Get current entitlement for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to current entitlement\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/current-entitlement-ios}\n */\nexport const currentEntitlementIOS: QueryField<\n 'currentEntitlementIOS'\n> = async (sku) => {\n requireIosPlatform('currentEntitlementIOS');\n if (!sku) {\n throw new Error('currentEntitlementIOS requires a SKU');\n }\n const purchase = await callNativeIOS(() =>\n ExpoIapModule.currentEntitlementIOS(sku),\n );\n return (purchase ?? null) as PurchaseIOS | null;\n};\n\n/**\n * Get latest transaction for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to latest transaction\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/latest-transaction-ios}\n */\nexport const latestTransactionIOS: QueryField<'latestTransactionIOS'> = async (\n sku,\n) => {\n requireIosPlatform('latestTransactionIOS');\n if (!sku) {\n throw new Error('latestTransactionIOS requires a SKU');\n }\n const transaction = await callNativeIOS(() =>\n ExpoIapModule.latestTransactionIOS(sku),\n );\n return (transaction ?? null) as PurchaseIOS | null;\n};\n\n/**\n * Begin refund request for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to refund request status\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/begin-refund-request-ios}\n */\nexport const beginRefundRequestIOS: MutationField<\n 'beginRefundRequestIOS'\n> = async (sku) => {\n requireIosPlatform('beginRefundRequestIOS');\n if (!sku) {\n throw new Error('beginRefundRequestIOS requires a SKU');\n }\n const status = await callNativeIOS(() =>\n ExpoIapModule.beginRefundRequestIOS(sku),\n );\n return status ?? null;\n};\n\n/**\n * Shows the system UI for managing subscriptions.\n * Returns an array of subscriptions that had status changes after the UI is closed.\n *\n * @returns Promise<Purchase[]> - Array of subscriptions with status changes (e.g., auto-renewal toggled)\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/show-manage-subscriptions-ios}\n */\nexport const showManageSubscriptionsIOS: MutationField<\n 'showManageSubscriptionsIOS'\n> = async () => {\n requireIosPlatform('showManageSubscriptionsIOS');\n const purchases = await callNativeIOS(() =>\n ExpoIapModule.showManageSubscriptionsIOS(),\n );\n return decodeApplePurchases(purchases);\n};\n\n/**\n * Get the device's base64 receipt data to send to your server. Verify it there\n * with Apple's verifyReceipt endpoint, never directly from the app.\n *\n * @returns {Promise<string>} Base64 encoded receipt data\n *\n * @see {@link https://openiap.dev/docs/apis/ios/get-receipt-data-ios}\n */\nexport const getReceiptDataIOS: QueryField<'getReceiptDataIOS'> = async () => {\n requireIosPlatform('getReceiptDataIOS');\n return callNativeIOS(() => ExpoIapModule.getReceiptDataIOS());\n};\n\n/**\n * Refresh the receipt from Apple (AppStore.sync()) and return it. Use after a\n * first purchase, when getReceiptDataIOS() can return an empty string because\n * the receipt file is not written to disk yet.\n *\n * @returns {Promise<string>} Base64 encoded receipt data\n *\n * @platform iOS\n */\nexport const requestReceiptRefreshIOS = async (): Promise<string> => {\n requireIosPlatform('requestReceiptRefreshIOS');\n return callNativeIOS(() => ExpoIapModule.requestReceiptRefreshIOS());\n};\n\n/**\n * Check if a transaction is verified through StoreKit 2.\n * StoreKit 2 performs local verification of transaction JWS signatures.\n *\n * @param sku The product's SKU (on iOS)\n * @returns Promise resolving to true if the transaction is verified\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/is-transaction-verified-ios}\n */\nexport const isTransactionVerifiedIOS: QueryField<\n 'isTransactionVerifiedIOS'\n> = async (sku) => {\n requireIosPlatform('isTransactionVerifiedIOS');\n if (!sku) {\n throw new Error('isTransactionVerifiedIOS requires a SKU');\n }\n return callNativeIOS(() => ExpoIapModule.isTransactionVerifiedIOS(sku));\n};\n\n/**\n * Get the JWS representation of a purchase for server-side verification.\n * The JWS (JSON Web Signature) can be verified on your server using Apple's public keys.\n *\n * @param sku The product's SKU (on iOS)\n * @returns Promise resolving to JWS representation of the transaction\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/get-transaction-jws-ios}\n */\nexport const getTransactionJwsIOS: QueryField<'getTransactionJwsIOS'> = async (\n sku,\n) => {\n requireIosPlatform('getTransactionJwsIOS');\n if (!sku) {\n throw new Error('getTransactionJwsIOS requires a SKU');\n }\n const jws = await callNativeIOS(() =>\n ExpoIapModule.getTransactionJwsIOS(sku),\n );\n return jws ?? '';\n};\n\n/**\n * Get the AppTransaction: the initial purchase that unlocked the app.\n * Requires iOS 16.0+ at runtime and Xcode 15.0+ (iOS 16.0 SDK) to compile.\n *\n * @returns Promise resolving to the app transaction information or null if not available\n * @throws Error if called on non-iOS platform, iOS version < 16.0, or compiled with older SDK\n *\n * @platform iOS\n * @since iOS 16.0\n *\n * @see {@link https://openiap.dev/docs/apis/ios/get-app-transaction-ios}\n */\nexport const getAppTransactionIOS: QueryField<\n 'getAppTransactionIOS'\n> = async () => {\n requireIosPlatform('getAppTransactionIOS');\n return (\n (await callNativeIOS(() => ExpoIapModule.getAppTransactionIOS())) ?? null\n );\n};\n\n/**\n * Get information about a promoted product if one is available (iOS only).\n * Promoted products are products that the App Store promotes on your behalf.\n * This is called after a promoted product event is received from the App Store.\n *\n * @returns Promise resolving to the promoted product information or null if none available\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/get-promoted-product-ios}\n */\nexport const getPromotedProductIOS: QueryField<\n 'getPromotedProductIOS'\n> = async () => {\n requireIosPlatform('getPromotedProductIOS');\n const product = await callNativeIOS(() =>\n ExpoIapModule.getPromotedProductIOS(),\n );\n return (product ?? null) as ProductIOS | null;\n};\n\n/**\n * Get pending transactions that haven't been finished yet (iOS only).\n *\n * @returns Promise resolving to array of pending transactions\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/get-pending-transactions-ios}\n */\nexport const getPendingTransactionsIOS: QueryField<\n 'getPendingTransactionsIOS'\n> = async () => {\n requireIosPlatform('getPendingTransactionsIOS');\n const transactions = await callNativeIOS(() =>\n ExpoIapModule.getPendingTransactionsIOS(),\n );\n return decodeApplePurchases(transactions);\n};\n\n/**\n * List every StoreKit transaction (finished + unfinished) for the current user.\n *\n * @see {@link https://openiap.dev/docs/apis/ios/get-all-transactions-ios}\n */\nexport const getAllTransactionsIOS: QueryField<\n 'getAllTransactionsIOS'\n> = async () => {\n requireIosPlatform('getAllTransactionsIOS');\n const transactions = await callNativeIOS(() =>\n ExpoIapModule.getAllTransactionsIOS(),\n );\n return decodeApplePurchases(transactions);\n};\n\n/**\n * Clear a specific transaction (iOS only).\n *\n * @returns Promise resolving when transaction is cleared\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/clear-transaction-ios}\n */\nexport const clearTransactionIOS: MutationField<\n 'clearTransactionIOS'\n> = async () => {\n requireIosPlatform('clearTransactionIOS');\n return !!(await callNativeIOS(() => ExpoIapModule.clearTransactionIOS()));\n};\n\n/**\n * Open the App Store subscription management sheet (iOS only).\n * @returns {Promise<void>}\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const deepLinkToSubscriptionsIOS = async (): Promise<void> => {\n requireIosPlatform('deepLinkToSubscriptionsIOS');\n // The Onside module has no subscription sheet; keep the App Store web page.\n if (ExpoIapModule.USING_ONSIDE_SDK) {\n await Linking.openURL('https://apps.apple.com/account/subscriptions');\n return;\n }\n await callNativeIOS(() => ExpoIapModule.deepLinkToSubscriptionsIOS());\n};\n\n/**\n * Check if the device can present an external purchase notice sheet (iOS 17.4+).\n * Wraps `ExternalPurchase.canPresent`.\n *\n * @returns Promise resolving to true if the notice sheet can be presented\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/can-present-external-purchase-notice-ios}\n */\nexport const canPresentExternalPurchaseNoticeIOS: QueryField<\n 'canPresentExternalPurchaseNoticeIOS'\n> = async () => {\n requireIosPlatform('canPresentExternalPurchaseNoticeIOS');\n return !!(await callNativeIOS(() =>\n ExpoIapModule.canPresentExternalPurchaseNoticeIOS(),\n ));\n};\n\n/**\n * Present an external purchase notice sheet to inform users about external purchases (iOS 17.4+).\n * This must be called before opening an external purchase link.\n * Returns the external purchase token when user continues.\n *\n * @returns Promise resolving to the result with action, token, and error if any\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/present-external-purchase-notice-sheet-ios}\n */\nexport const presentExternalPurchaseNoticeSheetIOS: MutationField<\n 'presentExternalPurchaseNoticeSheetIOS'\n> = async () => {\n requireIosPlatform('presentExternalPurchaseNoticeSheetIOS');\n const result = await callNativeIOS(() =>\n ExpoIapModule.presentExternalPurchaseNoticeSheetIOS(),\n );\n return result as ExternalPurchaseNoticeResultIOS;\n};\n\n/**\n * Present an external purchase link to redirect users to your website (iOS 16.0+).\n *\n * @param url - The external purchase URL to open\n * @returns Promise resolving to the result with success status and error if any\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/present-external-purchase-link-ios}\n */\nexport const presentExternalPurchaseLinkIOS: MutationField<\n 'presentExternalPurchaseLinkIOS'\n> = async (url: string) => {\n requireIosPlatform('presentExternalPurchaseLinkIOS');\n const result = await callNativeIOS(() =>\n ExpoIapModule.presentExternalPurchaseLinkIOS(url),\n );\n return result as ExternalPurchaseLinkResultIOS;\n};\n\n/**\n * Check if app is eligible for ExternalPurchaseCustomLink API (iOS 18.1+).\n *\n * @returns Promise resolving to true if eligible\n * @platform iOS\n * @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/iseligible\n *\n * @see {@link https://openiap.dev/docs/apis/ios/is-eligible-for-external-purchase-custom-link-ios}\n */\nexport const isEligibleForExternalPurchaseCustomLinkIOS: QueryField<\n 'isEligibleForExternalPurchaseCustomLinkIOS'\n> = async () => {\n requireIosPlatform('isEligibleForExternalPurchaseCustomLinkIOS');\n return !!(await callNativeIOS(() =>\n ExpoIapModule.isEligibleForExternalPurchaseCustomLinkIOS(),\n ));\n};\n\n/**\n * Get external purchase token for reporting to Apple (iOS 18.1+).\n * Use this token with Apple's External Purchase Server API to report transactions.\n *\n * @param tokenType - Token type: 'acquisition' (new customers) or 'services' (existing customers)\n * @returns Promise resolving to the token result with token string or error\n * @platform iOS\n * @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/token(for:)\n *\n * @see {@link https://openiap.dev/docs/apis/ios/get-external-purchase-custom-link-token-ios}\n */\nexport const getExternalPurchaseCustomLinkTokenIOS: QueryField<\n 'getExternalPurchaseCustomLinkTokenIOS'\n> = async (tokenType) => {\n requireIosPlatform('getExternalPurchaseCustomLinkTokenIOS');\n if (!tokenType) {\n throw new Error(\n \"getExternalPurchaseCustomLinkTokenIOS requires a tokenType ('acquisition' or 'services')\",\n );\n }\n const result = await callNativeIOS(() =>\n ExpoIapModule.getExternalPurchaseCustomLinkTokenIOS(tokenType),\n );\n return result as ExternalPurchaseCustomLinkTokenResultIOS;\n};\n\n/**\n * Show ExternalPurchaseCustomLink notice sheet (iOS 18.1+).\n * Call this after a deliberate customer interaction before linking out to external purchases.\n *\n * @param noticeType - Notice type: 'browser' (external purchases displayed in browser)\n * @returns Promise resolving to the result with continued status and error if any\n * @platform iOS\n * @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/shownotice(type:)\n *\n * @see {@link https://openiap.dev/docs/apis/ios/show-external-purchase-custom-link-notice-ios}\n */\nexport const showExternalPurchaseCustomLinkNoticeIOS: MutationField<\n 'showExternalPurchaseCustomLinkNoticeIOS'\n> = async (noticeType) => {\n requireIosPlatform('showExternalPurchaseCustomLinkNoticeIOS');\n if (!noticeType) {\n throw new Error(\n \"showExternalPurchaseCustomLinkNoticeIOS requires a noticeType ('browser')\",\n );\n }\n const result = await callNativeIOS(() =>\n ExpoIapModule.showExternalPurchaseCustomLinkNoticeIOS(noticeType),\n );\n return result as ExternalPurchaseCustomLinkNoticeResultIOS;\n};\n\n// iOS-specific APIs only; cross-platform wrappers live in src/index.ts\n"]}
|
|
1
|
+
{"version":3,"file":"ios.js","source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B,kBAAkB,CAAC,uCAAuC,CAAC,CAAC;IAC5D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,GAAG,EAAE,CACtC,aAAa,CAAC,qCAAqC,CAAC,SAAS,CAAC,CAC/D,CAAC;IACF,OAAO,MAAkD,CAAC;AAC5D,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAEhD,KAAK,EAAE,UAAU,EAAE,EAAE;IACvB,kBAAkB,CAAC,yCAAyC,CAAC,CAAC;IAC9D,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,GAAG,EAAE,CACtC,aAAa,CAAC,uCAAuC,CAAC,UAAU,CAAC,CAClE,CAAC;IACF,OAAO,MAAmD,CAAC;AAC7D,CAAC,CAAC;AAEF,uEAAuE","sourcesContent":["// Internal modules\nimport ExpoIapModule from '../ExpoIapModule';\n\n// Types\nimport type {\n ExternalPurchaseCustomLinkNoticeResultIOS,\n ExternalPurchaseCustomLinkTokenResultIOS,\n ExternalPurchaseLinkResultIOS,\n ExternalPurchaseNoticeResultIOS,\n MutationField,\n ProductIOS,\n Purchase,\n PurchaseIOS,\n QueryField,\n SubscriptionStatusIOS,\n} from '../types';\nimport {type PurchaseError} from '../utils/errorMapping';\nimport {invokeNativeWithPurchaseError} from '../utils/nativeError';\nimport {decodeApplePurchases} from '../utils/availablePurchases';\nimport {Linking, Platform} from 'react-native';\n\n/**\n * Throws the documented iOS-only error. Without it, other platforms reach the\n * native proxy and fail with an opaque `ExpoIapModule.<name> is not a function`.\n */\nconst requireIosPlatform = (methodName: string): void => {\n if (Platform.OS !== 'ios') {\n throw new Error(`${methodName} is only available on iOS`);\n }\n};\n\n// iOS rejections carry the OpenIAP error envelope; rethrow them as PurchaseError.\nconst callNativeIOS = <T>(operation: () => Promise<T>): Promise<T> =>\n invokeNativeWithPurchaseError(operation, 'ios');\n\nexport type TransactionEvent = {\n transaction?: Purchase;\n error?: PurchaseError;\n};\n\n// Type guards\nexport function isProductIOS<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'ios'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n typeof item.platform === 'string' &&\n item.platform.toLowerCase() === 'ios'\n );\n}\n\n// Functions\n/**\n * Sync state with Appstore (iOS only)\n * https://developer.apple.com/documentation/storekit/appstore/3791906-sync\n *\n * @returns Promise resolving to true on success\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/sync-ios}\n */\nexport const syncIOS: MutationField<'syncIOS'> = async () => {\n requireIosPlatform('syncIOS');\n return !!(await callNativeIOS(() => ExpoIapModule.syncIOS()));\n};\n\n/**\n * Check if user is eligible for introductory offer\n *\n * @param groupId - The subscription group ID\n * @returns Promise resolving to true if eligible\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/is-eligible-for-intro-offer-ios}\n */\nexport const isEligibleForIntroOfferIOS: QueryField<\n 'isEligibleForIntroOfferIOS'\n> = async (groupId) => {\n requireIosPlatform('isEligibleForIntroOfferIOS');\n if (!groupId) {\n throw new Error('isEligibleForIntroOfferIOS requires a groupId');\n }\n return callNativeIOS(() => ExpoIapModule.isEligibleForIntroOfferIOS(groupId));\n};\n\n/**\n * Get subscription status for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to array of subscription status\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/subscription-status-ios}\n */\nexport const subscriptionStatusIOS: QueryField<\n 'subscriptionStatusIOS'\n> = async (sku) => {\n requireIosPlatform('subscriptionStatusIOS');\n if (!sku) {\n throw new Error('subscriptionStatusIOS requires a SKU');\n }\n const status = await callNativeIOS(() =>\n ExpoIapModule.subscriptionStatusIOS(sku),\n );\n return (status ?? []) as SubscriptionStatusIOS[];\n};\n\n/**\n * Get current entitlement for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to current entitlement\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/current-entitlement-ios}\n */\nexport const currentEntitlementIOS: QueryField<\n 'currentEntitlementIOS'\n> = async (sku) => {\n requireIosPlatform('currentEntitlementIOS');\n if (!sku) {\n throw new Error('currentEntitlementIOS requires a SKU');\n }\n const purchase = await callNativeIOS(() =>\n ExpoIapModule.currentEntitlementIOS(sku),\n );\n return (purchase ?? null) as PurchaseIOS | null;\n};\n\n/**\n * Get latest transaction for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to latest transaction\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/latest-transaction-ios}\n */\nexport const latestTransactionIOS: QueryField<'latestTransactionIOS'> = async (\n sku,\n) => {\n requireIosPlatform('latestTransactionIOS');\n if (!sku) {\n throw new Error('latestTransactionIOS requires a SKU');\n }\n const transaction = await callNativeIOS(() =>\n ExpoIapModule.latestTransactionIOS(sku),\n );\n return (transaction ?? null) as PurchaseIOS | null;\n};\n\n/**\n * Begin refund request for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to refund request status\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/begin-refund-request-ios}\n */\nexport const beginRefundRequestIOS: MutationField<\n 'beginRefundRequestIOS'\n> = async (sku) => {\n requireIosPlatform('beginRefundRequestIOS');\n if (!sku) {\n throw new Error('beginRefundRequestIOS requires a SKU');\n }\n const status = await callNativeIOS(() =>\n ExpoIapModule.beginRefundRequestIOS(sku),\n );\n return status ?? null;\n};\n\n/**\n * Shows the system UI for managing subscriptions.\n * Returns an array of subscriptions that had status changes after the UI is closed.\n *\n * @returns Promise<Purchase[]> - Array of subscriptions with status changes (e.g., auto-renewal toggled)\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/show-manage-subscriptions-ios}\n */\nexport const showManageSubscriptionsIOS: MutationField<\n 'showManageSubscriptionsIOS'\n> = async () => {\n requireIosPlatform('showManageSubscriptionsIOS');\n const purchases = await callNativeIOS(() =>\n ExpoIapModule.showManageSubscriptionsIOS(),\n );\n return decodeApplePurchases(purchases);\n};\n\n/**\n * Get the device's base64 receipt data to send to your server. Verify it there\n * with Apple's verifyReceipt endpoint, never directly from the app.\n *\n * @returns {Promise<string>} Base64 encoded receipt data\n *\n * @see {@link https://openiap.dev/docs/apis/ios/get-receipt-data-ios}\n */\nexport const getReceiptDataIOS: QueryField<'getReceiptDataIOS'> = async () => {\n requireIosPlatform('getReceiptDataIOS');\n return callNativeIOS(() => ExpoIapModule.getReceiptDataIOS());\n};\n\n/**\n * Refresh the receipt from Apple (AppStore.sync()) and return it. Use after a\n * first purchase, when getReceiptDataIOS() can return an empty string because\n * the receipt file is not written to disk yet.\n *\n * @returns {Promise<string>} Base64 encoded receipt data\n *\n * @platform iOS\n */\nexport const requestReceiptRefreshIOS = async (): Promise<string> => {\n requireIosPlatform('requestReceiptRefreshIOS');\n return callNativeIOS(() => ExpoIapModule.requestReceiptRefreshIOS());\n};\n\n/**\n * Check if a transaction is verified through StoreKit 2.\n * StoreKit 2 performs local verification of transaction JWS signatures.\n *\n * @param sku The product's SKU (on iOS)\n * @returns Promise resolving to true if the transaction is verified\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/is-transaction-verified-ios}\n */\nexport const isTransactionVerifiedIOS: QueryField<\n 'isTransactionVerifiedIOS'\n> = async (sku) => {\n requireIosPlatform('isTransactionVerifiedIOS');\n if (!sku) {\n throw new Error('isTransactionVerifiedIOS requires a SKU');\n }\n return callNativeIOS(() => ExpoIapModule.isTransactionVerifiedIOS(sku));\n};\n\n/**\n * Get the JWS representation of a purchase for server-side verification.\n * The JWS (JSON Web Signature) can be verified on your server using Apple's public keys.\n *\n * @param sku The product's SKU (on iOS)\n * @returns Promise resolving to JWS representation of the transaction\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/get-transaction-jws-ios}\n */\nexport const getTransactionJwsIOS: QueryField<'getTransactionJwsIOS'> = async (\n sku,\n) => {\n requireIosPlatform('getTransactionJwsIOS');\n if (!sku) {\n throw new Error('getTransactionJwsIOS requires a SKU');\n }\n const jws = await callNativeIOS(() =>\n ExpoIapModule.getTransactionJwsIOS(sku),\n );\n return jws ?? '';\n};\n\n/**\n * Get the AppTransaction: the initial purchase that unlocked the app.\n * Requires iOS 16.0+ at runtime and Xcode 15.0+ (iOS 16.0 SDK) to compile.\n *\n * @returns Promise resolving to the app transaction information or null if not available\n * @throws Error if called on non-iOS platform, iOS version < 16.0, or compiled with older SDK\n *\n * @platform iOS\n * @since iOS 16.0\n *\n * @see {@link https://openiap.dev/docs/apis/ios/get-app-transaction-ios}\n */\nexport const getAppTransactionIOS: QueryField<\n 'getAppTransactionIOS'\n> = async () => {\n requireIosPlatform('getAppTransactionIOS');\n return (\n (await callNativeIOS(() => ExpoIapModule.getAppTransactionIOS())) ?? null\n );\n};\n\n/**\n * Get information about a promoted product if one is available (iOS only).\n * Promoted products are products that the App Store promotes on your behalf.\n * This is called after a promoted product event is received from the App Store.\n *\n * @returns Promise resolving to the promoted product information or null if none available\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/get-promoted-product-ios}\n */\nexport const getPromotedProductIOS: QueryField<\n 'getPromotedProductIOS'\n> = async () => {\n requireIosPlatform('getPromotedProductIOS');\n const product = await callNativeIOS(() =>\n ExpoIapModule.getPromotedProductIOS(),\n );\n return (product ?? null) as ProductIOS | null;\n};\n\n/**\n * Get pending transactions that haven't been finished yet (iOS only).\n *\n * @returns Promise resolving to array of pending transactions\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/get-pending-transactions-ios}\n */\nexport const getPendingTransactionsIOS: QueryField<\n 'getPendingTransactionsIOS'\n> = async () => {\n requireIosPlatform('getPendingTransactionsIOS');\n const transactions = await callNativeIOS(() =>\n ExpoIapModule.getPendingTransactionsIOS(),\n );\n return decodeApplePurchases(transactions);\n};\n\n/**\n * List every StoreKit transaction (finished + unfinished) for the current user.\n *\n * @see {@link https://openiap.dev/docs/apis/ios/get-all-transactions-ios}\n */\nexport const getAllTransactionsIOS: QueryField<\n 'getAllTransactionsIOS'\n> = async () => {\n requireIosPlatform('getAllTransactionsIOS');\n const transactions = await callNativeIOS(() =>\n ExpoIapModule.getAllTransactionsIOS(),\n );\n return decodeApplePurchases(transactions);\n};\n\n/**\n * Clear a specific transaction (iOS only).\n *\n * @returns Promise resolving when transaction is cleared\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/clear-transaction-ios}\n */\nexport const clearTransactionIOS: MutationField<\n 'clearTransactionIOS'\n> = async () => {\n requireIosPlatform('clearTransactionIOS');\n return !!(await callNativeIOS(() => ExpoIapModule.clearTransactionIOS()));\n};\n\n/**\n * Open the App Store subscription management sheet (iOS only).\n * @returns {Promise<void>}\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const deepLinkToSubscriptionsIOS = async (): Promise<void> => {\n requireIosPlatform('deepLinkToSubscriptionsIOS');\n // The Onside module has no subscription sheet; keep the App Store web page.\n if (ExpoIapModule.USING_ONSIDE_SDK) {\n await Linking.openURL('https://apps.apple.com/account/subscriptions');\n return;\n }\n await callNativeIOS(() => ExpoIapModule.deepLinkToSubscriptionsIOS());\n};\n\n/**\n * Check if the device can present an external purchase notice sheet (iOS 17.4+).\n * Wraps `ExternalPurchase.canPresent`.\n *\n * @returns Promise resolving to true if the notice sheet can be presented\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/can-present-external-purchase-notice-ios}\n */\nexport const canPresentExternalPurchaseNoticeIOS: QueryField<\n 'canPresentExternalPurchaseNoticeIOS'\n> = async () => {\n requireIosPlatform('canPresentExternalPurchaseNoticeIOS');\n return !!(await callNativeIOS(() =>\n ExpoIapModule.canPresentExternalPurchaseNoticeIOS(),\n ));\n};\n\n/**\n * Present an external purchase notice sheet to inform users about external purchases (iOS 17.4+).\n * This must be called before opening an external purchase link.\n * Returns the external purchase token when user continues.\n *\n * @returns Promise resolving to the result with action, token, and error if any\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/present-external-purchase-notice-sheet-ios}\n */\nexport const presentExternalPurchaseNoticeSheetIOS: MutationField<\n 'presentExternalPurchaseNoticeSheetIOS'\n> = async () => {\n requireIosPlatform('presentExternalPurchaseNoticeSheetIOS');\n const result = await callNativeIOS(() =>\n ExpoIapModule.presentExternalPurchaseNoticeSheetIOS(),\n );\n return result as ExternalPurchaseNoticeResultIOS;\n};\n\n/**\n * Present an external purchase link to redirect users to your website (iOS 16.0+).\n *\n * @param url - The external purchase URL to open\n * @returns Promise resolving to the result with success status and error if any\n * @platform iOS\n *\n * @see {@link https://openiap.dev/docs/apis/ios/present-external-purchase-link-ios}\n */\nexport const presentExternalPurchaseLinkIOS: MutationField<\n 'presentExternalPurchaseLinkIOS'\n> = async (url: string) => {\n requireIosPlatform('presentExternalPurchaseLinkIOS');\n const result = await callNativeIOS(() =>\n ExpoIapModule.presentExternalPurchaseLinkIOS(url),\n );\n return result as ExternalPurchaseLinkResultIOS;\n};\n\n/**\n * Check if app is eligible for ExternalPurchaseCustomLink API (iOS 18.1+).\n *\n * @returns Promise resolving to true if eligible\n * @platform iOS\n * @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/iseligible\n *\n * @see {@link https://openiap.dev/docs/apis/ios/is-eligible-for-external-purchase-custom-link-ios}\n */\nexport const isEligibleForExternalPurchaseCustomLinkIOS: QueryField<\n 'isEligibleForExternalPurchaseCustomLinkIOS'\n> = async () => {\n requireIosPlatform('isEligibleForExternalPurchaseCustomLinkIOS');\n return !!(await callNativeIOS(() =>\n ExpoIapModule.isEligibleForExternalPurchaseCustomLinkIOS(),\n ));\n};\n\n/**\n * Get external purchase token for reporting to Apple (iOS 18.1+).\n * Use this token with Apple's External Purchase Server API to report transactions.\n *\n * @param tokenType - Reporting token type for the app's storefront.\n * @returns Promise resolving to the token result with token string or error\n * @platform iOS\n * @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/token(for:)\n *\n * @see {@link https://openiap.dev/docs/apis/ios/get-external-purchase-custom-link-token-ios}\n */\nexport const getExternalPurchaseCustomLinkTokenIOS: QueryField<\n 'getExternalPurchaseCustomLinkTokenIOS'\n> = async (tokenType) => {\n requireIosPlatform('getExternalPurchaseCustomLinkTokenIOS');\n if (!tokenType) {\n throw new Error(\n 'getExternalPurchaseCustomLinkTokenIOS requires a tokenType',\n );\n }\n const result = await callNativeIOS(() =>\n ExpoIapModule.getExternalPurchaseCustomLinkTokenIOS(tokenType),\n );\n return result as ExternalPurchaseCustomLinkTokenResultIOS;\n};\n\n/**\n * Show ExternalPurchaseCustomLink notice sheet (iOS 18.1+).\n * Call this after a deliberate customer interaction before linking out to external purchases.\n *\n * @param noticeType - Notice type: 'browser' (external purchases displayed in browser)\n * @returns Promise resolving to the result with continued status and error if any\n * @platform iOS\n * @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/shownotice(type:)\n *\n * @see {@link https://openiap.dev/docs/apis/ios/show-external-purchase-custom-link-notice-ios}\n */\nexport const showExternalPurchaseCustomLinkNoticeIOS: MutationField<\n 'showExternalPurchaseCustomLinkNoticeIOS'\n> = async (noticeType) => {\n requireIosPlatform('showExternalPurchaseCustomLinkNoticeIOS');\n if (!noticeType) {\n throw new Error(\n \"showExternalPurchaseCustomLinkNoticeIOS requires a noticeType ('browser')\",\n );\n }\n const result = await callNativeIOS(() =>\n ExpoIapModule.showExternalPurchaseCustomLinkNoticeIOS(noticeType),\n );\n return result as ExternalPurchaseCustomLinkNoticeResultIOS;\n};\n\n// iOS-specific APIs only; cross-platform wrappers live in src/index.ts\n"]}
|
|
@@ -74,14 +74,22 @@ export declare function createIapkitConfirmation<P extends PurchaseFlowPurchase>
|
|
|
74
74
|
* @internal Use the SDK's confirmOnDeviceIOS.
|
|
75
75
|
* The SDK's `confirmOnDeviceIOS`, given its `getPendingTransactionsIOS`, for an
|
|
76
76
|
* app with neither a backend nor IAPKit. StoreKit verified the transaction if
|
|
77
|
-
* it
|
|
78
|
-
* purchase's environment
|
|
77
|
+
* it lists it as unfinished, or, for a purchase the flow already finished, in
|
|
78
|
+
* `getTransactionHistoryIOS`, from the purchase's environment. A revoked or
|
|
79
|
+
* upgraded one is `invalid`, and an expired one `verification_delayed`, since
|
|
80
|
+
* billing grace can still cover it; `grant` runs before an unfinished one is
|
|
81
|
+
* finished, and again for a finished non-consumable a restore reads.
|
|
79
82
|
*/
|
|
80
83
|
export declare function createDeviceConfirmationIOS<P extends PurchaseFlowPurchase>(getPendingTransactionsIOS: () => Promise<P[]>, options?: {
|
|
81
84
|
/** Required for consumables; credit each purchase.id only once. */
|
|
82
85
|
grant?: (purchase: P, context: {
|
|
83
86
|
isConsumable: boolean;
|
|
84
87
|
}) => Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* StoreKit's verified history, such as `getAvailablePurchases` with
|
|
90
|
+
* `onlyIncludeActiveItemsIOS: false`; without it a finished purchase throws.
|
|
91
|
+
*/
|
|
92
|
+
getTransactionHistoryIOS?: () => Promise<P[]>;
|
|
85
93
|
}): PurchaseFlowOptions<P>["confirmWithBackend"];
|
|
86
94
|
/** @internal Builds the IAPKit request; throws for a store IAPKit cannot verify. */
|
|
87
95
|
export declare function toIapkitVerificationProps<P extends PurchaseFlowPurchase>(purchase: P, options: IapkitConfirmationOptions<P>): IapkitVerificationProps;
|
|
@@ -1 +1 @@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E,QAAQ,CAAM,GACzD,oBAAoB,CAsDtB"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const IAPKIT_UNKNOWN_RETRY_MS = 30_000;
|
|
2
|
+
// An expired App Store receipt may still be in billing grace; check it again.
|
|
3
|
+
const DEVICE_EXPIRED_RETRY_MS = 30_000;
|
|
2
4
|
/**
|
|
3
5
|
* @internal Use the SDK's confirmWithIapkit.
|
|
4
6
|
* The SDK's `confirmWithIapkit`, given its `verifyPurchaseWithProvider`:
|
|
@@ -19,8 +21,11 @@ export function createIapkitConfirmation(verifyPurchaseWithProvider, options) {
|
|
|
19
21
|
* @internal Use the SDK's confirmOnDeviceIOS.
|
|
20
22
|
* The SDK's `confirmOnDeviceIOS`, given its `getPendingTransactionsIOS`, for an
|
|
21
23
|
* app with neither a backend nor IAPKit. StoreKit verified the transaction if
|
|
22
|
-
* it
|
|
23
|
-
* purchase's environment
|
|
24
|
+
* it lists it as unfinished, or, for a purchase the flow already finished, in
|
|
25
|
+
* `getTransactionHistoryIOS`, from the purchase's environment. A revoked or
|
|
26
|
+
* upgraded one is `invalid`, and an expired one `verification_delayed`, since
|
|
27
|
+
* billing grace can still cover it; `grant` runs before an unfinished one is
|
|
28
|
+
* finished, and again for a finished non-consumable a restore reads.
|
|
24
29
|
*/
|
|
25
30
|
export function createDeviceConfirmationIOS(getPendingTransactionsIOS, options = {}) {
|
|
26
31
|
return async (purchase, context) => {
|
|
@@ -30,24 +35,36 @@ export function createDeviceConfirmationIOS(getPendingTransactionsIOS, options =
|
|
|
30
35
|
(purchase.storeId ?? "apple") !== "apple") {
|
|
31
36
|
throw new Error(`Device confirmation covers App Store purchases, not ${purchase.storeId ?? purchase.store}`);
|
|
32
37
|
}
|
|
33
|
-
const
|
|
34
|
-
// After the query: a transaction can expire while StoreKit answers.
|
|
35
|
-
const now = Date.now();
|
|
36
|
-
const verified = pending.some((candidate) => candidate.store === "apple" &&
|
|
38
|
+
const isSame = (candidate) => candidate.store === "apple" &&
|
|
37
39
|
purchase.id !== "" &&
|
|
38
40
|
candidate.id === purchase.id &&
|
|
39
41
|
candidate.productId === purchase.productId &&
|
|
40
|
-
candidate.revocationDateIOS == null &&
|
|
41
|
-
candidate.isUpgradedIOS !== true &&
|
|
42
|
-
(candidate.expirationDateIOS == null ||
|
|
43
|
-
candidate.expirationDateIOS > now) &&
|
|
44
42
|
(purchase.environmentIOS == null ||
|
|
45
|
-
candidate.environmentIOS === purchase.environmentIOS)
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
candidate.environmentIOS === purchase.environmentIOS);
|
|
44
|
+
const pending = (await getPendingTransactionsIOS()).find(isSame);
|
|
45
|
+
const transaction = pending ?? (await options.getTransactionHistoryIOS?.())?.find(isSame);
|
|
46
|
+
if (!transaction) {
|
|
47
|
+
throw new Error(`StoreKit lists no transaction for ${purchase.productId}`);
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
if (transaction.revocationDateIOS != null) {
|
|
50
|
+
return { status: "invalid", reason: "revoked" };
|
|
51
|
+
}
|
|
52
|
+
if (transaction.isUpgradedIOS === true) {
|
|
53
|
+
return { status: "invalid", reason: "upgraded" };
|
|
54
|
+
}
|
|
55
|
+
// After the reads: a transaction can expire while StoreKit answers.
|
|
56
|
+
if (transaction.expirationDateIOS != null &&
|
|
57
|
+
transaction.expirationDateIOS <= Date.now()) {
|
|
58
|
+
return {
|
|
59
|
+
status: "verification_delayed",
|
|
60
|
+
retryAfterMs: DEVICE_EXPIRED_RETRY_MS,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// A finished consumable was credited before it was consumed.
|
|
64
|
+
if (pending || !context.isConsumable) {
|
|
65
|
+
await options.grant?.(purchase, context);
|
|
66
|
+
}
|
|
67
|
+
return { status: "entitled", alreadyGranted: !pending };
|
|
51
68
|
};
|
|
52
69
|
}
|
|
53
70
|
// Checked before verifying: a consumable must never pass without a way to credit it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file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I,KAAK,CACb,2DAA2D,CAC5D,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,mBAAmB,CAC1B,WAAsC,EACtC,KAAa,EACb,QAA8B,EAC9B,OAAkD;IAElD,MAAM,QAAQ,GACZ,KAAK,KAAK,QAAQ;QAChB,CAAC,CAAC,yBAAyB,CAAC,OAAO,CAAC,MAAM,CAAC;QAC3C,CAAC,CAAC,KAAK,KAAK,OAAO;YACjB,CAAC,CAAC,QAAQ,CAAC,cAAc;YACzB,CAAC,CAAC,IAAI,CAAC;IACb,OAAO,QAAQ,IAAI,WAAW,KAAK,QAAQ;QACzC,CAAC,CAAC,eAAe,WAAW,IAAI,QAAQ,cAAc,QAAQ,EAAE;QAChE,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,+EAA+E;AAC/E,0EAA0E;AAC1E,SAAS,YAAY,CACnB,KAAa,EACb,KAAa,EACb,YAAqB;IAErB,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,OAAO,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,KAAK,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;QACpE,KAAK,QAAQ;YACX,OAAO,CACL,KAAK,KAAK,UAAU;gBACpB,KAAK,KAAK,wBAAwB;gBAClC,CAAC,YAAY,IAAI,KAAK,KAAK,kBAAkB,CAAC,CAC/C,CAAC;QACJ,KAAK,SAAS;YACZ,OAAO,KAAK,KAAK,UAAU,CAAC;QAC9B;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC","sourcesContent":["// Internal adapters for SDK confirmation helpers; apps use SDK root imports.\n// Each adapter uses the same lifecycle contract as other verification services.\nimport type {\n PurchaseConfirmation,\n PurchaseFlowOptions,\n PurchaseFlowPurchase,\n} from \"./purchase-flow-core\";\n\ntype IapkitStore = \"apple\" | \"google\" | \"amazon\" | \"horizon\";\n\n/** How an app without its own backend confirms purchases with IAPKit. */\nexport interface IapkitConfirmationOptions<\n P extends PurchaseFlowPurchase = PurchaseFlowPurchase,\n> {\n /**\n * A publishable key (`openiap-kit_pk_...`), which is safe to ship in an\n * app. Leave it out where the SDK has one configured, such as Expo's\n * `iapkitApiKey`.\n */\n apiKey?: string;\n /** A self-hosted or local IAPKit origin. Defaults to https://kit.openiap.dev. */\n baseUrl?: string;\n amazon?: {\n /** Verify App Tester receipts with the Amazon RVS Cloud Sandbox. */\n sandbox?: boolean;\n /** Expected verdict environment; defaults to Sandbox with sandbox, otherwise Production. */\n expectedEnvironment?: \"Sandbox\" | \"Production\";\n /** RVS reports a subscription term under its parent SKU; maps one to the other. */\n verifiedProductId?: (productId: string) => string;\n };\n /** The IAPKit store that verifies a community store's evidence, such as an Amazon RVS adapter. */\n verifyAs?: (purchase: P) => IapkitStore | undefined;\n /** Credits consumables before finishing; must be idempotent per purchase.id. */\n grant?: (purchase: P, context: { isConsumable: boolean }) => Promise<void>;\n}\n\n/** @internal Use the SDK's VerifyPurchaseWithProviderProps. */\nexport interface IapkitVerificationProps {\n provider: \"iapkit\";\n iapkit: {\n apiKey?: string;\n baseUrl?: string;\n apple?: { jws: string };\n google?: { purchaseToken: string };\n amazon?: {\n receiptId: string;\n expectedProductId: string;\n sandbox: boolean;\n userId?: string;\n };\n horizon?: { sku: string };\n };\n}\n\n/** @internal Use the SDK's VerifyPurchaseWithProviderResult. */\nexport interface IapkitVerificationResult {\n iapkit?: {\n store: string;\n storeId: string;\n environment?: string | null;\n isValid: boolean;\n state: string;\n productId?: string | null;\n } | null;\n errors?: { code?: string | null; message: string }[] | null;\n}\n\nconst IAPKIT_UNKNOWN_RETRY_MS = 30_000;\n\n/**\n * @internal Use the SDK's confirmWithIapkit.\n * The SDK's `confirmWithIapkit`, given its `verifyPurchaseWithProvider`:\n * verifies the purchase with IAPKit, then runs `grant` before the flow\n * finishes it.\n */\nexport function createIapkitConfirmation<P extends PurchaseFlowPurchase>(\n verifyPurchaseWithProvider: (\n props: IapkitVerificationProps,\n ) => Promise<IapkitVerificationResult>,\n options: IapkitConfirmationOptions<P>,\n): PurchaseFlowOptions<P>[\"confirmWithBackend\"] {\n return async (purchase, context) => {\n requireGrant(\"confirmWithIapkit\", purchase, context, options);\n const confirmation = readIapkitVerification(\n await verifyPurchaseWithProvider(\n toIapkitVerificationProps(purchase, options),\n ),\n purchase,\n context,\n options,\n );\n if (confirmation.status === \"entitled\" && !confirmation.alreadyGranted) {\n await options.grant?.(purchase, context);\n }\n return confirmation;\n };\n}\n\n/**\n * @internal Use the SDK's confirmOnDeviceIOS.\n * The SDK's `confirmOnDeviceIOS`, given its `getPendingTransactionsIOS`, for an\n * app with neither a backend nor IAPKit. StoreKit verified the transaction if\n * it is still unfinished, unrevoked, not upgraded, unexpired, and from the\n * purchase's environment; `grant` then runs before the flow finishes it.\n */\nexport function createDeviceConfirmationIOS<P extends PurchaseFlowPurchase>(\n getPendingTransactionsIOS: () => Promise<P[]>,\n options: {\n /** Required for consumables; credit each purchase.id only once. */\n grant?: (purchase: P, context: { isConsumable: boolean }) => Promise<void>;\n } = {},\n): PurchaseFlowOptions<P>[\"confirmWithBackend\"] {\n return async (purchase, context) => {\n requireGrant(\"confirmOnDeviceIOS\", purchase, context, options);\n // A community provider may report store \"apple\" under its own storeId.\n if (\n purchase.store !== \"apple\" ||\n (purchase.storeId ?? \"apple\") !== \"apple\"\n ) {\n throw new Error(\n `Device confirmation covers App Store purchases, not ${purchase.storeId ?? purchase.store}`,\n );\n }\n const pending = await getPendingTransactionsIOS();\n // After the query: a transaction can expire while StoreKit answers.\n const now = Date.now();\n const verified = pending.some(\n (candidate) =>\n candidate.store === \"apple\" &&\n purchase.id !== \"\" &&\n candidate.id === purchase.id &&\n candidate.productId === purchase.productId &&\n candidate.revocationDateIOS == null &&\n candidate.isUpgradedIOS !== true &&\n (candidate.expirationDateIOS == null ||\n candidate.expirationDateIOS > now) &&\n (purchase.environmentIOS == null ||\n candidate.environmentIOS === purchase.environmentIOS),\n );\n if (!verified) {\n throw new Error(\n `StoreKit lists no valid unfinished transaction for ${purchase.productId}`,\n );\n }\n await options.grant?.(purchase, context);\n return { status: \"entitled\", alreadyGranted: false };\n };\n}\n\n// Checked before verifying: a consumable must never pass without a way to credit it.\nfunction requireGrant<P extends PurchaseFlowPurchase>(\n name: string,\n purchase: P,\n context: { isConsumable: boolean },\n options: Pick<IapkitConfirmationOptions<P>, \"grant\">,\n): void {\n if (context.isConsumable && !options.grant) {\n throw new Error(\n `${name} needs grant to credit consumable ${purchase.productId} before it is consumed`,\n );\n }\n}\n\n/** @internal Builds the IAPKit request; throws for a store IAPKit cannot verify. */\nexport function toIapkitVerificationProps<P extends PurchaseFlowPurchase>(\n purchase: P,\n options: IapkitConfirmationOptions<P>,\n): IapkitVerificationProps {\n const apiKey = options.apiKey?.trim();\n // An unset environment variable, not a deliberate fallback to the SDK's key.\n if (apiKey === \"\") throw new Error(\"IAPKit apiKey is empty\");\n const baseUrl = options.baseUrl?.trim();\n const base = {\n ...(apiKey ? { apiKey } : {}),\n ...(baseUrl ? { baseUrl } : {}),\n };\n const token = (): string => {\n if (!purchase.purchaseToken) {\n throw new Error(\n `Purchase ${purchase.productId} has no purchase token to verify`,\n );\n }\n return purchase.purchaseToken;\n };\n const store = verifyingStore(purchase, options);\n switch (store) {\n case \"apple\":\n return {\n provider: \"iapkit\",\n iapkit: { ...base, apple: { jws: token() } },\n };\n case \"google\":\n return {\n provider: \"iapkit\",\n iapkit: { ...base, google: { purchaseToken: token() } },\n };\n case \"amazon\":\n amazonExpectedEnvironment(options.amazon);\n return {\n provider: \"iapkit\",\n iapkit: {\n ...base,\n amazon: {\n receiptId: token(),\n expectedProductId: amazonProductId(purchase, options),\n sandbox: options.amazon?.sandbox ?? false,\n ...(purchase.userIdAmazon ? { userId: purchase.userIdAmazon } : {}),\n },\n },\n };\n case \"horizon\":\n return {\n provider: \"iapkit\",\n iapkit: { ...base, horizon: { sku: purchase.productId } },\n };\n default:\n throw new Error(`IAPKit cannot verify store ${purchase.store}`);\n }\n}\n\n/**\n * @internal Use the SDK's confirmWithIapkit.\n * Turns IAPKit's answer into the flow's confirmation. Anything that may be a\n * configuration error rather than a rejected payment throws, so the flow\n * reports `failed` and leaves the purchase unfinished: evidence for another\n * store, product, or environment, `inauthentic` (IAPKit's answer to a product\n * or package mismatch, and to every Horizon rejection), and a valid state this\n * product type cannot be granted from.\n */\nexport function readIapkitVerification<P extends PurchaseFlowPurchase>(\n result: IapkitVerificationResult,\n purchase: P,\n context: { isConsumable: boolean },\n options: Omit<IapkitConfirmationOptions<P>, \"apiKey\"> = {},\n): PurchaseConfirmation {\n const verified = result.iapkit;\n if (!verified) {\n const errors = (result.errors ?? []).map((error) =>\n error.code ? `[${error.code}] ${error.message}` : error.message,\n );\n throw new Error(\n errors.join(\"\\n\") || \"IAPKit returned no verification result\",\n );\n }\n switch (verified.state) {\n case \"pending\":\n return { status: \"store_pending\" };\n // The store gave no usable answer: retry instead of rejecting a payment.\n case \"unknown\":\n return {\n status: \"verification_delayed\",\n retryAfterMs: IAPKIT_UNKNOWN_RETRY_MS,\n };\n }\n const store = verifyingStore(purchase, options);\n const expectedProductId =\n store === \"amazon\"\n ? amazonProductId(purchase, options)\n : purchase.productId;\n const mismatch =\n verified.store !== purchase.store\n ? `store ${verified.store}, expected ${purchase.store}`\n : purchase.storeId && verified.storeId !== purchase.storeId\n ? `store id ${verified.storeId}, expected ${purchase.storeId}`\n : verified.productId !== expectedProductId\n ? `product ${verified.productId ?? \"(none)\"}, expected ${expectedProductId}`\n : environmentMismatch(verified.environment, store, purchase, options);\n if (mismatch) throw new Error(`IAPKit verified ${mismatch}`);\n if (!verified.isValid) {\n switch (verified.state) {\n case \"canceled\":\n case \"expired\":\n return { status: \"invalid\", reason: verified.state };\n // Only a granted purchase is consumed; the flow grants before finishing.\n case \"consumed\":\n return { status: \"entitled\", alreadyGranted: true };\n default:\n throw new Error(`IAPKit rejected the purchase: ${verified.state}`);\n }\n }\n if (!grantsAccess(store, verified.state, context.isConsumable)) {\n throw new Error(\n `IAPKit state ${verified.state} cannot grant this ${\n context.isConsumable ? \"consumable\" : \"non-consumable\"\n } ${purchase.store} purchase`,\n );\n }\n return { status: \"entitled\", alreadyGranted: false };\n}\n\nfunction verifyingStore<P extends PurchaseFlowPurchase>(\n purchase: P,\n options: Pick<IapkitConfirmationOptions<P>, \"verifyAs\">,\n): string {\n return options.verifyAs?.(purchase) ?? purchase.store;\n}\n\nfunction amazonProductId(\n purchase: PurchaseFlowPurchase,\n options: Pick<IapkitConfirmationOptions, \"amazon\">,\n): string {\n return (\n options.amazon?.verifiedProductId?.(purchase.productId) ??\n purchase.productId\n );\n}\n\nfunction amazonExpectedEnvironment(\n amazon: IapkitConfirmationOptions[\"amazon\"],\n): \"Sandbox\" | \"Production\" {\n const expected =\n amazon?.expectedEnvironment ?? (amazon?.sandbox ? \"Sandbox\" : \"Production\");\n if (expected !== \"Sandbox\" && expected !== \"Production\") {\n throw new Error(\"Amazon expectedEnvironment must be Sandbox or Production\");\n }\n if (amazon?.sandbox && expected === \"Production\") {\n throw new Error(\n \"Amazon Cloud Sandbox requires expectedEnvironment Sandbox\",\n );\n }\n return expected;\n}\n\nfunction environmentMismatch(\n environment: string | null | undefined,\n store: string,\n purchase: PurchaseFlowPurchase,\n options: Pick<IapkitConfirmationOptions, \"amazon\">,\n): string | null {\n const expected =\n store === \"amazon\"\n ? amazonExpectedEnvironment(options.amazon)\n : store === \"apple\"\n ? purchase.environmentIOS\n : null;\n return expected && environment !== expected\n ? `environment ${environment ?? \"(none)\"}, expected ${expected}`\n : null;\n}\n\n// Apple and Amazon keep a consumable at ready-to-consume until it is finished;\n// Google reports a granted purchase as pending-acknowledgment until then.\nfunction grantsAccess(\n store: string,\n state: string,\n isConsumable: boolean,\n): boolean {\n switch (store) {\n case \"apple\":\n case \"amazon\":\n return state === (isConsumable ? \"ready-to-consume\" : \"entitled\");\n case \"google\":\n return (\n state === \"entitled\" ||\n state === \"pending-acknowledgment\" ||\n (isConsumable && state === \"ready-to-consume\")\n );\n case \"horizon\":\n return state === \"entitled\";\n default:\n return false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"purchase-flow-confirmers.js","sourceRoot":"","sources":["../src/purchase-flow-confirmers.ts"],"names":[],"mappings":"AAmEA,MAAM,uBAAuB,GAAG,MAAM,CAAC;AACvC,8EAA8E;AAC9E,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,0BAEsC,EACtC,OAAqC;IAErC,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;QACjC,YAAY,CAAC,mBAAmB,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9D,MAAM,YAAY,GAAG,sBAAsB,CACzC,MAAM,0BAA0B,CAC9B,yBAAyB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAC7C,EACD,QAAQ,EACR,OAAO,EACP,OAAO,CACR,CAAC;QACF,IAAI,YAAY,CAAC,MAAM,KAAK,UAAU,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC;YACvE,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,YAAY,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,2BAA2B,CACzC,yBAA6C,EAC7C,UAQI,EAAE;IAEN,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;QACjC,YAAY,CAAC,oBAAoB,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC/D,uEAAuE;QACvE,IACE,QAAQ,CAAC,KAAK,KAAK,OAAO;YAC1B,CAAC,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,KAAK,OAAO,EACzC,CAAC;YACD,MAAM,IAAI,KAAK,CACb,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a,EACb,KAAa,EACb,YAAqB;IAErB,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,OAAO,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,KAAK,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;QACpE,KAAK,QAAQ;YACX,OAAO,CACL,KAAK,KAAK,UAAU;gBACpB,KAAK,KAAK,wBAAwB;gBAClC,CAAC,YAAY,IAAI,KAAK,KAAK,kBAAkB,CAAC,CAC/C,CAAC;QACJ,KAAK,SAAS;YACZ,OAAO,KAAK,KAAK,UAAU,CAAC;QAC9B;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC","sourcesContent":["// Internal adapters for SDK confirmation helpers; apps use SDK root imports.\n// Each adapter uses the same lifecycle contract as other verification services.\nimport type {\n PurchaseConfirmation,\n PurchaseFlowOptions,\n PurchaseFlowPurchase,\n} from \"./purchase-flow-core\";\n\ntype IapkitStore = \"apple\" | \"google\" | \"amazon\" | \"horizon\";\n\n/** How an app without its own backend confirms purchases with IAPKit. */\nexport interface IapkitConfirmationOptions<\n P extends PurchaseFlowPurchase = PurchaseFlowPurchase,\n> {\n /**\n * A publishable key (`openiap-kit_pk_...`), which is safe to ship in an\n * app. Leave it out where the SDK has one configured, such as Expo's\n * `iapkitApiKey`.\n */\n apiKey?: string;\n /** A self-hosted or local IAPKit origin. Defaults to https://kit.openiap.dev. */\n baseUrl?: string;\n amazon?: {\n /** Verify App Tester receipts with the Amazon RVS Cloud Sandbox. */\n sandbox?: boolean;\n /** Expected verdict environment; defaults to Sandbox with sandbox, otherwise Production. */\n expectedEnvironment?: \"Sandbox\" | \"Production\";\n /** RVS reports a subscription term under its parent SKU; maps one to the other. */\n verifiedProductId?: (productId: string) => string;\n };\n /** The IAPKit store that verifies a community store's evidence, such as an Amazon RVS adapter. */\n verifyAs?: (purchase: P) => IapkitStore | undefined;\n /** Credits consumables before finishing; must be idempotent per purchase.id. */\n grant?: (purchase: P, context: { isConsumable: boolean }) => Promise<void>;\n}\n\n/** @internal Use the SDK's VerifyPurchaseWithProviderProps. */\nexport interface IapkitVerificationProps {\n provider: \"iapkit\";\n iapkit: {\n apiKey?: string;\n baseUrl?: string;\n apple?: { jws: string };\n google?: { purchaseToken: string };\n amazon?: {\n receiptId: string;\n expectedProductId: string;\n sandbox: boolean;\n userId?: string;\n };\n horizon?: { sku: string };\n };\n}\n\n/** @internal Use the SDK's VerifyPurchaseWithProviderResult. */\nexport interface IapkitVerificationResult {\n iapkit?: {\n store: string;\n storeId: string;\n environment?: string | null;\n isValid: boolean;\n state: string;\n productId?: string | null;\n } | null;\n errors?: { code?: string | null; message: string }[] | null;\n}\n\nconst IAPKIT_UNKNOWN_RETRY_MS = 30_000;\n// An expired App Store receipt may still be in billing grace; check it again.\nconst DEVICE_EXPIRED_RETRY_MS = 30_000;\n\n/**\n * @internal Use the SDK's confirmWithIapkit.\n * The SDK's `confirmWithIapkit`, given its `verifyPurchaseWithProvider`:\n * verifies the purchase with IAPKit, then runs `grant` before the flow\n * finishes it.\n */\nexport function createIapkitConfirmation<P extends PurchaseFlowPurchase>(\n verifyPurchaseWithProvider: (\n props: IapkitVerificationProps,\n ) => Promise<IapkitVerificationResult>,\n options: IapkitConfirmationOptions<P>,\n): PurchaseFlowOptions<P>[\"confirmWithBackend\"] {\n return async (purchase, context) => {\n requireGrant(\"confirmWithIapkit\", purchase, context, options);\n const confirmation = readIapkitVerification(\n await verifyPurchaseWithProvider(\n toIapkitVerificationProps(purchase, options),\n ),\n purchase,\n context,\n options,\n );\n if (confirmation.status === \"entitled\" && !confirmation.alreadyGranted) {\n await options.grant?.(purchase, context);\n }\n return confirmation;\n };\n}\n\n/**\n * @internal Use the SDK's confirmOnDeviceIOS.\n * The SDK's `confirmOnDeviceIOS`, given its `getPendingTransactionsIOS`, for an\n * app with neither a backend nor IAPKit. StoreKit verified the transaction if\n * it lists it as unfinished, or, for a purchase the flow already finished, in\n * `getTransactionHistoryIOS`, from the purchase's environment. A revoked or\n * upgraded one is `invalid`, and an expired one `verification_delayed`, since\n * billing grace can still cover it; `grant` runs before an unfinished one is\n * finished, and again for a finished non-consumable a restore reads.\n */\nexport function createDeviceConfirmationIOS<P extends PurchaseFlowPurchase>(\n getPendingTransactionsIOS: () => Promise<P[]>,\n options: {\n /** Required for consumables; credit each purchase.id only once. */\n grant?: (purchase: P, context: { isConsumable: boolean }) => Promise<void>;\n /**\n * StoreKit's verified history, such as `getAvailablePurchases` with\n * `onlyIncludeActiveItemsIOS: false`; without it a finished purchase throws.\n */\n getTransactionHistoryIOS?: () => Promise<P[]>;\n } = {},\n): PurchaseFlowOptions<P>[\"confirmWithBackend\"] {\n return async (purchase, context) => {\n requireGrant(\"confirmOnDeviceIOS\", purchase, context, options);\n // A community provider may report store \"apple\" under its own storeId.\n if (\n purchase.store !== \"apple\" ||\n (purchase.storeId ?? \"apple\") !== \"apple\"\n ) {\n throw new Error(\n `Device confirmation covers App Store purchases, not ${purchase.storeId ?? purchase.store}`,\n );\n }\n const isSame = (candidate: P) =>\n candidate.store === \"apple\" &&\n purchase.id !== \"\" &&\n candidate.id === purchase.id &&\n candidate.productId === purchase.productId &&\n (purchase.environmentIOS == null ||\n candidate.environmentIOS === purchase.environmentIOS);\n const pending = (await getPendingTransactionsIOS()).find(isSame);\n const transaction =\n pending ?? (await options.getTransactionHistoryIOS?.())?.find(isSame);\n if (!transaction) {\n throw new Error(\n `StoreKit lists no transaction for ${purchase.productId}`,\n );\n }\n if (transaction.revocationDateIOS != null) {\n return { status: \"invalid\", reason: \"revoked\" };\n }\n if (transaction.isUpgradedIOS === true) {\n return { status: \"invalid\", reason: \"upgraded\" };\n }\n // After the reads: a transaction can expire while StoreKit answers.\n if (\n transaction.expirationDateIOS != null &&\n transaction.expirationDateIOS <= Date.now()\n ) {\n return {\n status: \"verification_delayed\",\n retryAfterMs: DEVICE_EXPIRED_RETRY_MS,\n };\n }\n // A finished consumable was credited before it was consumed.\n if (pending || !context.isConsumable) {\n await options.grant?.(purchase, context);\n }\n return { status: \"entitled\", alreadyGranted: !pending };\n };\n}\n\n// Checked before verifying: a consumable must never pass without a way to credit it.\nfunction requireGrant<P extends PurchaseFlowPurchase>(\n name: string,\n purchase: P,\n context: { isConsumable: boolean },\n options: Pick<IapkitConfirmationOptions<P>, \"grant\">,\n): void {\n if (context.isConsumable && !options.grant) {\n throw new Error(\n `${name} needs grant to credit consumable ${purchase.productId} before it is consumed`,\n );\n }\n}\n\n/** @internal Builds the IAPKit request; throws for a store IAPKit cannot verify. */\nexport function toIapkitVerificationProps<P extends PurchaseFlowPurchase>(\n purchase: P,\n options: IapkitConfirmationOptions<P>,\n): IapkitVerificationProps {\n const apiKey = options.apiKey?.trim();\n // An unset environment variable, not a deliberate fallback to the SDK's key.\n if (apiKey === \"\") throw new Error(\"IAPKit apiKey is empty\");\n const baseUrl = options.baseUrl?.trim();\n const base = {\n ...(apiKey ? { apiKey } : {}),\n ...(baseUrl ? { baseUrl } : {}),\n };\n const token = (): string => {\n if (!purchase.purchaseToken) {\n throw new Error(\n `Purchase ${purchase.productId} has no purchase token to verify`,\n );\n }\n return purchase.purchaseToken;\n };\n const store = verifyingStore(purchase, options);\n switch (store) {\n case \"apple\":\n return {\n provider: \"iapkit\",\n iapkit: { ...base, apple: { jws: token() } },\n };\n case \"google\":\n return {\n provider: \"iapkit\",\n iapkit: { ...base, google: { purchaseToken: token() } },\n };\n case \"amazon\":\n amazonExpectedEnvironment(options.amazon);\n return {\n provider: \"iapkit\",\n iapkit: {\n ...base,\n amazon: {\n receiptId: token(),\n expectedProductId: amazonProductId(purchase, options),\n sandbox: options.amazon?.sandbox ?? false,\n ...(purchase.userIdAmazon ? { userId: purchase.userIdAmazon } : {}),\n },\n },\n };\n case \"horizon\":\n return {\n provider: \"iapkit\",\n iapkit: { ...base, horizon: { sku: purchase.productId } },\n };\n default:\n throw new Error(`IAPKit cannot verify store ${purchase.store}`);\n }\n}\n\n/**\n * @internal Use the SDK's confirmWithIapkit.\n * Turns IAPKit's answer into the flow's confirmation. Anything that may be a\n * configuration error rather than a rejected payment throws, so the flow\n * reports `failed` and leaves the purchase unfinished: evidence for another\n * store, product, or environment, `inauthentic` (IAPKit's answer to a product\n * or package mismatch, and to every Horizon rejection), and a valid state this\n * product type cannot be granted from.\n */\nexport function readIapkitVerification<P extends PurchaseFlowPurchase>(\n result: IapkitVerificationResult,\n purchase: P,\n context: { isConsumable: boolean },\n options: Omit<IapkitConfirmationOptions<P>, \"apiKey\"> = {},\n): PurchaseConfirmation {\n const verified = result.iapkit;\n if (!verified) {\n const errors = (result.errors ?? []).map((error) =>\n error.code ? `[${error.code}] ${error.message}` : error.message,\n );\n throw new Error(\n errors.join(\"\\n\") || \"IAPKit returned no verification result\",\n );\n }\n switch (verified.state) {\n case \"pending\":\n return { status: \"store_pending\" };\n // The store gave no usable answer: retry instead of rejecting a payment.\n case \"unknown\":\n return {\n status: \"verification_delayed\",\n retryAfterMs: IAPKIT_UNKNOWN_RETRY_MS,\n };\n }\n const store = verifyingStore(purchase, options);\n const expectedProductId =\n store === \"amazon\"\n ? amazonProductId(purchase, options)\n : purchase.productId;\n const mismatch =\n verified.store !== purchase.store\n ? `store ${verified.store}, expected ${purchase.store}`\n : purchase.storeId && verified.storeId !== purchase.storeId\n ? `store id ${verified.storeId}, expected ${purchase.storeId}`\n : verified.productId !== expectedProductId\n ? `product ${verified.productId ?? \"(none)\"}, expected ${expectedProductId}`\n : environmentMismatch(verified.environment, store, purchase, options);\n if (mismatch) throw new Error(`IAPKit verified ${mismatch}`);\n if (!verified.isValid) {\n switch (verified.state) {\n case \"canceled\":\n case \"expired\":\n return { status: \"invalid\", reason: verified.state };\n // Only a granted purchase is consumed; the flow grants before finishing.\n case \"consumed\":\n return { status: \"entitled\", alreadyGranted: true };\n default:\n throw new Error(`IAPKit rejected the purchase: ${verified.state}`);\n }\n }\n if (!grantsAccess(store, verified.state, context.isConsumable)) {\n throw new Error(\n `IAPKit state ${verified.state} cannot grant this ${\n context.isConsumable ? \"consumable\" : \"non-consumable\"\n } ${purchase.store} purchase`,\n );\n }\n return { status: \"entitled\", alreadyGranted: false };\n}\n\nfunction verifyingStore<P extends PurchaseFlowPurchase>(\n purchase: P,\n options: Pick<IapkitConfirmationOptions<P>, \"verifyAs\">,\n): string {\n return options.verifyAs?.(purchase) ?? purchase.store;\n}\n\nfunction amazonProductId(\n purchase: PurchaseFlowPurchase,\n options: Pick<IapkitConfirmationOptions, \"amazon\">,\n): string {\n return (\n options.amazon?.verifiedProductId?.(purchase.productId) ??\n purchase.productId\n );\n}\n\nfunction amazonExpectedEnvironment(\n amazon: IapkitConfirmationOptions[\"amazon\"],\n): \"Sandbox\" | \"Production\" {\n const expected =\n amazon?.expectedEnvironment ?? (amazon?.sandbox ? \"Sandbox\" : \"Production\");\n if (expected !== \"Sandbox\" && expected !== \"Production\") {\n throw new Error(\"Amazon expectedEnvironment must be Sandbox or Production\");\n }\n if (amazon?.sandbox && expected === \"Production\") {\n throw new Error(\n \"Amazon Cloud Sandbox requires expectedEnvironment Sandbox\",\n );\n }\n return expected;\n}\n\nfunction environmentMismatch(\n environment: string | null | undefined,\n store: string,\n purchase: PurchaseFlowPurchase,\n options: Pick<IapkitConfirmationOptions, \"amazon\">,\n): string | null {\n const expected =\n store === \"amazon\"\n ? amazonExpectedEnvironment(options.amazon)\n : store === \"apple\"\n ? purchase.environmentIOS\n : null;\n return expected && environment !== expected\n ? `environment ${environment ?? \"(none)\"}, expected ${expected}`\n : null;\n}\n\n// Apple and Amazon keep a consumable at ready-to-consume until it is finished;\n// Google reports a granted purchase as pending-acknowledgment until then.\nfunction grantsAccess(\n store: string,\n state: string,\n isConsumable: boolean,\n): boolean {\n switch (store) {\n case \"apple\":\n case \"amazon\":\n return state === (isConsumable ? \"ready-to-consume\" : \"entitled\");\n case \"google\":\n return (\n state === \"entitled\" ||\n state === \"pending-acknowledgment\" ||\n (isConsumable && state === \"ready-to-consume\")\n );\n case \"horizon\":\n return state === \"entitled\";\n default:\n return false;\n }\n}\n"]}
|