react-native-iap 16.3.0 → 16.3.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/README.md +3 -3
- package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +111 -15
- package/android/src/main/java/com/margelo/nitro/iap/RnIapLog.kt +5 -1
- package/ios/HybridRnIap.swift +1 -1
- package/ios/RnIapLog.swift +6 -6
- package/lib/module/index.js +51 -6
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.kepler.js +9 -0
- package/lib/module/index.kepler.js.map +1 -1
- package/lib/module/kit-api.js +3 -1
- package/lib/module/kit-api.js.map +1 -1
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/vega-adapter.js +3 -4
- package/lib/module/vega-adapter.js.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.kepler.d.ts.map +1 -1
- package/lib/typescript/src/kit-api.d.ts +119 -2
- package/lib/typescript/src/kit-api.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +9 -3
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +33 -9
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/vega-adapter.d.ts.map +1 -1
- package/nitrogen/generated/android/NitroIap+autolinking.cmake +1 -1
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +8 -4
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/JNitroPurchaseVerificationResultAndroid.hpp +5 -1
- package/nitrogen/generated/android/c++/JNitroPurchaseVerificationResultHorizon.hpp +69 -0
- package/nitrogen/generated/android/c++/JVariant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid_NitroPurchaseVerificationResultHorizon.cpp +30 -0
- package/nitrogen/generated/android/c++/{JVariant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid.hpp → JVariant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid_NitroPurchaseVerificationResultHorizon.hpp} +33 -16
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchaseVerificationResultAndroid.kt +8 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchaseVerificationResultHorizon.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/{Variant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid.kt → Variant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid_NitroPurchaseVerificationResultHorizon.kt} +21 -8
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.cpp +4 -4
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +43 -34
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +4 -1
- package/nitrogen/generated/ios/swift/{Func_void_std__variant_NitroPurchaseVerificationResultIOS__NitroPurchaseVerificationResultAndroid_.swift → Func_void_std__variant_NitroPurchaseVerificationResultIOS__NitroPurchaseVerificationResultAndroid__NitroPurchaseVerificationResultHorizon_.swift} +14 -11
- package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +11 -9
- package/nitrogen/generated/ios/swift/NitroPurchaseVerificationResultAndroid.swift +7 -2
- package/nitrogen/generated/ios/swift/NitroPurchaseVerificationResultHorizon.swift +71 -0
- package/nitrogen/generated/ios/swift/{Variant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid.swift → Variant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid_NitroPurchaseVerificationResultHorizon.swift} +6 -4
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +4 -1
- package/nitrogen/generated/shared/c++/NitroPurchaseVerificationResultAndroid.hpp +5 -1
- package/nitrogen/generated/shared/c++/NitroPurchaseVerificationResultHorizon.hpp +93 -0
- package/openiap-versions.json +3 -3
- package/package.json +3 -2
- package/src/index.kepler.ts +10 -2
- package/src/index.ts +88 -18
- package/src/kit-api.ts +125 -4
- package/src/specs/RnIap.nitro.ts +12 -2
- package/src/types.ts +34 -9
- package/src/vega-adapter.ts +6 -11
- package/nitrogen/generated/android/c++/JVariant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid.cpp +0 -26
package/src/types.ts
CHANGED
|
@@ -885,11 +885,11 @@ export interface Mutation {
|
|
|
885
885
|
*/
|
|
886
886
|
syncIOS: Promise<boolean>;
|
|
887
887
|
/**
|
|
888
|
-
* Verify a purchase against your own backend.
|
|
889
|
-
* variant
|
|
890
|
-
*
|
|
891
|
-
* receipt fields
|
|
892
|
-
*
|
|
888
|
+
* Verify a purchase against your own backend. Every VerifyPurchaseResult
|
|
889
|
+
* variant exposes isValid, so entitlement can be gated without inspecting the
|
|
890
|
+
* concrete type. Variants add their own metadata on top: IOS carries
|
|
891
|
+
* receipt/JWS fields, Android carries Play Store receipt fields, and Horizon
|
|
892
|
+
* carries grantTime.
|
|
893
893
|
* See: https://openiap.dev/docs/features/validation#verify-purchase
|
|
894
894
|
*/
|
|
895
895
|
verifyPurchase: Promise<VerifyPurchaseResult>;
|
|
@@ -1857,6 +1857,12 @@ export interface RequestVerifyPurchaseWithIapkitResult {
|
|
|
1857
1857
|
* Available in OpenIAP Spec 3.2.0 / openiap-apple 3.2.0 / openiap-google 3.3.0.
|
|
1858
1858
|
* Amazon RVS environment selected by IAPKit. Present as `Sandbox` or
|
|
1859
1859
|
* `Production` on handled Amazon verification results.
|
|
1860
|
+
*
|
|
1861
|
+
* Deliberately String, not an enum: the value space belongs to IAPKit and the
|
|
1862
|
+
* stores behind it, and Apple's App Store Server alone also names `Xcode` and
|
|
1863
|
+
* `LocalTesting`. SDKs must forward this value opaquely. Never reject a
|
|
1864
|
+
* verification because the environment is unrecognised — that fails a purchase
|
|
1865
|
+
* the store already confirmed.
|
|
1860
1866
|
*/
|
|
1861
1867
|
environment?: (string | null);
|
|
1862
1868
|
/**
|
|
@@ -2187,7 +2193,7 @@ export interface VerifyPurchaseProps {
|
|
|
2187
2193
|
|
|
2188
2194
|
export type VerifyPurchaseResult = VerifyPurchaseResultAndroid | VerifyPurchaseResultHorizon | VerifyPurchaseResultIOS;
|
|
2189
2195
|
|
|
2190
|
-
export interface VerifyPurchaseResultAndroid {
|
|
2196
|
+
export interface VerifyPurchaseResultAndroid extends VerifyPurchaseResultCommon {
|
|
2191
2197
|
autoRenewing: boolean;
|
|
2192
2198
|
betaProduct: boolean;
|
|
2193
2199
|
cancelDate?: (number | null);
|
|
@@ -2196,6 +2202,11 @@ export interface VerifyPurchaseResultAndroid {
|
|
|
2196
2202
|
deferredSku?: (string | null);
|
|
2197
2203
|
freeTrialEndDate: number;
|
|
2198
2204
|
gracePeriodEndDate: number;
|
|
2205
|
+
/**
|
|
2206
|
+
* Whether the purchase is valid. Uniform across every VerifyPurchaseResult
|
|
2207
|
+
* variant so callers can gate entitlement without inspecting the concrete type.
|
|
2208
|
+
*/
|
|
2209
|
+
isValid: boolean;
|
|
2199
2210
|
parentProductId: string;
|
|
2200
2211
|
productId: string;
|
|
2201
2212
|
productType: string;
|
|
@@ -2208,18 +2219,32 @@ export interface VerifyPurchaseResultAndroid {
|
|
|
2208
2219
|
testTransaction: boolean;
|
|
2209
2220
|
}
|
|
2210
2221
|
|
|
2222
|
+
/** Validity shared by every store-specific purchase verification result. */
|
|
2223
|
+
export interface VerifyPurchaseResultCommon {
|
|
2224
|
+
/** Whether the purchase is valid, without inspecting the concrete result variant. */
|
|
2225
|
+
isValid: boolean;
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2211
2228
|
/**
|
|
2212
2229
|
* Result from Meta Horizon verify_entitlement API.
|
|
2213
2230
|
* Returns verification status and grant time for the entitlement.
|
|
2214
2231
|
*/
|
|
2215
|
-
export interface VerifyPurchaseResultHorizon {
|
|
2232
|
+
export interface VerifyPurchaseResultHorizon extends VerifyPurchaseResultCommon {
|
|
2216
2233
|
/** Unix timestamp (seconds) when the entitlement was granted. */
|
|
2217
2234
|
grantTime?: (number | null);
|
|
2218
|
-
/**
|
|
2235
|
+
/**
|
|
2236
|
+
* Whether the purchase is valid. Uniform across every VerifyPurchaseResult
|
|
2237
|
+
* variant so callers can gate entitlement without inspecting the concrete type.
|
|
2238
|
+
*/
|
|
2239
|
+
isValid: boolean;
|
|
2240
|
+
/**
|
|
2241
|
+
* Whether the entitlement verification succeeded.
|
|
2242
|
+
* @deprecated Renamed to isValid so every VerifyPurchaseResult variant answers validity the same way. Scheduled for removal in OpenIAP 4.0.
|
|
2243
|
+
*/
|
|
2219
2244
|
success: boolean;
|
|
2220
2245
|
}
|
|
2221
2246
|
|
|
2222
|
-
export interface VerifyPurchaseResultIOS {
|
|
2247
|
+
export interface VerifyPurchaseResultIOS extends VerifyPurchaseResultCommon {
|
|
2223
2248
|
/** Whether the receipt is valid */
|
|
2224
2249
|
isValid: boolean;
|
|
2225
2250
|
/** JWS representation */
|
package/src/vega-adapter.ts
CHANGED
|
@@ -1271,17 +1271,12 @@ export function createVegaIapModule(service: VegaPurchasingService): RnIap {
|
|
|
1271
1271
|
`IAPKit returned malformed response (HTTP ${status}).`,
|
|
1272
1272
|
);
|
|
1273
1273
|
}
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
throw createVegaError(
|
|
1281
|
-
ErrorCode.PurchaseVerificationFailed,
|
|
1282
|
-
`IAPKit returned malformed response (HTTP ${status}).`,
|
|
1283
|
-
);
|
|
1284
|
-
}
|
|
1274
|
+
// Forwarded opaquely: `environment` is String in the spec.
|
|
1275
|
+
const rawEnvironment = json.environment;
|
|
1276
|
+
const environment =
|
|
1277
|
+
typeof rawEnvironment === 'string' && rawEnvironment.length > 0
|
|
1278
|
+
? rawEnvironment
|
|
1279
|
+
: undefined;
|
|
1285
1280
|
|
|
1286
1281
|
return {
|
|
1287
1282
|
...(environment == null ? {} : {environment}),
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// JVariant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid.cpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
#include "JVariant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid.hpp"
|
|
9
|
-
|
|
10
|
-
namespace margelo::nitro::iap {
|
|
11
|
-
/**
|
|
12
|
-
* Converts JVariant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid to std::variant<NitroPurchaseVerificationResultIOS, NitroPurchaseVerificationResultAndroid>
|
|
13
|
-
*/
|
|
14
|
-
std::variant<NitroPurchaseVerificationResultIOS, NitroPurchaseVerificationResultAndroid> JVariant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid::toCpp() const {
|
|
15
|
-
if (isInstanceOf(JVariant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid_impl::First::javaClassStatic())) {
|
|
16
|
-
// It's a `NitroPurchaseVerificationResultIOS`
|
|
17
|
-
auto jniValue = static_cast<const JVariant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid_impl::First*>(this)->getValue();
|
|
18
|
-
return jniValue->toCpp();
|
|
19
|
-
} else if (isInstanceOf(JVariant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid_impl::Second::javaClassStatic())) {
|
|
20
|
-
// It's a `NitroPurchaseVerificationResultAndroid`
|
|
21
|
-
auto jniValue = static_cast<const JVariant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid_impl::Second*>(this)->getValue();
|
|
22
|
-
return jniValue->toCpp();
|
|
23
|
-
}
|
|
24
|
-
throw std::invalid_argument("Variant is unknown Kotlin instance!");
|
|
25
|
-
}
|
|
26
|
-
} // namespace margelo::nitro::iap
|