expo-iap 5.8.1 → 5.8.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/README.md +13 -2
- package/android/openiap-store.gradle +18 -15
- package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +6 -0
- package/build/ExpoIapModule.d.ts +2 -0
- package/build/ExpoIapModule.d.ts.map +1 -1
- package/build/ExpoIapModule.js.map +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +9 -6
- package/build/index.js.map +1 -1
- package/build/utils/firstPurchaseNotice.d.ts +14 -0
- package/build/utils/firstPurchaseNotice.d.ts.map +1 -0
- package/build/utils/firstPurchaseNotice.js +42 -0
- package/build/utils/firstPurchaseNotice.js.map +1 -0
- package/build/vega-adapter.d.ts.map +1 -1
- package/build/vega-adapter.js +60 -36
- package/build/vega-adapter.js.map +1 -1
- package/bun.lock +7 -7
- package/ios/ExpoIapModule.swift +5 -0
- package/ios/onside/OnsideIapModule.swift +5 -0
- package/openiap-versions.json +3 -3
- package/osv-scanner.toml +14 -0
- package/package.json +16 -2
- package/plugin/build/logOnce.d.ts +1 -0
- package/plugin/build/logOnce.js +13 -0
- package/plugin/build/withIAP.d.ts +3 -5
- package/plugin/build/withIAP.js +76 -102
- package/plugin/build/withLocalOpenIAP.js +10 -20
- package/plugin/build/withVega.d.ts +1 -1
- package/plugin/build/withVega.js +17 -42
- package/plugin/src/expoConfig.augmentation.d.ts +14 -11
- package/plugin/src/logOnce.ts +9 -0
- package/plugin/src/withIAP.ts +77 -106
- package/plugin/src/withLocalOpenIAP.ts +2 -13
- package/plugin/src/withVega.ts +17 -41
- package/src/ExpoIapModule.ts +2 -0
- package/src/index.ts +7 -9
- package/src/utils/firstPurchaseNotice.ts +60 -0
- package/src/vega-adapter.ts +78 -36
package/README.md
CHANGED
|
@@ -79,10 +79,21 @@ Other libraries built on OpenIAP: [react-native-iap](https://github.com/hyodotde
|
|
|
79
79
|
|
|
80
80
|
## Community
|
|
81
81
|
|
|
82
|
-
Have a question or need help? Ask in [expo-iap Q&A Discussions](https://github.com/hyodotdev/openiap/discussions/categories/expo-iap).
|
|
83
|
-
|
|
84
82
|
For bug reports, please [open an issue](https://github.com/hyodotdev/openiap/issues).
|
|
85
83
|
|
|
84
|
+
<!-- community:start -->
|
|
85
|
+
<!-- Generated by scripts/sync-sponsors.mjs from packages/docs/community-touchpoints.json. -->
|
|
86
|
+
|
|
87
|
+
## Built something with expo-iap?
|
|
88
|
+
|
|
89
|
+
List your app on the [OpenIAP showcase](https://openiap.dev/showcase).
|
|
90
|
+
|
|
91
|
+
Questions and feedback go to [Discussions](https://github.com/hyodotdev/openiap/discussions).
|
|
92
|
+
|
|
93
|
+
If expo-iap saves you time, a ⭐ on [hyodotdev/openiap](https://github.com/hyodotdev/openiap) helps.
|
|
94
|
+
|
|
95
|
+
<!-- community:end -->
|
|
96
|
+
|
|
86
97
|
<!-- sponsors:start -->
|
|
87
98
|
<!-- Generated by scripts/sync-sponsors.mjs from packages/docs/sponsor-registry.json. -->
|
|
88
99
|
|
|
@@ -4,15 +4,16 @@
|
|
|
4
4
|
// where the library can build without a store SDK.
|
|
5
5
|
//
|
|
6
6
|
// First match wins:
|
|
7
|
-
// 1. explicit openiapStore=<store> (-P, ORG_GRADLE_PROJECT_openiapStore, gradle.properties)
|
|
8
|
-
// The legacy horizonEnabled
|
|
7
|
+
// 1. explicit openiapStore=<store> (-P, ORG_GRADLE_PROJECT_openiapStore, gradle.properties),
|
|
8
|
+
// or fireOsEnabled=true. The legacy horizonEnabled and openiapPlatform=none
|
|
9
|
+
// still pin until the next major release.
|
|
9
10
|
// 2. variant a requested task names a store flavor (assembleHorizonRelease).
|
|
10
11
|
// 3. device debug builds only: the Quest or Fire device that ANDROID_SERIAL
|
|
11
12
|
// names, or the only one connected.
|
|
12
13
|
// 4. play
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// once the
|
|
14
|
+
// A pin and a task flavor naming different stores fail the build; the device is
|
|
15
|
+
// read only when neither is set. Only spelled-out task names are read; a task that
|
|
16
|
+
// builds another store (an abbreviation such as aHR) fails once the graph is ready.
|
|
16
17
|
|
|
17
18
|
ext.openIapStoreAliases = [
|
|
18
19
|
play: 'play', google: 'play', gplay: 'play', googleplay: 'play', 'google-play': 'play', gms: 'play',
|
|
@@ -57,13 +58,15 @@ ext.openIapExplicitStore = { String label, boolean allowNone ->
|
|
|
57
58
|
throw new GradleException("${label}: horizonEnabled and fireOsEnabled cannot both be true")
|
|
58
59
|
}
|
|
59
60
|
if (platform == 'none' && (horizon || fireOs)) {
|
|
60
|
-
throw new GradleException("${label}: openiapPlatform=none conflicts with
|
|
61
|
+
throw new GradleException("${label}: openiapPlatform=none conflicts with ${fireOs ? 'fireOsEnabled' : 'horizonEnabled'}=true")
|
|
61
62
|
}
|
|
62
63
|
def (legacyKey, legacy) = platform == 'none' ? ['openiapPlatform=none', 'none']
|
|
63
64
|
: fireOs ? ['fireOsEnabled=true', 'amazon']
|
|
64
65
|
: horizon ? ['horizonEnabled=true', 'horizon'] : [null, null]
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
// fireOsEnabled=true is a supported Fire OS declaration, so it does not warn.
|
|
67
|
+
if (legacy != null && !fireOs) {
|
|
68
|
+
// Quiet, like every openiap line here: Flutter runs Gradle with -q.
|
|
69
|
+
logger.quiet("${label}: ${legacyKey} is deprecated and will be removed in the next major release; use openiapStore=${legacy}")
|
|
67
70
|
}
|
|
68
71
|
def pin = explicit == 'auto' ? null : explicit
|
|
69
72
|
if (pin != null && legacy != null && legacy != pin) {
|
|
@@ -125,7 +128,7 @@ ext.openIapTaskStore = { String label ->
|
|
|
125
128
|
.findAll { it in ['play', 'horizon', 'amazon'] } as LinkedHashSet
|
|
126
129
|
// Two stores in one build: refuse rather than guess.
|
|
127
130
|
if (named.size() > 1) {
|
|
128
|
-
throw new GradleException("${label}:
|
|
131
|
+
throw new GradleException("${label}: the requested tasks '${openIapRequestedTasks().join(' ')}' name more than one store (${named.join(', ')}); build one store per invocation")
|
|
129
132
|
}
|
|
130
133
|
return named ? named.first() : null
|
|
131
134
|
}
|
|
@@ -210,12 +213,12 @@ ext.openIapVerifyTaskGraph = { String label, Map resolution ->
|
|
|
210
213
|
if (!named) {
|
|
211
214
|
// The store came from something that is not a task, such as an option's value.
|
|
212
215
|
if (resolution.source == 'variant') {
|
|
213
|
-
throw new GradleException("${label}: read ${resolved} from '${openIapRequestedTasks().join(' ')}', but no task it runs names a store;
|
|
216
|
+
throw new GradleException("${label}: read ${resolved} from '${openIapRequestedTasks().join(' ')}', but no task it runs names a store; pass option values inline (--name=value)")
|
|
214
217
|
}
|
|
215
218
|
return
|
|
216
219
|
}
|
|
217
220
|
if (named.size() > 1) {
|
|
218
|
-
throw new GradleException("${label}: the requested tasks build more than one store (${named.join(', ')}) but a build links one; build one store per invocation
|
|
221
|
+
throw new GradleException("${label}: the requested tasks build more than one store (${named.join(', ')}) but a build links one; build one store per invocation")
|
|
219
222
|
}
|
|
220
223
|
def actual = named.first()
|
|
221
224
|
if (actual != resolved) {
|
|
@@ -297,7 +300,7 @@ ext.openIapDeviceStore = {
|
|
|
297
300
|
def serial
|
|
298
301
|
if (requested) {
|
|
299
302
|
if (!serials.contains(requested)) {
|
|
300
|
-
logger.
|
|
303
|
+
logger.quiet("openiap: ANDROID_SERIAL=${requested} is not attached; not selecting a store from a device")
|
|
301
304
|
return null
|
|
302
305
|
}
|
|
303
306
|
serial = requested
|
|
@@ -310,7 +313,7 @@ ext.openIapDeviceStore = {
|
|
|
310
313
|
def manufacturerText = openIapAdbText([adb, '-s', serial, 'shell', 'getprop', 'ro.product.manufacturer'])
|
|
311
314
|
// A device that dropped after the listing answers with nothing; that is not Play.
|
|
312
315
|
if (!features?.trim() && !manufacturerText?.trim()) {
|
|
313
|
-
logger.
|
|
316
|
+
logger.quiet("openiap: ${serial} stopped responding; not selecting a store from a device")
|
|
314
317
|
return null
|
|
315
318
|
}
|
|
316
319
|
features = features ?: ''
|
|
@@ -346,7 +349,7 @@ ext.openIapResolveStore = { String label, Map options = [:] ->
|
|
|
346
349
|
}
|
|
347
350
|
def resolution = null
|
|
348
351
|
if (explicit != null) {
|
|
349
|
-
resolution = [store: explicit, source: 'explicit', reason: 'openiapStore or a
|
|
352
|
+
resolution = [store: explicit, source: 'explicit', reason: 'openiapStore or a store flag']
|
|
350
353
|
} else if (variant != null) {
|
|
351
354
|
resolution = [store: variant, source: 'variant', reason: "task ${openIapRequestedTasks().join(' ')}"]
|
|
352
355
|
} else if (openIapDebugBuild()) {
|
|
@@ -359,7 +362,7 @@ ext.openIapResolveStore = { String label, Map options = [:] ->
|
|
|
359
362
|
resolution = [store: 'play', source: 'default', reason: 'no store signal']
|
|
360
363
|
}
|
|
361
364
|
rootProject.ext.openIapStoreResolution = resolution
|
|
362
|
-
logger.
|
|
365
|
+
logger.quiet("openiap: store=${resolution.store} (source=${resolution.source}; ${resolution.reason})")
|
|
363
366
|
openIapVerifyTaskGraph(label, resolution)
|
|
364
367
|
return resolution
|
|
365
368
|
}
|
|
@@ -23,6 +23,7 @@ import dev.hyo.openiap.VerifyPurchaseGoogleOptions
|
|
|
23
23
|
import dev.hyo.openiap.VerifyPurchaseHorizonOptions
|
|
24
24
|
import dev.hyo.openiap.VerifyPurchaseProps
|
|
25
25
|
import dev.hyo.openiap.VerifyPurchaseWithProviderProps
|
|
26
|
+
import dev.hyo.openiap.helpers.OpenIapFirstPurchaseNotice
|
|
26
27
|
import dev.hyo.openiap.store.OpenIapStore
|
|
27
28
|
import expo.modules.kotlin.Promise
|
|
28
29
|
import expo.modules.kotlin.exception.Exceptions
|
|
@@ -519,6 +520,11 @@ class ExpoIapModule : Module() {
|
|
|
519
520
|
}
|
|
520
521
|
}
|
|
521
522
|
|
|
523
|
+
// Internal: backs the JS first-purchase notice; not app API.
|
|
524
|
+
AsyncFunction("claimFirstPurchaseNotice") {
|
|
525
|
+
OpenIapFirstPurchaseNotice.claim(context)
|
|
526
|
+
}
|
|
527
|
+
|
|
522
528
|
AsyncFunction("verifyPurchase") { params: Map<String, Any?>, promise: Promise ->
|
|
523
529
|
ExpoIapLog.payload(
|
|
524
530
|
"verifyPurchase",
|
package/build/ExpoIapModule.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export type ExpoIapNativeModule = NativeEventModule & QueryFields<'canPresentExt
|
|
|
32
32
|
showManageSubscriptionsIOS(): Promise<unknown>;
|
|
33
33
|
requestPurchase(request: object): Promise<unknown>;
|
|
34
34
|
finishTransaction(purchase: PurchaseInput, isConsumable: boolean | null): Promise<boolean>;
|
|
35
|
+
/** Internal: the once-per-install flag behind the first-purchase notice. */
|
|
36
|
+
claimFirstPurchaseNotice(): Promise<boolean>;
|
|
35
37
|
acknowledgePurchaseAndroid(purchaseToken: string): Promise<unknown>;
|
|
36
38
|
consumePurchaseAndroid(purchaseToken: string): Promise<unknown>;
|
|
37
39
|
createBillingProgramReportingDetailsAndroid(program: BillingProgramAndroid, developerBillingType: DeveloperBillingTypeAndroid | null): Promise<BillingProgramReportingDetailsAndroid>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoIapModule.d.ts","sourceRoot":"","sources":["../src/ExpoIapModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EACV,qBAAqB,EACrB,qCAAqC,EACrC,2BAA2B,EAC3B,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,8BAA8B,EAC9B,KAAK,EACL,UAAU,EACV,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAMjB,0EAA0E;AAC1E,KAAK,iBAAiB,GAAG;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,WAAW,CAAC,CAAC,EACX,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IA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n UnavailabilityError,\n type EventSubscription,\n} from 'expo-modules-core';\nimport {installedFromOnside} from './onside';\nimport type {\n BillingProgramAndroid,\n BillingProgramReportingDetailsAndroid,\n DeveloperBillingTypeAndroid,\n Mutation,\n MutationField,\n ProductQueryType,\n PurchaseInput,\n PurchaseOptions,\n PurchaseUpdatedListenerOptions,\n Query,\n QueryField,\n SubscriptionStatusIOS,\n} from './types';\nimport {getVegaIapModule, isVegaOS} from './vega';\n\ntype NativeIapModuleName = 'ExpoIapVega' | 'ExpoIapOnside' | 'ExpoIap';\nconst ONSIDE_MARKETPLACE_ID = 'com.onside.marketplace-app';\n\n/** Members read from the raw module; every store module provides them. */\ntype NativeEventModule = {\n ERROR_CODES?: Record<string, unknown>;\n addListener<T>(\n eventName: string,\n listener: (payload: T) => void,\n ): EventSubscription | undefined;\n removeListener?<T>(eventName: string, listener: (payload: T) => void): void;\n setPurchaseUpdatedListenerOptions?(\n options?: PurchaseUpdatedListenerOptions | null,\n ): Promise<void>;\n};\n\ntype QueryFields<K extends keyof Query> = {[P in K]: QueryField<P>};\ntype MutationFields<K extends keyof Mutation> = {[P in K]: MutationField<P>};\n\n/**\n * Native surface behind the default export. Results the wrappers decode stay\n * `unknown`; the rest match the generated operation signatures.\n */\nexport type ExpoIapNativeModule = NativeEventModule &\n QueryFields<\n | 'canPresentExternalPurchaseNoticeIOS'\n | 'currentEntitlementIOS'\n | 'getActiveSubscriptions'\n | 'getAppTransactionIOS'\n | 'getBillingChoiceInfoAndroid'\n | 'getExternalPurchaseCustomLinkTokenIOS'\n | 'getPromotedProductIOS'\n | 'getReceiptDataIOS'\n | 'getTransactionJwsIOS'\n | 'hasActiveSubscriptions'\n | 'isEligibleForExternalPurchaseCustomLinkIOS'\n | 'isEligibleForIntroOfferIOS'\n | 'isTransactionVerifiedIOS'\n | 'latestTransactionIOS'\n > &\n MutationFields<\n | 'beginRefundRequestIOS'\n | 'clearTransactionIOS'\n | 'endConnection'\n | 'initConnection'\n | 'isBillingProgramAvailableAndroid'\n | 'launchExternalLinkAndroid'\n | 'openRedeemOfferCodeAndroid'\n | 'presentCodeRedemptionSheetIOS'\n | 'presentExternalPurchaseLinkIOS'\n | 'presentExternalPurchaseNoticeSheetIOS'\n | 'showBillingProgramInformationDialogAndroid'\n | 'showExternalPurchaseCustomLinkNoticeIOS'\n | 'showInAppMessagesAndroid'\n | 'syncIOS'\n | 'verifyPurchase'\n | 'verifyPurchaseWithProvider'\n > & {\n USING_ONSIDE_SDK: boolean;\n USING_VEGA_SDK: boolean;\n fetchProducts(request: {\n skus: string[];\n type: ProductQueryType;\n }): Promise<unknown[]>;\n fetchProducts(type: ProductQueryType, skus: string[]): Promise<unknown[]>;\n getAvailableItems(\n alsoPublishToEventListenerIOS: boolean,\n onlyIncludeActiveItemsIOS: boolean,\n ): Promise<unknown>;\n getAvailableItems(options: PurchaseOptions): Promise<unknown>;\n getAllTransactionsIOS(): Promise<unknown>;\n getPendingTransactionsIOS(): Promise<unknown>;\n showManageSubscriptionsIOS(): Promise<unknown>;\n requestPurchase(request: object): Promise<unknown>;\n finishTransaction(\n purchase: PurchaseInput,\n isConsumable: boolean | null,\n ): Promise<boolean>;\n acknowledgePurchaseAndroid(purchaseToken: string): Promise<unknown>;\n consumePurchaseAndroid(purchaseToken: string): Promise<unknown>;\n createBillingProgramReportingDetailsAndroid(\n program: BillingProgramAndroid,\n developerBillingType: DeveloperBillingTypeAndroid | null,\n ): Promise<BillingProgramReportingDetailsAndroid>;\n subscriptionStatusIOS(sku: string): Promise<SubscriptionStatusIOS[] | null>;\n requestReceiptRefreshIOS(): Promise<string>;\n deepLinkToSubscriptionsAndroid?(options: {\n skuAndroid?: string;\n packageNameAndroid?: string;\n }): Promise<void> | void;\n getStorefront?(): Promise<string> | string;\n restorePurchases?(): Promise<boolean>;\n };\n\ntype ResolvedNativeModule = {\n module: NativeEventModule;\n name: NativeIapModuleName;\n};\n\nlet cached: ResolvedNativeModule | null = null;\nlet onsideModuleUnavailable = false;\n\nfunction getResolved(): ResolvedNativeModule {\n function shouldUseOnsideModule(): boolean {\n if (installedFromOnside === true) {\n return true;\n }\n\n if (typeof installedFromOnside !== 'string') {\n return false;\n }\n\n const normalized = installedFromOnside.trim().toLowerCase();\n return normalized === 'true' || normalized === ONSIDE_MARKETPLACE_ID;\n }\n\n function getExpectedModuleName(): NativeIapModuleName {\n if (isVegaOS()) {\n return 'ExpoIapVega';\n }\n\n return shouldUseOnsideModule() ? 'ExpoIapOnside' : 'ExpoIap';\n }\n\n function resolveNativeModule(): ResolvedNativeModule {\n if (isVegaOS()) {\n const vegaModule = getVegaIapModule();\n if (!vegaModule) {\n throw new UnavailabilityError(\n 'expo-iap',\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: vegaModule, name: 'ExpoIapVega'};\n }\n\n if (shouldUseOnsideModule()) {\n if (onsideModuleUnavailable) {\n throw new UnavailabilityError(\n 'expo-iap',\n 'The Onside marketplace build does not contain ExpoIapOnside. Rebuild with ios.onside.enabled instead of routing purchases through Apple StoreKit.',\n );\n }\n try {\n return {\n module: requireNativeModule<NativeEventModule>('ExpoIapOnside'),\n name: 'ExpoIapOnside',\n };\n } catch (error) {\n if (!isMissingModuleError(error, 'ExpoIapOnside')) {\n throw error;\n }\n onsideModuleUnavailable = true;\n throw new UnavailabilityError(\n 'expo-iap',\n 'The Onside marketplace build does not contain ExpoIapOnside. Rebuild with ios.onside.enabled instead of routing purchases through Apple StoreKit.',\n );\n }\n }\n\n return {\n module: requireNativeModule<NativeEventModule>('ExpoIap'),\n name: 'ExpoIap',\n };\n }\n\n const expectedName = getExpectedModuleName();\n if (!cached || cached.name !== expectedName) {\n cached = resolveNativeModule();\n }\n return cached;\n}\n\nfunction isMissingModuleError(error: unknown, moduleName: string): boolean {\n if (error instanceof UnavailabilityError) {\n return true;\n }\n\n if (error instanceof Error) {\n return error.message.includes(`Cannot find native module '${moduleName}'`);\n }\n\n return false;\n}\n\nexport const NATIVE_ERROR_CODES: Record<string, unknown> = new Proxy(\n {} as Record<string, unknown>,\n {\n get(target, prop) {\n if (typeof prop === 'symbol') return Reflect.get(target, prop);\n const errorCodes: Record<string, unknown> =\n getResolved().module.ERROR_CODES || {};\n return errorCodes[prop];\n },\n },\n);\n\n/**\n * Returns the raw native module, not the Proxy. Use it for addListener: a JSI\n * HostObject needs the real module as `this`, and a Proxy throws \"native state\n * unsupported on Proxy\" on New Architecture / Hermes.\n */\nexport function getNativeModule(): NativeEventModule {\n return getResolved().module;\n}\n\n// The Proxy forwards every member to the lazily resolved store module.\nexport default new Proxy({} as ExpoIapNativeModule, {\n get(target, prop) {\n if (typeof prop === 'symbol') return Reflect.get(target, prop);\n const resolved = getResolved();\n if (prop === 'USING_ONSIDE_SDK') {\n return resolved.name === 'ExpoIapOnside';\n }\n if (prop === 'USING_VEGA_SDK') {\n return resolved.name === 'ExpoIapVega';\n }\n\n const value: unknown = Reflect.get(resolved.module, prop);\n if (value !== undefined || resolved.name !== 'ExpoIapOnside') {\n return value;\n }\n\n return () => {\n throw new UnavailabilityError(\n 'expo-iap',\n `The Onside marketplace does not support ${String(\n prop,\n )}. The call was not routed through Apple StoreKit.`,\n );\n };\n },\n});\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoIapModule.js","sourceRoot":"","sources":["../src/ExpoIapModule.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GAEpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAC;AAe7C,OAAO,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAGlD,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAoG3D,IAAI,MAAM,GAAgC,IAAI,CAAC;AAC/C,IAAI,uBAAuB,GAAG,KAAK,CAAC;AAEpC,SAAS,WAAW;IAClB,SAAS,qBAAqB;QAC5B,IAAI,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AAE,IAAI;QACd,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC/D,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;QAC/B,IAAI,IAAI,KAAK,kBAAkB,EAAE,CAAC;YAChC,OAAO,QAAQ,CAAC,IAAI,KAAK,eAAe,CAAC;QAC3C,CAAC;QACD,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;YAC9B,OAAO,QAAQ,CAAC,IAAI,KAAK,aAAa,CAAC;QACzC,CAAC;QAED,MAAM,KAAK,GAAY,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC1D,IAAI,KAAK,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;YAC7D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,GAAG,EAAE;YACV,MAAM,IAAI,mBAAmB,CAC3B,UAAU,EACV,2CAA2C,MAAM,CAC/C,IAAI,CACL,mDAAmD,CACrD,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {\n requireNativeModule,\n UnavailabilityError,\n type EventSubscription,\n} from 'expo-modules-core';\nimport {installedFromOnside} from './onside';\nimport type {\n BillingProgramAndroid,\n BillingProgramReportingDetailsAndroid,\n DeveloperBillingTypeAndroid,\n Mutation,\n MutationField,\n ProductQueryType,\n PurchaseInput,\n PurchaseOptions,\n PurchaseUpdatedListenerOptions,\n Query,\n QueryField,\n SubscriptionStatusIOS,\n} from './types';\nimport {getVegaIapModule, isVegaOS} from './vega';\n\ntype NativeIapModuleName = 'ExpoIapVega' | 'ExpoIapOnside' | 'ExpoIap';\nconst ONSIDE_MARKETPLACE_ID = 'com.onside.marketplace-app';\n\n/** Members read from the raw module; every store module provides them. */\ntype NativeEventModule = {\n ERROR_CODES?: Record<string, unknown>;\n addListener<T>(\n eventName: string,\n listener: (payload: T) => void,\n ): EventSubscription | undefined;\n removeListener?<T>(eventName: string, listener: (payload: T) => void): void;\n setPurchaseUpdatedListenerOptions?(\n options?: PurchaseUpdatedListenerOptions | null,\n ): Promise<void>;\n};\n\ntype QueryFields<K extends keyof Query> = {[P in K]: QueryField<P>};\ntype MutationFields<K extends keyof Mutation> = {[P in K]: MutationField<P>};\n\n/**\n * Native surface behind the default export. Results the wrappers decode stay\n * `unknown`; the rest match the generated operation signatures.\n */\nexport type ExpoIapNativeModule = NativeEventModule &\n QueryFields<\n | 'canPresentExternalPurchaseNoticeIOS'\n | 'currentEntitlementIOS'\n | 'getActiveSubscriptions'\n | 'getAppTransactionIOS'\n | 'getBillingChoiceInfoAndroid'\n | 'getExternalPurchaseCustomLinkTokenIOS'\n | 'getPromotedProductIOS'\n | 'getReceiptDataIOS'\n | 'getTransactionJwsIOS'\n | 'hasActiveSubscriptions'\n | 'isEligibleForExternalPurchaseCustomLinkIOS'\n | 'isEligibleForIntroOfferIOS'\n | 'isTransactionVerifiedIOS'\n | 'latestTransactionIOS'\n > &\n MutationFields<\n | 'beginRefundRequestIOS'\n | 'clearTransactionIOS'\n | 'endConnection'\n | 'initConnection'\n | 'isBillingProgramAvailableAndroid'\n | 'launchExternalLinkAndroid'\n | 'openRedeemOfferCodeAndroid'\n | 'presentCodeRedemptionSheetIOS'\n | 'presentExternalPurchaseLinkIOS'\n | 'presentExternalPurchaseNoticeSheetIOS'\n | 'showBillingProgramInformationDialogAndroid'\n | 'showExternalPurchaseCustomLinkNoticeIOS'\n | 'showInAppMessagesAndroid'\n | 'syncIOS'\n | 'verifyPurchase'\n | 'verifyPurchaseWithProvider'\n > & {\n USING_ONSIDE_SDK: boolean;\n USING_VEGA_SDK: boolean;\n fetchProducts(request: {\n skus: string[];\n type: ProductQueryType;\n }): Promise<unknown[]>;\n fetchProducts(type: ProductQueryType, skus: string[]): Promise<unknown[]>;\n getAvailableItems(\n alsoPublishToEventListenerIOS: boolean,\n onlyIncludeActiveItemsIOS: boolean,\n ): Promise<unknown>;\n getAvailableItems(options: PurchaseOptions): Promise<unknown>;\n getAllTransactionsIOS(): Promise<unknown>;\n getPendingTransactionsIOS(): Promise<unknown>;\n showManageSubscriptionsIOS(): Promise<unknown>;\n requestPurchase(request: object): Promise<unknown>;\n finishTransaction(\n purchase: PurchaseInput,\n isConsumable: boolean | null,\n ): Promise<boolean>;\n /** Internal: the once-per-install flag behind the first-purchase notice. */\n claimFirstPurchaseNotice(): Promise<boolean>;\n acknowledgePurchaseAndroid(purchaseToken: string): Promise<unknown>;\n consumePurchaseAndroid(purchaseToken: string): Promise<unknown>;\n createBillingProgramReportingDetailsAndroid(\n program: BillingProgramAndroid,\n developerBillingType: DeveloperBillingTypeAndroid | null,\n ): Promise<BillingProgramReportingDetailsAndroid>;\n subscriptionStatusIOS(sku: string): Promise<SubscriptionStatusIOS[] | null>;\n requestReceiptRefreshIOS(): Promise<string>;\n deepLinkToSubscriptionsAndroid?(options: {\n skuAndroid?: string;\n packageNameAndroid?: string;\n }): Promise<void> | void;\n getStorefront?(): Promise<string> | string;\n restorePurchases?(): Promise<boolean>;\n };\n\ntype ResolvedNativeModule = {\n module: NativeEventModule;\n name: NativeIapModuleName;\n};\n\nlet cached: ResolvedNativeModule | null = null;\nlet onsideModuleUnavailable = false;\n\nfunction getResolved(): ResolvedNativeModule {\n function shouldUseOnsideModule(): boolean {\n if (installedFromOnside === true) {\n return true;\n }\n\n if (typeof installedFromOnside !== 'string') {\n return false;\n }\n\n const normalized = installedFromOnside.trim().toLowerCase();\n return normalized === 'true' || normalized === ONSIDE_MARKETPLACE_ID;\n }\n\n function getExpectedModuleName(): NativeIapModuleName {\n if (isVegaOS()) {\n return 'ExpoIapVega';\n }\n\n return shouldUseOnsideModule() ? 'ExpoIapOnside' : 'ExpoIap';\n }\n\n function resolveNativeModule(): ResolvedNativeModule {\n if (isVegaOS()) {\n const vegaModule = getVegaIapModule();\n if (!vegaModule) {\n throw new UnavailabilityError(\n 'expo-iap',\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: vegaModule, name: 'ExpoIapVega'};\n }\n\n if (shouldUseOnsideModule()) {\n if (onsideModuleUnavailable) {\n throw new UnavailabilityError(\n 'expo-iap',\n 'The Onside marketplace build does not contain ExpoIapOnside. Rebuild with ios.onside.enabled instead of routing purchases through Apple StoreKit.',\n );\n }\n try {\n return {\n module: requireNativeModule<NativeEventModule>('ExpoIapOnside'),\n name: 'ExpoIapOnside',\n };\n } catch (error) {\n if (!isMissingModuleError(error, 'ExpoIapOnside')) {\n throw error;\n }\n onsideModuleUnavailable = true;\n throw new UnavailabilityError(\n 'expo-iap',\n 'The Onside marketplace build does not contain ExpoIapOnside. Rebuild with ios.onside.enabled instead of routing purchases through Apple StoreKit.',\n );\n }\n }\n\n return {\n module: requireNativeModule<NativeEventModule>('ExpoIap'),\n name: 'ExpoIap',\n };\n }\n\n const expectedName = getExpectedModuleName();\n if (!cached || cached.name !== expectedName) {\n cached = resolveNativeModule();\n }\n return cached;\n}\n\nfunction isMissingModuleError(error: unknown, moduleName: string): boolean {\n if (error instanceof UnavailabilityError) {\n return true;\n }\n\n if (error instanceof Error) {\n return error.message.includes(`Cannot find native module '${moduleName}'`);\n }\n\n return false;\n}\n\nexport const NATIVE_ERROR_CODES: Record<string, unknown> = new Proxy(\n {} as Record<string, unknown>,\n {\n get(target, prop) {\n if (typeof prop === 'symbol') return Reflect.get(target, prop);\n const errorCodes: Record<string, unknown> =\n getResolved().module.ERROR_CODES || {};\n return errorCodes[prop];\n },\n },\n);\n\n/**\n * Returns the raw native module, not the Proxy. Use it for addListener: a JSI\n * HostObject needs the real module as `this`, and a Proxy throws \"native state\n * unsupported on Proxy\" on New Architecture / Hermes.\n */\nexport function getNativeModule(): NativeEventModule {\n return getResolved().module;\n}\n\n// The Proxy forwards every member to the lazily resolved store module.\nexport default new Proxy({} as ExpoIapNativeModule, {\n get(target, prop) {\n if (typeof prop === 'symbol') return Reflect.get(target, prop);\n const resolved = getResolved();\n if (prop === 'USING_ONSIDE_SDK') {\n return resolved.name === 'ExpoIapOnside';\n }\n if (prop === 'USING_VEGA_SDK') {\n return resolved.name === 'ExpoIapVega';\n }\n\n const value: unknown = Reflect.get(resolved.module, prop);\n if (value !== undefined || resolved.name !== 'ExpoIapOnside') {\n return value;\n }\n\n return () => {\n throw new UnavailabilityError(\n 'expo-iap',\n `The Onside marketplace does not support ${String(\n prop,\n )}. The call was not routed through Apple StoreKit.`,\n );\n };\n },\n});\n"]}
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAGV,sCAAsC,EAEtC,aAAa,EAEb,OAAO,EACP,gBAAgB,EAEhB,QAAQ,EAER,8BAA8B,EAC9B,UAAU,EAOV,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAIL,KAAK,aAAa,EAEnB,MAAM,sBAAsB,CAAC;AAE9B,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AAEvB,oBAAY,YAAY;IACtB,eAAe,qBAAqB;IACpC,aAAa,mBAAmB;IAChC,kBAAkB,yBAAyB;IAC3C,wBAAwB,gCAAgC;IACxD;;;OAGG;IACH,+BAA+B,uCAAuC;IACtE,sGAAsG;IACtG,wBAAwB,+BAA+B;CACxD;AAED,KAAK,oBAAoB,GAAG;IAC1B,CAAC,YAAY,CAAC,eAAe,CAAC,EAAE,QAAQ,CAAC;IACzC,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE,aAA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ToSubscriptionsIOS, presentCodeRedemptionSheetIOS, } from './modules/ios';
|
|
7
7
|
import { isProductAndroid, deepLinkToSubscriptionsAndroid, openRedeemOfferCodeAndroid, } from './modules/android';
|
|
8
8
|
import { ExpoIapConsole } from './utils/debug';
|
|
9
|
+
import { showFirstPurchaseNotice } from './utils/firstPurchaseNotice';
|
|
9
10
|
import { restorePurchasesIOSNative } from './utils/restorePurchases';
|
|
10
11
|
import { decodeAndroidPurchases, decodeApplePurchases, } from './utils/availablePurchases';
|
|
11
12
|
import { ErrorCode } from './types';
|
|
@@ -838,9 +839,8 @@ export const requestPurchase = async (args) => {
|
|
|
838
839
|
export const finishTransaction = async ({ purchase, isConsumable = false, }) => {
|
|
839
840
|
if (Platform.OS === 'ios') {
|
|
840
841
|
await ExpoIapModule.finishTransaction(purchase, isConsumable);
|
|
841
|
-
return;
|
|
842
842
|
}
|
|
843
|
-
if (isAndroidStoreRuntime()) {
|
|
843
|
+
else if (isAndroidStoreRuntime()) {
|
|
844
844
|
const token = purchase.purchaseToken ?? undefined;
|
|
845
845
|
if (!token) {
|
|
846
846
|
throw createPurchaseError({
|
|
@@ -852,12 +852,15 @@ export const finishTransaction = async ({ purchase, isConsumable = false, }) =>
|
|
|
852
852
|
}
|
|
853
853
|
if (isConsumable) {
|
|
854
854
|
await ExpoIapModule.consumePurchaseAndroid(token);
|
|
855
|
-
return;
|
|
856
855
|
}
|
|
857
|
-
|
|
858
|
-
|
|
856
|
+
else {
|
|
857
|
+
await ExpoIapModule.acknowledgePurchaseAndroid(token);
|
|
858
|
+
}
|
|
859
859
|
}
|
|
860
|
-
|
|
860
|
+
else {
|
|
861
|
+
throw unsupportedPlatformError();
|
|
862
|
+
}
|
|
863
|
+
showFirstPurchaseNotice(purchase);
|
|
861
864
|
};
|
|
862
865
|
/**
|
|
863
866
|
* Restore completed transactions. Returns nothing; read the restored items with
|