expo-iap 5.6.2 β 5.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/CONTRIBUTING.md +5 -5
- package/README.md +2 -2
- package/build/index.kepler.d.ts +2 -2
- package/build/index.kepler.js +2 -2
- package/build/index.kepler.js.map +1 -1
- package/build/modules/android.d.ts +1 -1
- package/build/modules/android.js +1 -1
- package/build/modules/android.js.map +1 -1
- package/build/modules/ios.d.ts +1 -1
- package/build/modules/ios.js +1 -1
- package/build/modules/ios.js.map +1 -1
- package/build/types.d.ts +40 -40
- package/build/types.js.map +1 -1
- package/build/useIAP.d.ts +1 -1
- package/build/useIAP.js.map +1 -1
- package/build/utils/debug.d.ts.map +1 -1
- package/build/utils/debug.js +4 -11
- package/build/utils/debug.js.map +1 -1
- package/openiap-versions.json +1 -1
- package/package.json +1 -1
- package/plugin/build/withIAP.js +13 -4
- package/plugin/build/withLocalOpenIAP.js +28 -15
- package/plugin/build/withVega.js +18 -8
- package/plugin/src/withIAP.ts +10 -4
- package/plugin/src/withLocalOpenIAP.ts +30 -19
- package/plugin/src/withVega.ts +17 -9
- package/scripts/update-types.mjs +12 -8
- package/src/index.kepler.ts +2 -2
- package/src/modules/android.ts +1 -1
- package/src/modules/ios.ts +1 -1
- package/src/types.ts +40 -40
- package/src/useIAP.ts +1 -1
- package/src/utils/debug.ts +10 -17
package/AGENTS.md
CHANGED
|
@@ -84,7 +84,7 @@ For complete type definitions and documentation, see: <https://openiap.dev/docs/
|
|
|
84
84
|
|
|
85
85
|
The library follows the OpenIAP type specifications with platform-specific extensions using iOS/Android suffixes.
|
|
86
86
|
|
|
87
|
-
> **Important:** `src/types.ts` is generated from the OpenIAP schema. Never edit this file manually or commit hand-written changes. In this monorepo, run `cd specs/client && bun run generate` from the repository root so every platform copy stays synchronized. The Expo-local `bun run generate:types` command is only for a standalone checkout: it atomically refreshes the platform-ready file from the raw `
|
|
87
|
+
> **Important:** `src/types.ts` is generated from the OpenIAP schema. Never edit this file manually or commit hand-written changes. In this monorepo, run `cd specs/client && bun run generate` from the repository root so every platform copy stays synchronized. The Expo-local `bun run generate:types` command is only for a standalone checkout: it atomically refreshes the platform-ready file from the raw `openiap-client-protocol-${clientProtocol}` tag pinned by `openiap-versions.json` (or the version passed with `--tag`).
|
|
88
88
|
|
|
89
89
|
- Whenever you need Request/Params/Result types in the JS API surface (`src/index.ts`, hooks, modules, examples), import them directly from the generated `src/types.ts` (e.g., `MutationRequestPurchaseArgs`, `QueryFetchProductsArgs`). Bind exported functions with the generated `QueryField` / `MutationField` helpers so their signatures stay in lockstep with `types.ts` instead of redefining ad-hoc unions like `ProductTypeInput`.
|
|
90
90
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -214,28 +214,28 @@ For detailed code conventions, naming standards, and implementation guidelines,
|
|
|
214
214
|
|
|
215
215
|
### Updating OpenIAP Types
|
|
216
216
|
|
|
217
|
-
The generated TypeScript definitions in `src/types.ts` come from the platform-ready file committed in the [OpenIAP](https://github.com/hyodotdev/openiap) raw `
|
|
217
|
+
The generated TypeScript definitions in `src/types.ts` come from the platform-ready file committed in the [OpenIAP](https://github.com/hyodotdev/openiap) raw `openiap-client-protocol-${clientProtocol}` tag. Never edit this file by hand. When the schema changes or you need to pull newer published types:
|
|
218
218
|
|
|
219
219
|
- Run `bun run generate:types` to download the version pinned by `openiap-versions.json`, validate it, and atomically replace `src/types.ts`.
|
|
220
|
-
- To target a specific published
|
|
220
|
+
- To target a specific published Client Protocol version, pass it: `bun run generate:types --tag <version>` (the script resolves it to `openiap-client-protocol-<version>`).
|
|
221
221
|
- Commit the updated file alongside any related schema or documentation changes.
|
|
222
222
|
|
|
223
223
|
Always ensure the repository builds and tests succeed after regenerating the types.
|
|
224
224
|
|
|
225
225
|
## π’ OpenIAP Version Management
|
|
226
226
|
|
|
227
|
-
The native dependency and
|
|
227
|
+
The native dependency and Client Protocol versions are sourced from `openiap-versions.json` at the repository root:
|
|
228
228
|
|
|
229
229
|
- `apple` β iOS Pod dependency (`ios/ExpoIap.podspec`).
|
|
230
230
|
- `google` β Android artifact (`android/build.gradle`, Expo config plugin).
|
|
231
|
-
- `
|
|
231
|
+
- `clientProtocol` β published Client Protocol types release (`scripts/update-types.mjs`).
|
|
232
232
|
|
|
233
233
|
When bumping dependencies:
|
|
234
234
|
|
|
235
235
|
1. Update the relevant fields in `openiap-versions.json`.
|
|
236
236
|
2. For iOS changes, run `cd ios && pod install` (and commit the Pod.lock if required by the workflow).
|
|
237
237
|
3. For Android, re-run Gradle (`bun run android`) so the new artifact is pulled down.
|
|
238
|
-
4. When the `
|
|
238
|
+
4. When the `clientProtocol` value changes, run `bun run generate:types` to refresh `src/types.ts` from the matching raw `openiap-client-protocol-${clientProtocol}` tag.
|
|
239
239
|
5. Commit the updated JSON, regenerated files, and any resulting lockfile changes together.
|
|
240
240
|
|
|
241
241
|
If the JSON file is missing or malformed, build scripts (Gradle, Podspec, the type generator) will fail fast β fix the JSON rather than hard-coding version strings in multiple locations.
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
[](https://npmjs.org/package/expo-iap) [](https://npmjs.org/package/expo-iap) [](https://openiap.dev) [](https://github.com/hyodotdev/openiap/actions/workflows/ci-expo-iap.yml?query=branch%3Amain) [](https://app.codecov.io/gh/hyodotdev/openiap/tree/main/libraries/expo-iap) [](https://app.fossa.com/projects/git%2Bgithub.com%2Fhyochan%2Fexpo-iap?ref=badge_shield&issueType=license)
|
|
7
7
|
|
|
8
|
-
Expo IAP is a powerful in-app purchase solution for Expo and React Native applications that conforms to the OpenIAP
|
|
8
|
+
Expo IAP is a powerful in-app purchase solution for Expo and React Native applications that conforms to the OpenIAP Client Protocol. It provides a unified API for handling in-app purchases across iOS and Android platforms with comprehensive error handling and modern TypeScript support.
|
|
9
9
|
|
|
10
10
|
If you're shipping an app with expo-iap, weβd love to hear about itβplease share your product and feedback in [expo-iap Q&A Discussions](https://github.com/hyodotdev/openiap/discussions/categories/expo-iap). Community stories help us keep improving the ecosystem.
|
|
11
11
|
|
|
@@ -66,7 +66,7 @@ For detailed usage examples and error handling, see the [documentation](https://
|
|
|
66
66
|
|
|
67
67
|
<a href="https://openiap.dev"><img src="https://raw.githubusercontent.com/hyodotdev/openiap/main/logo.webp" alt="OpenIAP" height="50" /></a>
|
|
68
68
|
|
|
69
|
-
Expo IAP conforms to the **[OpenIAP
|
|
69
|
+
Expo IAP conforms to the **[OpenIAP Client Protocol](https://openiap.dev)** β an open, vendor-neutral interoperability standard for in-app purchases. OpenIAP provides:
|
|
70
70
|
|
|
71
71
|
- **Shared specification** β Common types, error codes, and purchase flows across all platforms
|
|
72
72
|
- **Generated type-safe bindings** β Swift, Kotlin, Dart, and GDScript from a single GraphQL schema
|
package/build/index.kepler.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export declare const getAppTransactionIOS: QueryField<'getAppTransactionIOS'>;
|
|
|
43
43
|
export declare const getPromotedProductIOS: QueryField<'getPromotedProductIOS'>;
|
|
44
44
|
export declare const showManageSubscriptionsIOS: MutationField<'showManageSubscriptionsIOS'>;
|
|
45
45
|
/**
|
|
46
|
-
* @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in
|
|
46
|
+
* @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in client protocol 1.0.0.
|
|
47
47
|
*/
|
|
48
48
|
export declare const presentCodeRedemptionSheetIOS: MutationField<'presentCodeRedemptionSheetIOS'>;
|
|
49
49
|
export declare const presentExternalPurchaseLinkIOS: MutationField<'presentExternalPurchaseLinkIOS'>;
|
|
@@ -51,7 +51,7 @@ export declare const deepLinkToSubscriptions: MutationField<'deepLinkToSubscript
|
|
|
51
51
|
export declare const openRedeemOfferCode: MutationField<'openRedeemOfferCode'>;
|
|
52
52
|
/**
|
|
53
53
|
* @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in
|
|
54
|
-
*
|
|
54
|
+
* client protocol 1.0.0.
|
|
55
55
|
*/
|
|
56
56
|
export declare const openRedeemOfferCodeAndroid: MutationField<'openRedeemOfferCodeAndroid'>;
|
|
57
57
|
export declare const promotedProductListenerIOS: () => EventSubscription;
|
package/build/index.kepler.js
CHANGED
|
@@ -132,7 +132,7 @@ export const getAppTransactionIOS = async () => null;
|
|
|
132
132
|
export const getPromotedProductIOS = async () => null;
|
|
133
133
|
export const showManageSubscriptionsIOS = async () => [];
|
|
134
134
|
/**
|
|
135
|
-
* @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in
|
|
135
|
+
* @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in client protocol 1.0.0.
|
|
136
136
|
*/
|
|
137
137
|
export const presentCodeRedemptionSheetIOS = async () => null;
|
|
138
138
|
export const presentExternalPurchaseLinkIOS = async () => unsupported('presentExternalPurchaseLinkIOS');
|
|
@@ -141,7 +141,7 @@ export const deepLinkToSubscriptions = async () => unsupported('deepLinkToSubscr
|
|
|
141
141
|
export const openRedeemOfferCode = async () => null;
|
|
142
142
|
/**
|
|
143
143
|
* @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in
|
|
144
|
-
*
|
|
144
|
+
* client protocol 1.0.0.
|
|
145
145
|
*/
|
|
146
146
|
export const openRedeemOfferCodeAndroid = async () => false;
|
|
147
147
|
export const promotedProductListenerIOS = () => ({
|
|
@@ -1 +1 @@
|
|
|
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;AAalC,OAAO,EAAC,sBAAsB,EAAC,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAC,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AAEzD,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAC,MA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GAAE,CAAC;CACjB,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,uCAAuC,GAClD,GAAsB,EAAE,CAAC,CAAC;IACxB,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;CACjB,CAAC,CAAC;AACL,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAsB,EAAE,CAAC,CAAC;IACxE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gCAAgC,GAEzC,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,kCAAkC,CAAC,CAAC;AAChE,MAAM,CAAC,MAAM,2BAA2B,GAEpC,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,6BAA6B,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,yBAAyB,GAElC,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,2BAA2B,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,2CAA2C,GAEpD,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,6CAA6C,CAAC,CAAC;AAC3E,MAAM,CAAC,MAAM,0CAA0C,GAEnD,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,4CAA4C,CAAC,CAAC;AAC1E,MAAM,CAAC,MAAM,wBAAwB,GAEjC,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,0BAA0B,CAAC,CAAC","sourcesContent":["import {getVegaIapModule} from './vega';\nimport {ErrorCode} from './types';\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 * from './vega';\nexport * from './useIAP';\nexport {kitApi, KitApiError} from './kit-api';\nexport type {\n EntitlementsResponse,\n KitApiOptions,\n KitClientPayloadCache,\n KitClientPayloadOptions,\n KitClientPayloadResponse,\n KitProduct,\n KitProductClientPayload,\n KitProductOffer,\n KitProductPlatform,\n KitProductsOptions,\n KitProductsResponse,\n KitSubscription,\n StatusResponse,\n} from './kit-api';\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 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 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 () => [];\n/**\n * @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in OpenIAP 4.0.\n */\nexport const presentCodeRedemptionSheetIOS: MutationField<\n 'presentCodeRedemptionSheetIOS'\n> = async () => null;\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/**\n * @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in\n * OpenIAP 4.0.\n */\nexport const openRedeemOfferCodeAndroid: MutationField<\n 'openRedeemOfferCodeAndroid'\n> = async () => false;\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"]}
|
|
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;AAalC,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M,0BAA0B,GAAG,GAAsB,EAAE,CAAC,CAAC;IAClE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;CACjB,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAsB,EAAE,CAAC,CAAC;IACxE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;CACjB,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,uCAAuC,GAClD,GAAsB,EAAE,CAAC,CAAC;IACxB,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;CACjB,CAAC,CAAC;AACL,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAsB,EAAE,CAAC,CAAC;IACxE,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gCAAgC,GAEzC,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,kCAAkC,CAAC,CAAC;AAChE,MAAM,CAAC,MAAM,2BAA2B,GAEpC,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,6BAA6B,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,yBAAyB,GAElC,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,2BAA2B,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,2CAA2C,GAEpD,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,6CAA6C,CAAC,CAAC;AAC3E,MAAM,CAAC,MAAM,0CAA0C,GAEnD,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,4CAA4C,CAAC,CAAC;AAC1E,MAAM,CAAC,MAAM,wBAAwB,GAEjC,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,0BAA0B,CAAC,CAAC","sourcesContent":["import {getVegaIapModule} from './vega';\nimport {ErrorCode} from './types';\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 * from './vega';\nexport * from './useIAP';\nexport {kitApi, KitApiError} from './kit-api';\nexport type {\n EntitlementsResponse,\n KitApiOptions,\n KitClientPayloadCache,\n KitClientPayloadOptions,\n KitClientPayloadResponse,\n KitProduct,\n KitProductClientPayload,\n KitProductOffer,\n KitProductPlatform,\n KitProductsOptions,\n KitProductsResponse,\n KitSubscription,\n StatusResponse,\n} from './kit-api';\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 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 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 () => [];\n/**\n * @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in client protocol 1.0.0.\n */\nexport const presentCodeRedemptionSheetIOS: MutationField<\n 'presentCodeRedemptionSheetIOS'\n> = async () => null;\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/**\n * @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in\n * client protocol 1.0.0.\n */\nexport const openRedeemOfferCodeAndroid: MutationField<\n 'openRedeemOfferCodeAndroid'\n> = async () => false;\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"]}
|
|
@@ -49,7 +49,7 @@ export declare const acknowledgePurchaseAndroid: MutationField<'acknowledgePurch
|
|
|
49
49
|
* @returns Promise resolving to true when launched, or false when unsupported
|
|
50
50
|
*
|
|
51
51
|
* @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in
|
|
52
|
-
*
|
|
52
|
+
* client protocol 1.0.0.
|
|
53
53
|
*
|
|
54
54
|
* @see {@link https://openiap.dev/docs/apis/android/open-redeem-offer-code-android}
|
|
55
55
|
*/
|
package/build/modules/android.js
CHANGED
|
@@ -119,7 +119,7 @@ export const acknowledgePurchaseAndroid = async (purchaseToken) => {
|
|
|
119
119
|
* @returns Promise resolving to true when launched, or false when unsupported
|
|
120
120
|
*
|
|
121
121
|
* @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in
|
|
122
|
-
*
|
|
122
|
+
* client protocol 1.0.0.
|
|
123
123
|
*
|
|
124
124
|
* @see {@link https://openiap.dev/docs/apis/android/open-redeem-offer-code-android}
|
|
125
125
|
*/
|
|
@@ -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,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AA2BjC,MAAM,mBAAmB,GAAG,aAAoC,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,sBAAsB,GAAG,CAAC,UAAkB,EAAQ,EAAE;IAC1D,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,2CAA2C,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC,CAAC;AAEF,cAAc;AACd,MAAM,UAAU,gBAAg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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 {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\ntype NativeAndroidModule = {\n deepLinkToSubscriptionsAndroid?: (params: {\n skuAndroid?: string;\n packageNameAndroid?: string;\n }) => Promise<void> | void;\n getStorefront?: () => Promise<string> | string;\n};\n\nconst nativeAndroidModule = ExpoIapModule as NativeAndroidModule;\n\n/**\n * Enforce the documented Android-only contract. Vega OS is treated as an\n * Android store runtime (matching `isAndroidStoreRuntime` in src/index.ts),\n * so it passes through. Without this guard, calling a suffixed wrapper on\n * another platform falls through to the native proxy and surfaces as an\n * opaque `TypeError: ExpoIapModule.<name> is not a function` instead of the\n * promised platform error.\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 as any).platform === 'string' &&\n (item as any).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 (nativeAndroidModule?.deepLinkToSubscriptionsAndroid) {\n return nativeAndroidModule.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 ExpoIapModule.consumePurchaseAndroid(purchaseToken);\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 ExpoIapModule.acknowledgePurchaseAndroid(purchaseToken);\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 * Open the Google Play offer/promo code redemption flow so the user can enter a code (Android only).\n * On Play builds, launches the Play Store redeem page. A listener can receive\n * the purchase while the app has an active billing connection; reconcile\n * available purchases when the app resumes. Unsupported store flavors return false.\n * Does not require the billing client to be initialized (no Play Billing version requirement).\n * Android counterpart of presentCodeRedemptionSheetIOS.\n *\n * @returns Promise resolving to true when launched, or false when unsupported\n *\n * @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in\n * OpenIAP 4.0.\n *\n * @see {@link https://openiap.dev/docs/apis/android/open-redeem-offer-code-android}\n */\nexport const openRedeemOfferCodeAndroid: MutationField<\n 'openRedeemOfferCodeAndroid'\n> = async () => {\n requireAndroidPlatform('openRedeemOfferCodeAndroid');\n if (isVegaOS()) {\n return false;\n }\n return ExpoIapModule.openRedeemOfferCodeAndroid();\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,QAAQ,EAAC,MAAM,SAAS,CAAC;AA2BjC,MAAM,mBAAmB,GAAG,aAAoC,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,sBAAsB,GAAG,CAAC,UAAkB,EAAQ,EAAE;IAC1D,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,2CAA2C,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC,CAAC;AAEF,cAAc;AACd,MAAM,UAAU,gBAAgB,CAC9B,IAAa;IAEb,OAAO,CACL,IAAI,IAAI,IAAI;QACZ,OAAO,IAAI,KAAK,QAAQ;QACxB,UAAU,IAAI,IAAI;QAClB,OAAQ,IAAY,CAAC,QAAQ,KAAK,QAAQ;QACzC,IAAY,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,SAAS,CACnD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,KAAK,EACjD,OAAgC,EACjB,EAAE;IACjB,MAAM,GAAG,GAAG,OAAO,EAAE,UAAU,IAAI,SAAS,CAAC;IAC7C,MAAM,WAAW,GAAG,OAAO,EAAE,kBAAkB,IAAI,SAAS,CAAC;IAE7D,4DAA4D;IAC5D,IAAI,mBAAmB,EAAE,8BAA8B,EAAE,CAAC;QACxD,OAAO,mBAAmB,CAAC,8BAA8B,CAAC;YACxD,UAAU,EAAE,GAAG;YACf,kB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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 {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\ntype NativeAndroidModule = {\n deepLinkToSubscriptionsAndroid?: (params: {\n skuAndroid?: string;\n packageNameAndroid?: string;\n }) => Promise<void> | void;\n getStorefront?: () => Promise<string> | string;\n};\n\nconst nativeAndroidModule = ExpoIapModule as NativeAndroidModule;\n\n/**\n * Enforce the documented Android-only contract. Vega OS is treated as an\n * Android store runtime (matching `isAndroidStoreRuntime` in src/index.ts),\n * so it passes through. Without this guard, calling a suffixed wrapper on\n * another platform falls through to the native proxy and surfaces as an\n * opaque `TypeError: ExpoIapModule.<name> is not a function` instead of the\n * promised platform error.\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 as any).platform === 'string' &&\n (item as any).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 (nativeAndroidModule?.deepLinkToSubscriptionsAndroid) {\n return nativeAndroidModule.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 ExpoIapModule.consumePurchaseAndroid(purchaseToken);\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 ExpoIapModule.acknowledgePurchaseAndroid(purchaseToken);\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 * Open the Google Play offer/promo code redemption flow so the user can enter a code (Android only).\n * On Play builds, launches the Play Store redeem page. A listener can receive\n * the purchase while the app has an active billing connection; reconcile\n * available purchases when the app resumes. Unsupported store flavors return false.\n * Does not require the billing client to be initialized (no Play Billing version requirement).\n * Android counterpart of presentCodeRedemptionSheetIOS.\n *\n * @returns Promise resolving to true when launched, or false when unsupported\n *\n * @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in\n * client protocol 1.0.0.\n *\n * @see {@link https://openiap.dev/docs/apis/android/open-redeem-offer-code-android}\n */\nexport const openRedeemOfferCodeAndroid: MutationField<\n 'openRedeemOfferCodeAndroid'\n> = async () => {\n requireAndroidPlatform('openRedeemOfferCodeAndroid');\n if (isVegaOS()) {\n return false;\n }\n return ExpoIapModule.openRedeemOfferCodeAndroid();\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"]}
|
package/build/modules/ios.d.ts
CHANGED
|
@@ -159,7 +159,7 @@ export declare const getTransactionJwsIOS: QueryField<'getTransactionJwsIOS'>;
|
|
|
159
159
|
* @platform iOS
|
|
160
160
|
*
|
|
161
161
|
* @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in
|
|
162
|
-
*
|
|
162
|
+
* client protocol 1.0.0.
|
|
163
163
|
*
|
|
164
164
|
* @see {@link https://openiap.dev/docs/apis/ios/present-code-redemption-sheet-ios}
|
|
165
165
|
*/
|
package/build/modules/ios.js
CHANGED
|
@@ -236,7 +236,7 @@ export const getTransactionJwsIOS = async (sku) => {
|
|
|
236
236
|
* @platform iOS
|
|
237
237
|
*
|
|
238
238
|
* @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in
|
|
239
|
-
*
|
|
239
|
+
* client protocol 1.0.0.
|
|
240
240
|
*
|
|
241
241
|
* @see {@link https://openiap.dev/docs/apis/ios/present-code-redemption-sheet-ios}
|
|
242
242
|
*/
|
package/build/modules/ios.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,mBAAmB;AACnB,mEAAmE;AACnE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAe7C,OAAO,EAAoB,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,kBAAkB,GAAG,CAAC,UAAkB,EAAQ,EAAE;IACtD,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,2BAA2B,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC,CAAC;AAOF,YAAY;AAEZ,cAAc;AACd,MAAM,UAAU,YAAY,CAC1B,IAAa;IAEb,OAAO,CACL,IAAI,IAAI,IAAI;QACZ,OAAO,IAAI,KAAK,QAAQ;QACxB,UAAU,IAAI,IAAI;QAClB,OAAQ,IAAY,CAAC,QAAQ,KAAK,QAAQ;QACzC,IAAY,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,KAAK,CAC/C,CAAC;AACJ,CAAC;AAED,YAAY;AACZ;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,OAAO,GAA6B,KAAK,IAAI,EAAE;IAC1D,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC9B,OAAO,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAEnC,KA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;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAEvC,KAAK,EAAE,GAAW,EAAE,EAAE;IACxB,kBAAkB,CAAC,gCAAgC,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,8BAA8B,CAAC,GAAG,CAAC,CAAC;IACvE,OAAO,MAAuC,CAAC;AACjD,CAAC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAEnD,KAAK,IAAI,EAAE;IACb,kBAAkB,CAAC,4CAA4C,CAAC,CAAC;IACjE,OAAO,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,0CAA0C,EAAE,CAAC,CAAC;AAC9E,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAE9C,KAAK,EAAE,SAAS,EAAE,EAAE;IACtB,kBAAkB,CAAC,uCAAuC,CAAC,CAAC;IAC5D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,0FAA0F,CAC3F,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GACV,MAAM,aAAa,CAAC,qCAAqC,CAAC,SAAS,CAAC,CAAC;IACvE,OAAO,MAAkD,CAAC;AAC5D,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;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,GACV,MAAM,aAAa,CAAC,uCAAuC,CAAC,UAAU,CAAC,CAAC;IAC1E,OAAO,MAAmD,CAAC;AAC7D,CAAC,CAAC;AAEF,uEAAuE","sourcesContent":["// External dependencies\n\n// Internal modules\n// import removed: use purchaseUpdatedListener directly in app code\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 {decodeApplePurchases} from '../utils/availablePurchases';\nimport {Linking, Platform} from 'react-native';\n\n/**\n * Enforce the documented iOS-only contract. Without this, calling a\n * suffixed wrapper on another platform falls through to the native proxy\n * and surfaces as an opaque `TypeError: ExpoIapModule.<name> is not a\n * function` instead of the promised platform error.\n */\nconst requireIosPlatform = (methodName: string): void => {\n if (Platform.OS !== 'ios') {\n throw new Error(`${methodName} is only available on iOS`);\n }\n};\n\nexport type TransactionEvent = {\n transaction?: Purchase;\n error?: PurchaseError;\n};\n\n// Listeners\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 as any).platform === 'string' &&\n (item as any).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 null 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 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 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 ExpoIapModule.subscriptionStatusIOS(sku);\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 ExpoIapModule.currentEntitlementIOS(sku);\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 ExpoIapModule.latestTransactionIOS(sku);\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 ExpoIapModule.beginRefundRequestIOS(sku);\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 ExpoIapModule.showManageSubscriptionsIOS();\n return decodeApplePurchases(purchases);\n};\n\n/**\n * Get the receipt data from the iOS device.\n * This returns the base64 encoded receipt data which can be sent to your server\n * for verification with Apple's server.\n *\n * NOTE: For proper security, always verify receipts on your server using\n * Apple's verifyReceipt endpoint, not 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 ExpoIapModule.getReceiptDataIOS();\n};\n\n/**\n * Refresh the receipt data from Apple's servers and return the updated receipt.\n * This calls AppStore.sync() before reading the receipt, ensuring the latest\n * receipt data is available. Use this after a first purchase when\n * getReceiptDataIOS() may return an empty string because the receipt file\n * has not yet been written to disk.\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 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 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 ExpoIapModule.getTransactionJwsIOS(sku);\n return jws ?? '';\n};\n\n/**\n * Present the code redemption sheet for offer codes (iOS only).\n * This allows users to redeem promotional codes for in-app purchases and subscriptions.\n *\n * Note: This only works on real devices, not simulators.\n *\n * @returns The verified redeemed purchase when built with Xcode 27+ and\n * running on Apple 27+. Earlier iOS/visionOS system sheets return null;\n * Catalyst 16β26 surfaces StoreKitError.unknown, and Catalyst 15 is a no-op\n * that returns null.\n * @throws Error if called on non-iOS platform or tvOS\n *\n * @platform iOS\n *\n * @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in\n * OpenIAP 4.0.\n *\n * @see {@link https://openiap.dev/docs/apis/ios/present-code-redemption-sheet-ios}\n */\nexport const presentCodeRedemptionSheetIOS: MutationField<\n 'presentCodeRedemptionSheetIOS'\n> = async () => {\n requireIosPlatform('presentCodeRedemptionSheetIOS');\n return await ExpoIapModule.presentCodeRedemptionSheetIOS();\n};\n\n/**\n * Get app transaction information (iOS 16.0+).\n * AppTransaction represents the initial purchase that unlocked the app.\n *\n * NOTE: This function requires:\n * - iOS 16.0 or later at runtime\n * - Xcode 15.0+ with iOS 16.0 SDK for compilation\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 (await ExpoIapModule.getAppTransactionIOS()) ?? null;\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 ExpoIapModule.getPromotedProductIOS();\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 ExpoIapModule.getPendingTransactionsIOS();\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 ExpoIapModule.getAllTransactionsIOS();\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 ExpoIapModule.clearTransactionIOS());\n};\n\n/**\n * Deep link to subscriptions screen on iOS.\n * @returns {Promise<void>}\n *\n * @platform iOS\n */\nexport const deepLinkToSubscriptionsIOS = (): Promise<void> =>\n Linking.openURL('https://apps.apple.com/account/subscriptions');\n\n/**\n * Check if the device can present an external purchase notice sheet (iOS 17.4+).\n *\n * Wraps `ExternalPurchase.canPresent`, which Apple introduced in iOS 17.4.\n * Note: the notice sheet itself (`presentExternalPurchaseNoticeSheetIOS`)\n * still requires iOS 18.2+; only the eligibility check is available earlier.\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 ExpoIapModule.canPresentExternalPurchaseNoticeIOS());\n};\n\n/**\n * Present an external purchase notice sheet to inform users about external purchases (iOS 15.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 ExpoIapModule.presentExternalPurchaseNoticeSheetIOS();\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 ExpoIapModule.presentExternalPurchaseLinkIOS(url);\n return result as ExternalPurchaseLinkResultIOS;\n};\n\n/**\n * Check if app is eligible for ExternalPurchaseCustomLink API (iOS 18.1+).\n * Returns true if the app can use custom external purchase links.\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 ExpoIapModule.isEligibleForExternalPurchaseCustomLinkIOS());\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 =\n await ExpoIapModule.getExternalPurchaseCustomLinkTokenIOS(tokenType);\n return result as ExternalPurchaseCustomLinkTokenResultIOS;\n};\n\n/**\n * Show ExternalPurchaseCustomLink notice sheet (iOS 18.1+).\n * Displays the system disclosure notice sheet for custom external purchase links.\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 =\n await ExpoIapModule.showExternalPurchaseCustomLinkNoticeIOS(noticeType);\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","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,mBAAmB;AACnB,mEAAmE;AACnE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAe7C,OAAO,EAAoB,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,kBAAkB,G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AC,MAAM,qCAAqC,GAE9C,KAAK,EAAE,SAAS,EAAE,EAAE;IACtB,kBAAkB,CAAC,uCAAuC,CAAC,CAAC;IAC5D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,0FAA0F,CAC3F,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GACV,MAAM,aAAa,CAAC,qCAAqC,CAAC,SAAS,CAAC,CAAC;IACvE,OAAO,MAAkD,CAAC;AAC5D,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;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,GACV,MAAM,aAAa,CAAC,uCAAuC,CAAC,UAAU,CAAC,CAAC;IAC1E,OAAO,MAAmD,CAAC;AAC7D,CAAC,CAAC;AAEF,uEAAuE","sourcesContent":["// External dependencies\n\n// Internal modules\n// import removed: use purchaseUpdatedListener directly in app code\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 {decodeApplePurchases} from '../utils/availablePurchases';\nimport {Linking, Platform} from 'react-native';\n\n/**\n * Enforce the documented iOS-only contract. Without this, calling a\n * suffixed wrapper on another platform falls through to the native proxy\n * and surfaces as an opaque `TypeError: ExpoIapModule.<name> is not a\n * function` instead of the promised platform error.\n */\nconst requireIosPlatform = (methodName: string): void => {\n if (Platform.OS !== 'ios') {\n throw new Error(`${methodName} is only available on iOS`);\n }\n};\n\nexport type TransactionEvent = {\n transaction?: Purchase;\n error?: PurchaseError;\n};\n\n// Listeners\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 as any).platform === 'string' &&\n (item as any).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 null 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 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 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 ExpoIapModule.subscriptionStatusIOS(sku);\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 ExpoIapModule.currentEntitlementIOS(sku);\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 ExpoIapModule.latestTransactionIOS(sku);\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 ExpoIapModule.beginRefundRequestIOS(sku);\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 ExpoIapModule.showManageSubscriptionsIOS();\n return decodeApplePurchases(purchases);\n};\n\n/**\n * Get the receipt data from the iOS device.\n * This returns the base64 encoded receipt data which can be sent to your server\n * for verification with Apple's server.\n *\n * NOTE: For proper security, always verify receipts on your server using\n * Apple's verifyReceipt endpoint, not 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 ExpoIapModule.getReceiptDataIOS();\n};\n\n/**\n * Refresh the receipt data from Apple's servers and return the updated receipt.\n * This calls AppStore.sync() before reading the receipt, ensuring the latest\n * receipt data is available. Use this after a first purchase when\n * getReceiptDataIOS() may return an empty string because the receipt file\n * has not yet been written to disk.\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 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 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 ExpoIapModule.getTransactionJwsIOS(sku);\n return jws ?? '';\n};\n\n/**\n * Present the code redemption sheet for offer codes (iOS only).\n * This allows users to redeem promotional codes for in-app purchases and subscriptions.\n *\n * Note: This only works on real devices, not simulators.\n *\n * @returns The verified redeemed purchase when built with Xcode 27+ and\n * running on Apple 27+. Earlier iOS/visionOS system sheets return null;\n * Catalyst 16β26 surfaces StoreKitError.unknown, and Catalyst 15 is a no-op\n * that returns null.\n * @throws Error if called on non-iOS platform or tvOS\n *\n * @platform iOS\n *\n * @deprecated Use `openRedeemOfferCode` instead. Scheduled for removal in\n * client protocol 1.0.0.\n *\n * @see {@link https://openiap.dev/docs/apis/ios/present-code-redemption-sheet-ios}\n */\nexport const presentCodeRedemptionSheetIOS: MutationField<\n 'presentCodeRedemptionSheetIOS'\n> = async () => {\n requireIosPlatform('presentCodeRedemptionSheetIOS');\n return await ExpoIapModule.presentCodeRedemptionSheetIOS();\n};\n\n/**\n * Get app transaction information (iOS 16.0+).\n * AppTransaction represents the initial purchase that unlocked the app.\n *\n * NOTE: This function requires:\n * - iOS 16.0 or later at runtime\n * - Xcode 15.0+ with iOS 16.0 SDK for compilation\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 (await ExpoIapModule.getAppTransactionIOS()) ?? null;\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 ExpoIapModule.getPromotedProductIOS();\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 ExpoIapModule.getPendingTransactionsIOS();\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 ExpoIapModule.getAllTransactionsIOS();\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 ExpoIapModule.clearTransactionIOS());\n};\n\n/**\n * Deep link to subscriptions screen on iOS.\n * @returns {Promise<void>}\n *\n * @platform iOS\n */\nexport const deepLinkToSubscriptionsIOS = (): Promise<void> =>\n Linking.openURL('https://apps.apple.com/account/subscriptions');\n\n/**\n * Check if the device can present an external purchase notice sheet (iOS 17.4+).\n *\n * Wraps `ExternalPurchase.canPresent`, which Apple introduced in iOS 17.4.\n * Note: the notice sheet itself (`presentExternalPurchaseNoticeSheetIOS`)\n * still requires iOS 18.2+; only the eligibility check is available earlier.\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 ExpoIapModule.canPresentExternalPurchaseNoticeIOS());\n};\n\n/**\n * Present an external purchase notice sheet to inform users about external purchases (iOS 15.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 ExpoIapModule.presentExternalPurchaseNoticeSheetIOS();\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 ExpoIapModule.presentExternalPurchaseLinkIOS(url);\n return result as ExternalPurchaseLinkResultIOS;\n};\n\n/**\n * Check if app is eligible for ExternalPurchaseCustomLink API (iOS 18.1+).\n * Returns true if the app can use custom external purchase links.\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 ExpoIapModule.isEligibleForExternalPurchaseCustomLinkIOS());\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 =\n await ExpoIapModule.getExternalPurchaseCustomLinkTokenIOS(tokenType);\n return result as ExternalPurchaseCustomLinkTokenResultIOS;\n};\n\n/**\n * Show ExternalPurchaseCustomLink notice sheet (iOS 18.1+).\n * Displays the system disclosure notice sheet for custom external purchase links.\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 =\n await ExpoIapModule.showExternalPurchaseCustomLinkNoticeIOS(noticeType);\n return result as ExternalPurchaseCustomLinkNoticeResultIOS;\n};\n\n// iOS-specific APIs only; cross-platform wrappers live in src/index.ts\n"]}
|