expo-iap 4.3.1 → 4.4.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +14 -10
- package/android/src/main/java/expo/modules/iap/ExpoIapLog.kt +8 -1
- package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +9 -2
- package/build/ExpoIapModule.d.ts.map +1 -1
- package/build/ExpoIapModule.js +63 -49
- package/build/ExpoIapModule.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +13 -4
- package/build/index.js.map +1 -1
- package/build/kit-api.d.ts +1 -1
- package/build/kit-api.d.ts.map +1 -1
- package/build/kit-api.js +15 -15
- package/build/kit-api.js.map +1 -1
- package/build/types.d.ts +16 -3
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/build/useIAP.d.ts.map +1 -1
- package/build/useIAP.js +4 -1
- package/build/useIAP.js.map +1 -1
- package/build/vega-adapter.d.ts +90 -0
- package/build/vega-adapter.d.ts.map +1 -0
- package/build/vega-adapter.js +599 -0
- package/build/vega-adapter.js.map +1 -0
- package/build/vega.d.ts +4 -0
- package/build/vega.d.ts.map +1 -0
- package/build/vega.js +8 -0
- package/build/vega.js.map +1 -0
- package/build/vega.kepler.d.ts +4 -0
- package/build/vega.kepler.d.ts.map +1 -0
- package/build/vega.kepler.js +17 -0
- package/build/vega.kepler.js.map +1 -0
- package/build/webhook-client.d.ts +8 -8
- package/build/webhook-client.d.ts.map +1 -1
- package/build/webhook-client.js +43 -43
- package/build/webhook-client.js.map +1 -1
- package/bun.lock +6 -0
- package/ios/ExpoIapLog.swift +8 -1
- package/ios/ExpoIapModule.swift +7 -1
- package/ios/expoiap.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/expoiap.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/package.json +11 -1
- package/plugin/build/withIAP.d.ts +32 -3
- package/plugin/build/withIAP.js +145 -78
- package/plugin/build/withLocalOpenIAP.d.ts +4 -1
- package/plugin/build/withLocalOpenIAP.js +20 -8
- package/plugin/src/expoConfig.augmentation.d.ts +18 -6
- package/plugin/src/withIAP.ts +234 -107
- package/plugin/src/withIosAlternativeBilling.ts +5 -15
- package/plugin/src/withLocalOpenIAP.ts +26 -9
- package/src/ExpoIapModule.ts +73 -54
- package/src/amazon-devices-kepler.d.ts +12 -0
- package/src/index.ts +16 -7
- package/src/kit-api.ts +23 -27
- package/src/types.ts +17 -3
- package/src/useIAP.ts +6 -1
- package/src/vega-adapter.ts +911 -0
- package/src/vega.kepler.ts +24 -0
- package/src/vega.ts +10 -0
- package/src/webhook-client.ts +72 -74
- package/openiap-versions.json +0 -5
- package/plugin/tsconfig.tsbuildinfo +0 -1
package/android/build.gradle
CHANGED
|
@@ -50,6 +50,13 @@ if (!(googleVersion instanceof String) || !googleVersion.trim()) {
|
|
|
50
50
|
def googleVersionString = googleVersion.trim()
|
|
51
51
|
apply from: project.file('openiap-android-sdk.gradle')
|
|
52
52
|
|
|
53
|
+
def horizonEnabled = project.findProperty('horizonEnabled')?.toBoolean() ?: false
|
|
54
|
+
def fireOsEnabled = project.findProperty('fireOsEnabled')?.toBoolean() ?: false
|
|
55
|
+
if (horizonEnabled && fireOsEnabled) {
|
|
56
|
+
throw new GradleException("expo-iap: horizonEnabled and fireOsEnabled cannot both be true")
|
|
57
|
+
}
|
|
58
|
+
def openiapFlavor = fireOsEnabled ? 'amazon' : (horizonEnabled ? 'horizon' : 'play')
|
|
59
|
+
|
|
53
60
|
// If you want to use the managed Android SDK versions from expo-modules-core, set this to true.
|
|
54
61
|
// The Android SDK versions will be bumped from time to time in SDK releases and may introduce breaking changes in your module code.
|
|
55
62
|
// Most of the time, you may like to manage the Android SDK versions yourself.
|
|
@@ -76,17 +83,14 @@ android {
|
|
|
76
83
|
versionCode = 1
|
|
77
84
|
versionName = expoIapPackageVersion
|
|
78
85
|
// When using local openiap-google with flavors, select the appropriate flavor
|
|
79
|
-
|
|
80
|
-
def horizonEnabled = project.findProperty('horizonEnabled')?.toBoolean() ?: false
|
|
81
|
-
def flavor = horizonEnabled ? 'horizon' : 'play'
|
|
82
|
-
missingDimensionStrategy "platform", flavor
|
|
86
|
+
missingDimensionStrategy "platform", openiapFlavor
|
|
83
87
|
}
|
|
84
|
-
|
|
88
|
+
lint {
|
|
85
89
|
abortOnError = false
|
|
86
90
|
}
|
|
87
91
|
compileOptions {
|
|
88
|
-
sourceCompatibility JavaVersion.VERSION_17
|
|
89
|
-
targetCompatibility JavaVersion.VERSION_17
|
|
92
|
+
sourceCompatibility = JavaVersion.VERSION_17
|
|
93
|
+
targetCompatibility = JavaVersion.VERSION_17
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
|
|
@@ -100,12 +104,12 @@ kotlin {
|
|
|
100
104
|
dependencies {
|
|
101
105
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
|
|
102
106
|
|
|
103
|
-
// Determine which OpenIAP dependency to use based on horizonEnabled flag
|
|
104
|
-
def horizonEnabled = project.findProperty('horizonEnabled')?.toBoolean() ?: false
|
|
105
|
-
|
|
106
107
|
// Use OpenIAP Google module only; avoid direct BillingClient dependency
|
|
107
108
|
if (findProject(":openiap-google") != null) {
|
|
108
109
|
implementation project(":openiap-google")
|
|
110
|
+
} else if (fireOsEnabled) {
|
|
111
|
+
// Use openiap-google-amazon for Fire OS when fireOsEnabled is true
|
|
112
|
+
implementation "io.github.hyochan.openiap:openiap-google-amazon:${googleVersionString}"
|
|
109
113
|
} else if (horizonEnabled) {
|
|
110
114
|
// Use openiap-google-horizon for Meta Quest when horizonEnabled is true
|
|
111
115
|
implementation "io.github.hyochan.openiap:openiap-google-horizon:${googleVersionString}"
|
|
@@ -64,7 +64,7 @@ internal object ExpoIapLog {
|
|
|
64
64
|
val sanitized = linkedMapOf<String, Any?>()
|
|
65
65
|
for ((rawKey, rawValue) in source) {
|
|
66
66
|
val key = rawKey as? String ?: continue
|
|
67
|
-
if (key
|
|
67
|
+
if (isSensitiveKey(key)) {
|
|
68
68
|
sanitized[key] = "hidden"
|
|
69
69
|
continue
|
|
70
70
|
}
|
|
@@ -72,4 +72,11 @@ internal object ExpoIapLog {
|
|
|
72
72
|
}
|
|
73
73
|
return sanitized
|
|
74
74
|
}
|
|
75
|
+
|
|
76
|
+
private fun isSensitiveKey(key: String): Boolean {
|
|
77
|
+
val normalized = key.lowercase().filter { it.isLetterOrDigit() }
|
|
78
|
+
return listOf("token", "apikey", "secret", "jws", "receiptid", "userid").any {
|
|
79
|
+
normalized.contains(it)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
75
82
|
}
|
|
@@ -3,6 +3,7 @@ package expo.modules.iap
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import dev.hyo.openiap.AndroidSubscriptionOfferInput
|
|
5
5
|
import dev.hyo.openiap.DeepLinkOptions
|
|
6
|
+
import dev.hyo.openiap.FetchProductsResultAll
|
|
6
7
|
import dev.hyo.openiap.FetchProductsResultProducts
|
|
7
8
|
import dev.hyo.openiap.FetchProductsResultSubscriptions
|
|
8
9
|
import dev.hyo.openiap.InitConnectionConfig
|
|
@@ -183,9 +184,9 @@ class ExpoIapModule : Module() {
|
|
|
183
184
|
val result = openIap.fetchProducts(request)
|
|
184
185
|
val payload =
|
|
185
186
|
when (result) {
|
|
187
|
+
is FetchProductsResultAll -> result.value.orEmpty().map { it.toJson() }
|
|
186
188
|
is FetchProductsResultProducts -> result.value.orEmpty().map { it.toJson() }
|
|
187
189
|
is FetchProductsResultSubscriptions -> result.value.orEmpty().map { it.toJson() }
|
|
188
|
-
else -> emptyList<Map<String, Any?>>()
|
|
189
190
|
}
|
|
190
191
|
ExpoIapLog.result("fetchProducts", payload)
|
|
191
192
|
promise.resolve(payload)
|
|
@@ -495,7 +496,13 @@ class ExpoIapModule : Module() {
|
|
|
495
496
|
}
|
|
496
497
|
|
|
497
498
|
AsyncFunction("verifyPurchaseWithProvider") { params: Map<String, Any?>, promise: Promise ->
|
|
498
|
-
ExpoIapLog.payload(
|
|
499
|
+
ExpoIapLog.payload(
|
|
500
|
+
"verifyPurchaseWithProvider",
|
|
501
|
+
mapOf(
|
|
502
|
+
"provider" to params["provider"],
|
|
503
|
+
"hasIapkit" to (params["iapkit"] != null),
|
|
504
|
+
),
|
|
505
|
+
)
|
|
499
506
|
scope.launch {
|
|
500
507
|
try {
|
|
501
508
|
val props =
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoIapModule.d.ts","sourceRoot":"","sources":["../src/ExpoIapModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpoIapModule.d.ts","sourceRoot":"","sources":["../src/ExpoIapModule.ts"],"names":[],"mappings":"AAsFA,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAQtD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,QAE9B;;AAED,wBAoCG"}
|
package/build/ExpoIapModule.js
CHANGED
|
@@ -1,47 +1,58 @@
|
|
|
1
1
|
import { requireNativeModule, UnavailabilityError } from 'expo-modules-core';
|
|
2
2
|
import { installedFromOnside } from './onside';
|
|
3
|
+
import { getVegaIapModule, isVegaOS } from './vega';
|
|
3
4
|
const ONSIDE_MARKETPLACE_ID = 'com.onside.marketplace-app';
|
|
4
5
|
let cached = null;
|
|
5
6
|
let expoIapFallback;
|
|
6
7
|
let onsideModuleUnavailable = false;
|
|
7
|
-
function isOnsideInstallation() {
|
|
8
|
-
if (installedFromOnside === true) {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
if (typeof installedFromOnside !== 'string') {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
const normalized = installedFromOnside.trim().toLowerCase();
|
|
15
|
-
return normalized === 'true' || normalized === ONSIDE_MARKETPLACE_ID;
|
|
16
|
-
}
|
|
17
|
-
function shouldUseOnsideModule() {
|
|
18
|
-
return isOnsideInstallation() && !onsideModuleUnavailable;
|
|
19
|
-
}
|
|
20
8
|
function getResolved() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
function shouldUseOnsideModule() {
|
|
10
|
+
if (installedFromOnside === true) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
if (typeof installedFromOnside !== 'string') {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const normalized = installedFromOnside.trim().toLowerCase();
|
|
17
|
+
return normalized === 'true' || normalized === ONSIDE_MARKETPLACE_ID;
|
|
26
18
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (isOnsideInstallation()) {
|
|
31
|
-
try {
|
|
32
|
-
return {
|
|
33
|
-
module: requireNativeModule('ExpoIapOnside'),
|
|
34
|
-
name: 'ExpoIapOnside',
|
|
35
|
-
};
|
|
19
|
+
function getExpectedModuleName() {
|
|
20
|
+
if (isVegaOS()) {
|
|
21
|
+
return 'ExpoIapVega';
|
|
36
22
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
return shouldUseOnsideModule() && !onsideModuleUnavailable
|
|
24
|
+
? 'ExpoIapOnside'
|
|
25
|
+
: 'ExpoIap';
|
|
26
|
+
}
|
|
27
|
+
function resolveNativeModule() {
|
|
28
|
+
if (isVegaOS()) {
|
|
29
|
+
const vegaModule = getVegaIapModule();
|
|
30
|
+
if (!vegaModule) {
|
|
31
|
+
throw new UnavailabilityError('expo-iap', 'Amazon Vega IAP module is unavailable. Add @amazon-devices/keplerscript-appstore-iap-lib and build with the React Native Vega kepler platform.');
|
|
32
|
+
}
|
|
33
|
+
return { module: vegaModule, name: 'ExpoIapVega' };
|
|
34
|
+
}
|
|
35
|
+
if (shouldUseOnsideModule()) {
|
|
36
|
+
try {
|
|
37
|
+
return {
|
|
38
|
+
module: requireNativeModule('ExpoIapOnside'),
|
|
39
|
+
name: 'ExpoIapOnside',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (!isMissingModuleError(error, 'ExpoIapOnside')) {
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
onsideModuleUnavailable = true;
|
|
40
47
|
}
|
|
41
|
-
onsideModuleUnavailable = true;
|
|
42
48
|
}
|
|
49
|
+
return { module: requireNativeModule('ExpoIap'), name: 'ExpoIap' };
|
|
43
50
|
}
|
|
44
|
-
|
|
51
|
+
const expectedName = getExpectedModuleName();
|
|
52
|
+
if (!cached || cached.name !== expectedName) {
|
|
53
|
+
cached = resolveNativeModule();
|
|
54
|
+
}
|
|
55
|
+
return cached;
|
|
45
56
|
}
|
|
46
57
|
function isMissingModuleError(error, moduleName) {
|
|
47
58
|
if (error instanceof UnavailabilityError) {
|
|
@@ -68,31 +79,34 @@ export const NATIVE_ERROR_CODES = new Proxy({}, {
|
|
|
68
79
|
export function getNativeModule() {
|
|
69
80
|
return getResolved().module;
|
|
70
81
|
}
|
|
71
|
-
function getExpoIapFallbackModule() {
|
|
72
|
-
if (expoIapFallback !== undefined) {
|
|
73
|
-
return expoIapFallback;
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
expoIapFallback = requireNativeModule('ExpoIap');
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
if (isMissingModuleError(error, 'ExpoIap')) {
|
|
80
|
-
expoIapFallback = null;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
throw error;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return expoIapFallback;
|
|
87
|
-
}
|
|
88
82
|
export default new Proxy({}, {
|
|
89
83
|
get(target, prop) {
|
|
84
|
+
function getExpoIapFallbackModule() {
|
|
85
|
+
if (expoIapFallback !== undefined) {
|
|
86
|
+
return expoIapFallback;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
expoIapFallback = requireNativeModule('ExpoIap');
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (isMissingModuleError(error, 'ExpoIap')) {
|
|
93
|
+
expoIapFallback = null;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return expoIapFallback;
|
|
100
|
+
}
|
|
90
101
|
if (typeof prop === 'symbol')
|
|
91
102
|
return Reflect.get(target, prop);
|
|
92
103
|
const resolved = getResolved();
|
|
93
104
|
if (prop === 'USING_ONSIDE_SDK') {
|
|
94
105
|
return resolved.name === 'ExpoIapOnside';
|
|
95
106
|
}
|
|
107
|
+
if (prop === 'USING_VEGA_SDK') {
|
|
108
|
+
return resolved.name === 'ExpoIapVega';
|
|
109
|
+
}
|
|
96
110
|
const value = resolved.module[prop];
|
|
97
111
|
if (value !== undefined || resolved.name !== 'ExpoIapOnside') {
|
|
98
112
|
return value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoIapModule.js","sourceRoot":"","sources":["../src/ExpoIapModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpoIapModule.js","sourceRoot":"","sources":["../src/ExpoIapModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAC,mBAAmB,EAAC,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAGlD,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAE3D,IAAI,MAAM,GAAoD,IAAI,CAAC;AACnE,IAAI,eAAuC,CAAC;AAC5C,IAAI,uBAAuB,GAAG,KAAK,CAAC;AAEpC,SAAS,WAAW;IA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C,CAAC;YACnD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,oBAAoB,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;oBAC3C,eAAe,GAAG,IAAI,CAAC;gBACzB,CAAC;qBAAM,CAAC;oBACN,MAAM,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;YAED,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,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,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,KAAK,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;YAC7D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,wBAAwB,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {requireNativeModule, UnavailabilityError} from 'expo-modules-core';\nimport {installedFromOnside} from './onside';\nimport {getVegaIapModule, isVegaOS} from './vega';\n\ntype NativeIapModuleName = 'ExpoIapVega' | 'ExpoIapOnside' | 'ExpoIap';\nconst ONSIDE_MARKETPLACE_ID = 'com.onside.marketplace-app';\n\nlet cached: {module: any; name: NativeIapModuleName} | null = null;\nlet expoIapFallback: any | null | undefined;\nlet onsideModuleUnavailable = false;\n\nfunction getResolved(): {module: any; name: NativeIapModuleName} {\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() && !onsideModuleUnavailable\n ? 'ExpoIapOnside'\n : 'ExpoIap';\n }\n\n function resolveNativeModule(): {\n module: any;\n name: NativeIapModuleName;\n } {\n if (isVegaOS()) {\n const vegaModule = getVegaIapModule();\n if (!vegaModule) {\n throw new UnavailabilityError(\n 'expo-iap',\n 'Amazon Vega IAP module is unavailable. Add @amazon-devices/keplerscript-appstore-iap-lib and build with the React Native Vega kepler platform.',\n );\n }\n return {module: vegaModule, name: 'ExpoIapVega'};\n }\n\n if (shouldUseOnsideModule()) {\n try {\n return {\n module: requireNativeModule('ExpoIapOnside'),\n name: 'ExpoIapOnside',\n };\n } catch (error) {\n if (!isMissingModuleError(error, 'ExpoIapOnside')) {\n throw error;\n }\n onsideModuleUnavailable = true;\n }\n }\n\n return {module: requireNativeModule('ExpoIap'), name: 'ExpoIap'};\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 return (getResolved().module.ERROR_CODES || {})[prop as string];\n },\n },\n);\n\n/**\n * Returns the raw native module (not wrapped in a Proxy).\n * Use this for EventEmitter / addListener calls — JSI HostObjects\n * require the real native module as `this`; a Proxy triggers\n * \"native state unsupported on Proxy\" on New Architecture / Hermes.\n */\nexport function getNativeModule() {\n return getResolved().module;\n}\n\nexport default new Proxy({} as any, {\n get(target, prop) {\n function getExpoIapFallbackModule(): any | null {\n if (expoIapFallback !== undefined) {\n return expoIapFallback;\n }\n\n try {\n expoIapFallback = requireNativeModule('ExpoIap');\n } catch (error) {\n if (isMissingModuleError(error, 'ExpoIap')) {\n expoIapFallback = null;\n } else {\n throw error;\n }\n }\n\n return expoIapFallback;\n }\n\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 = resolved.module[prop];\n if (value !== undefined || resolved.name !== 'ExpoIapOnside') {\n return value;\n }\n\n return getExpoIapFallbackModule()?.[prop];\n },\n});\n"]}
|
package/build/index.d.ts
CHANGED
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":"AAoBA,OAAO,KAAK,EAIV,sCAAsC,EACtC,aAAa,EAGb,OAAO,EACP,gBAAgB,EAEhB,QAAQ,EAER,8BAA8B,EAC9B,UAAU,EAOV,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAsB,KAAK,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAG7E,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AAGvB,oBAAY,YAAY;IACtB,eAAe,qBAAqB;IACpC,aAAa,mBAAmB;IAChC,kBAAkB,yBAAyB;IAC3C,wBAAwB,gCAAgC;IACxD;;;OAGG;IACH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;AAC9C,YAAY,EACV,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,aAAa,IAAI,iBAAiB,EAClC,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
3
|
// Internal modules
|
|
4
4
|
import ExpoIapModule, { getNativeModule } from './ExpoIapModule';
|
|
5
|
+
import { isVegaOS } from './vega';
|
|
5
6
|
import { isProductIOS, validateReceiptIOS, deepLinkToSubscriptionsIOS, syncIOS, } from './modules/ios';
|
|
6
7
|
import { isProductAndroid, validateReceiptAndroid, deepLinkToSubscriptionsAndroid, } from './modules/android';
|
|
7
8
|
import { ExpoIapConsole } from './utils/debug';
|
|
@@ -12,6 +13,7 @@ export * from './types';
|
|
|
12
13
|
export * from './modules/android';
|
|
13
14
|
export * from './modules/ios';
|
|
14
15
|
export * from './onside';
|
|
16
|
+
export * from './vega';
|
|
15
17
|
// Get the native constant value
|
|
16
18
|
export var OpenIapEvent;
|
|
17
19
|
(function (OpenIapEvent) {
|
|
@@ -149,6 +151,9 @@ const normalizePurchasePlatform = (purchase) => {
|
|
|
149
151
|
return { ...purchase, platform: lowered };
|
|
150
152
|
};
|
|
151
153
|
const normalizePurchaseArray = (purchases) => purchases.map((purchase) => normalizePurchasePlatform(purchase));
|
|
154
|
+
const isAndroidStoreRuntime = () => {
|
|
155
|
+
return Platform.OS === 'android' || isVegaOS();
|
|
156
|
+
};
|
|
152
157
|
export const purchaseUpdatedListener = (listener, options) => {
|
|
153
158
|
const receiveDuplicateTransactionUpdatesIOS = Platform.OS === 'ios' && options?.dedupeTransactionIOS === false;
|
|
154
159
|
const listenerDedupeHistoryIOS = {
|
|
@@ -471,7 +476,7 @@ export const fetchProducts = async (request) => {
|
|
|
471
476
|
const rawItems = await ExpoIapModule.fetchProducts({ skus, type: native });
|
|
472
477
|
return castResult(filterIosItems(rawItems));
|
|
473
478
|
}
|
|
474
|
-
if (
|
|
479
|
+
if (isAndroidStoreRuntime()) {
|
|
475
480
|
const rawItems = await ExpoIapModule.fetchProducts(native, skus);
|
|
476
481
|
return castResult(filterAndroidItems(rawItems));
|
|
477
482
|
}
|
|
@@ -502,6 +507,10 @@ export const getAvailablePurchases = async (options) => {
|
|
|
502
507
|
onlyIncludeActiveItemsIOS: options?.onlyIncludeActiveItemsIOS ?? true,
|
|
503
508
|
includeSuspendedAndroid: options?.includeSuspendedAndroid ?? false,
|
|
504
509
|
};
|
|
510
|
+
if (isVegaOS()) {
|
|
511
|
+
const purchases = await ExpoIapModule.getAvailableItems(normalizedOptions);
|
|
512
|
+
return normalizePurchaseArray(purchases);
|
|
513
|
+
}
|
|
505
514
|
let purchases;
|
|
506
515
|
if (Platform.OS === 'ios') {
|
|
507
516
|
purchases = (await ExpoIapModule.getAvailableItems(normalizedOptions.alsoPublishToEventListenerIOS, normalizedOptions.onlyIncludeActiveItemsIOS));
|
|
@@ -580,7 +589,7 @@ export const hasActiveSubscriptions = async (subscriptionIds) => {
|
|
|
580
589
|
* @see {@link https://openiap.dev/docs/apis/get-storefront}
|
|
581
590
|
*/
|
|
582
591
|
export const getStorefront = async () => {
|
|
583
|
-
if (Platform.OS !== 'ios' &&
|
|
592
|
+
if (Platform.OS !== 'ios' && !isAndroidStoreRuntime()) {
|
|
584
593
|
return '';
|
|
585
594
|
}
|
|
586
595
|
return ExpoIapModule.getStorefront();
|
|
@@ -654,7 +663,7 @@ export const requestPurchase = async (args) => {
|
|
|
654
663
|
}
|
|
655
664
|
return canonical === 'subs' ? [] : null;
|
|
656
665
|
}
|
|
657
|
-
if (
|
|
666
|
+
if (isAndroidStoreRuntime()) {
|
|
658
667
|
if (isInAppPurchase) {
|
|
659
668
|
const normalizedRequest = normalizeRequestProps(request, 'android');
|
|
660
669
|
if (!normalizedRequest?.skus?.length) {
|
|
@@ -747,7 +756,7 @@ export const finishTransaction = async ({ purchase, isConsumable = false, }) =>
|
|
|
747
756
|
await ExpoIapModule.finishTransaction(purchase, isConsumable);
|
|
748
757
|
return;
|
|
749
758
|
}
|
|
750
|
-
if (
|
|
759
|
+
if (isAndroidStoreRuntime()) {
|
|
751
760
|
const token = purchase.purchaseToken ?? undefined;
|
|
752
761
|
if (!token) {
|
|
753
762
|
throw createPurchaseError({
|