react-native-purchases 10.10.0 → 10.10.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.
@@ -25,6 +25,6 @@ Pod::Spec.new do |spec|
25
25
  ]
26
26
 
27
27
  spec.dependency "React-Core"
28
- spec.dependency "PurchasesHybridCommon", '19.0.0'
28
+ spec.dependency "PurchasesHybridCommon", '19.3.1'
29
29
  spec.swift_version = '5.7'
30
30
  end
@@ -35,7 +35,7 @@ android {
35
35
  minSdkVersion getExtOrIntegerDefault('minSdkVersion')
36
36
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
37
37
  versionCode 1
38
- versionName '10.10.0'
38
+ versionName '10.10.2'
39
39
  }
40
40
 
41
41
  buildTypes {
@@ -127,6 +127,6 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
127
127
  dependencies {
128
128
  //noinspection GradleDynamicVersion
129
129
  api 'com.facebook.react:react-native:+'
130
- implementation 'com.revenuecat.purchases:purchases-hybrid-common:19.0.0'
130
+ implementation 'com.revenuecat.purchases:purchases-hybrid-common:19.3.1'
131
131
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
132
132
  }
@@ -51,7 +51,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
51
51
  private static final String TRACKED_EVENT = "Purchases-TrackedEvent";
52
52
  private static final String DEBUG_EVENT = "Purchases-DebugEvent";
53
53
  public static final String PLATFORM_NAME = "react-native";
54
- public static final String PLUGIN_VERSION = "10.10.0";
54
+ public static final String PLUGIN_VERSION = "10.10.2";
55
55
 
56
56
  private final ReactApplicationContext reactContext;
57
57
 
@@ -43,7 +43,7 @@ var typeGuards_1 = require("./typeGuards");
43
43
  var environment_1 = require("../utils/environment");
44
44
  var utils_1 = require("./utils");
45
45
  var purchaseSimulatedPackageHelper_1 = require("./simulatedstore/purchaseSimulatedPackageHelper");
46
- var packageVersion = '10.10.0';
46
+ var packageVersion = '10.10.2';
47
47
  /**
48
48
  * Browser implementation of the native module. This will be used in the browser and Expo Go.
49
49
  */
@@ -0,0 +1 @@
1
+ export declare function normalizingRejections<T extends object>(module: T): T;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizingRejections = void 0;
4
+ var purchases_typescript_internal_1 = require("@revenuecat/purchases-typescript-internal");
5
+ // The returned promise is chained, never copied: enumerating a TurboModule
6
+ // promise's own properties throws inside Hermes.
7
+ function normalizingRejections(module) {
8
+ return new Proxy(module, {
9
+ get: function (target, property, receiver) {
10
+ var value = Reflect.get(target, property, receiver);
11
+ if (typeof value !== "function") {
12
+ return value;
13
+ }
14
+ // An apply trap keeps what the bridge puts on the method it generated, such as its
15
+ // name and React Native's own call-type marker.
16
+ return new Proxy(value, {
17
+ apply: function (method, thisArg, args) {
18
+ var result = Reflect.apply(method, thisArg, args);
19
+ return result instanceof Promise
20
+ ? result.catch(function (error) {
21
+ throw (0, purchases_typescript_internal_1.normalizePurchasesError)(error);
22
+ })
23
+ : result;
24
+ },
25
+ });
26
+ },
27
+ });
28
+ }
29
+ exports.normalizingRejections = normalizingRejections;
package/dist/purchases.js CHANGED
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.PurchasesAdTracker = exports.AdRevenuePrecision = exports.AdFormat = exports.AdMediatorName = exports.WebPurchaseRedemptionResultType = exports.STOREKIT_VERSION = exports.LOG_LEVEL = exports.REFUND_REQUEST_STATUS = exports.BILLING_FEATURE = exports.PURCHASES_ARE_COMPLETED_BY_TYPE = exports.PURCHASE_TYPE = void 0;
40
40
  var react_native_1 = require("react-native");
41
41
  var purchases_typescript_internal_1 = require("@revenuecat/purchases-typescript-internal");
42
+ var normalizingRejections_1 = require("./normalizingRejections");
42
43
  var environment_1 = require("./utils/environment");
43
44
  var nativeModule_1 = require("./browser/nativeModule");
44
45
  // This export is kept to keep backwards compatibility to any possible users using this file directly
@@ -62,14 +63,15 @@ var NATIVE_MODULE_ERROR = "[RevenueCat] Native module (RNPurchases) not found. T
62
63
  "- Check that you have rebuilt the app after installing the package\n";
63
64
  // Get the native module or use the browser implementation
64
65
  var usingBrowserMode = (0, environment_1.shouldUseBrowserMode)();
65
- var RNPurchases = usingBrowserMode ? nativeModule_1.browserNativeModuleRNPurchases : react_native_1.NativeModules.RNPurchases;
66
+ var nativeModule = usingBrowserMode ? nativeModule_1.browserNativeModuleRNPurchases : react_native_1.NativeModules.RNPurchases;
67
+ var RNPurchases = nativeModule ? (0, normalizingRejections_1.normalizingRejections)(nativeModule) : nativeModule;
66
68
  // Only create event emitter if native module is available to avoid crash on import
67
69
  //
68
70
  // React Native 0.79+ requires native modules to implement addListener() and removeListeners()
69
71
  // methods for NativeEventEmitter to work. Both iOS and Android native modules now have these.
70
72
  // See: https://github.com/RevenueCat/react-native-purchases/issues/1298
71
73
  // See: https://reactnative.dev/blog/2025/04/08/react-native-0.79 (Breaking Changes section)
72
- var eventEmitter = !usingBrowserMode && RNPurchases ? new react_native_1.NativeEventEmitter(RNPurchases) : null;
74
+ var eventEmitter = !usingBrowserMode && nativeModule ? new react_native_1.NativeEventEmitter(nativeModule) : null;
73
75
  // Helper function to check if native module is available - provides better error message than "Cannot read property X of null"
74
76
  function throwIfNativeModuleNotAvailable() {
75
77
  if (!RNPurchases) {
@@ -431,11 +433,7 @@ var Purchases = /** @class */ (function () {
431
433
  case 0: return [4 /*yield*/, throwIfNotConfigured()];
432
434
  case 1:
433
435
  _a.sent();
434
- return [2 /*return*/, RNPurchases.purchaseProduct(productIdentifier, upgradeInfo, type, null, null, null).catch(function (error) {
435
- error.userCancelled =
436
- error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
437
- throw error;
438
- })];
436
+ return [2 /*return*/, RNPurchases.purchaseProduct(productIdentifier, upgradeInfo, type, null, null, null)];
439
437
  }
440
438
  });
441
439
  });
@@ -463,11 +461,7 @@ var Purchases = /** @class */ (function () {
463
461
  _a.sent();
464
462
  return [2 /*return*/, RNPurchases.purchaseProduct(product.identifier, productChangeInfo, product.productCategory, null, googleIsPersonalizedPrice == null
465
463
  ? null
466
- : { isPersonalizedPrice: googleIsPersonalizedPrice }, product.presentedOfferingContext).catch(function (error) {
467
- error.userCancelled =
468
- error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
469
- throw error;
470
- })];
464
+ : { isPersonalizedPrice: googleIsPersonalizedPrice }, product.presentedOfferingContext)];
471
465
  }
472
466
  });
473
467
  });
@@ -495,11 +489,7 @@ var Purchases = /** @class */ (function () {
495
489
  if (typeof discount === "undefined" || discount == null) {
496
490
  throw new Error("A discount is required");
497
491
  }
498
- return [2 /*return*/, RNPurchases.purchaseProduct(product.identifier, null, null, discount.timestamp.toString(), null, product.presentedOfferingContext).catch(function (error) {
499
- error.userCancelled =
500
- error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
501
- throw error;
502
- })];
492
+ return [2 /*return*/, RNPurchases.purchaseProduct(product.identifier, null, null, discount.timestamp.toString(), null, product.presentedOfferingContext)];
503
493
  }
504
494
  });
505
495
  });
@@ -528,11 +518,7 @@ var Purchases = /** @class */ (function () {
528
518
  _a.sent();
529
519
  return [2 /*return*/, RNPurchases.purchasePackage(aPackage.identifier, aPackage.presentedOfferingContext, productChangeInfo || upgradeInfo, null, googleIsPersonalizedPrice == null
530
520
  ? null
531
- : { isPersonalizedPrice: googleIsPersonalizedPrice }).catch(function (error) {
532
- error.userCancelled =
533
- error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
534
- throw error;
535
- })];
521
+ : { isPersonalizedPrice: googleIsPersonalizedPrice })];
536
522
  }
537
523
  });
538
524
  });
@@ -563,11 +549,7 @@ var Purchases = /** @class */ (function () {
563
549
  _a.sent();
564
550
  return [2 /*return*/, RNPurchases.purchaseSubscriptionOption(subscriptionOption.productId, subscriptionOption.id, productChangeInfo, null, googleIsPersonalizedPrice == null
565
551
  ? null
566
- : { isPersonalizedPrice: googleIsPersonalizedPrice }, subscriptionOption.presentedOfferingContext).catch(function (error) {
567
- error.userCancelled =
568
- error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
569
- throw error;
570
- })];
552
+ : { isPersonalizedPrice: googleIsPersonalizedPrice }, subscriptionOption.presentedOfferingContext)];
571
553
  }
572
554
  });
573
555
  });
@@ -592,11 +574,7 @@ var Purchases = /** @class */ (function () {
592
574
  if (typeof discount === "undefined" || discount == null) {
593
575
  throw new Error("A discount is required");
594
576
  }
595
- return [2 /*return*/, RNPurchases.purchasePackage(aPackage.identifier, aPackage.presentedOfferingContext, null, discount.timestamp.toString(), null).catch(function (error) {
596
- error.userCancelled =
597
- error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
598
- throw error;
599
- })];
577
+ return [2 /*return*/, RNPurchases.purchasePackage(aPackage.identifier, aPackage.presentedOfferingContext, null, discount.timestamp.toString(), null)];
600
578
  }
601
579
  });
602
580
  });
@@ -1131,11 +1109,7 @@ var Purchases = /** @class */ (function () {
1131
1109
  if (react_native_2.Platform.OS === "android") {
1132
1110
  throw new purchases_typescript_internal_1.UnsupportedPlatformError();
1133
1111
  }
1134
- return [2 /*return*/, RNPurchases.purchaseProductWithWinBackOffer(product.identifier, winBackOffer.identifier).catch(function (error) {
1135
- error.userCancelled =
1136
- error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
1137
- throw error;
1138
- })];
1112
+ return [2 /*return*/, RNPurchases.purchaseProductWithWinBackOffer(product.identifier, winBackOffer.identifier)];
1139
1113
  }
1140
1114
  });
1141
1115
  });
@@ -1165,11 +1139,7 @@ var Purchases = /** @class */ (function () {
1165
1139
  if (react_native_2.Platform.OS === "android") {
1166
1140
  throw new purchases_typescript_internal_1.UnsupportedPlatformError();
1167
1141
  }
1168
- return [2 /*return*/, RNPurchases.purchasePackageWithWinBackOffer(aPackage.identifier, aPackage.presentedOfferingContext, winBackOffer.identifier).catch(function (error) {
1169
- error.userCancelled =
1170
- error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
1171
- throw error;
1172
- })];
1142
+ return [2 /*return*/, RNPurchases.purchasePackageWithWinBackOffer(aPackage.identifier, aPackage.presentedOfferingContext, winBackOffer.identifier)];
1173
1143
  }
1174
1144
  });
1175
1145
  });
package/ios/RNPurchases.m CHANGED
@@ -324,18 +324,13 @@ RCT_EXPORT_METHOD(eligibleWinBackOffersForProductIdentifier:(nonnull NSString *)
324
324
  [RCCommonFunctionality eligibleWinBackOffersForProductIdentifier:productID
325
325
  completionBlock:^(NSArray<NSDictionary *> * _Nullable offers, RCErrorContainer * _Nullable errorContainer) {
326
326
  if (errorContainer) {
327
- reject(
328
- [NSString stringWithFormat:@"%ld", (long)errorContainer.code],
329
- errorContainer.message,
330
- errorContainer.error
331
- );
327
+ [self rejectPromiseWithBlock:reject error:errorContainer];
332
328
  } else {
333
329
  resolve(offers ?: @[]);
334
330
  }
335
331
  }];
336
332
  } else {
337
- NSError *error = [self createUnsupportedErrorWithDescription:@"iOS win-back offers are only available on iOS 18.0 or greater."];
338
- reject([NSString stringWithFormat:@"%ld", (long)error.code], [error localizedDescription], error);
333
+ [self rejectPromiseWithBlock:reject unsupportedErrorDescription:@"iOS win-back offers are only available on iOS 18.0 or greater."];
339
334
  }
340
335
  }
341
336
 
@@ -348,8 +343,7 @@ RCT_EXPORT_METHOD(purchaseProductWithWinBackOffer:(nonnull NSString *)productID
348
343
  winBackOfferID:winBackOfferID
349
344
  completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
350
345
  } else {
351
- NSError *error = [self createUnsupportedErrorWithDescription:@"iOS win-back offers are only available on iOS 18.0 or greater."];
352
- reject([NSString stringWithFormat:@"%ld", (long)error.code], [error localizedDescription], error);
346
+ [self rejectPromiseWithBlock:reject unsupportedErrorDescription:@"iOS win-back offers are only available on iOS 18.0 or greater."];
353
347
  }
354
348
  }
355
349
 
@@ -364,8 +358,7 @@ RCT_EXPORT_METHOD(purchasePackageWithWinBackOffer:(nonnull NSString *)packageID
364
358
  winBackOfferID:winBackOfferID
365
359
  completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
366
360
  } else {
367
- NSError *error = [self createUnsupportedErrorWithDescription:@"iOS win-back offers are only available on iOS 18.0 or greater."];
368
- reject([NSString stringWithFormat:@"%ld", (long)error.code], [error localizedDescription], error);
361
+ [self rejectPromiseWithBlock:reject unsupportedErrorDescription:@"iOS win-back offers are only available on iOS 18.0 or greater."];
369
362
  }
370
363
  }
371
364
 
@@ -551,24 +544,18 @@ RCT_EXPORT_METHOD(showManageSubscriptions:
551
544
  if (@available(iOS 13.0, macOS 10.15, visionOS 1.0, *)) {
552
545
  [RCCommonFunctionality showManageSubscriptions:^(RCErrorContainer * _Nullable errorContainer) {
553
546
  if (errorContainer) {
554
- reject(
555
- [NSString stringWithFormat:@"%ld", (long)errorContainer.code],
556
- errorContainer.message,
557
- errorContainer.error
558
- );
547
+ [self rejectPromiseWithBlock:reject error:errorContainer];
559
548
  } else {
560
549
  resolve(nil);
561
550
  }
562
551
  }];
563
552
  } else {
564
553
  NSLog(@"[Purchases] Warning: tried to showManageSubscriptions in non supported iOS devices. Only available on iOS 13.0 or greater.");
565
- NSError *error = [self createUnsupportedErrorWithDescription:@"Tried to present manage subscriptions sheet, but this functionality is only available on iOS 13.0 or greater."];
566
- reject([NSString stringWithFormat:@"%ld", (long)error.code], [error localizedDescription], error);
554
+ [self rejectPromiseWithBlock:reject unsupportedErrorDescription:@"Tried to present manage subscriptions sheet, but this functionality is only available on iOS 13.0 or greater."];
567
555
  }
568
556
  #else
569
557
  NSLog(@"[Purchases] Warning: tried to showManageSubscriptions in non-ios devices. That's not supported.");
570
- NSError *error = [self createUnsupportedErrorWithDescription:@"Tried to present manage subscriptions sheet, but this functionality is only available on iOS devices."];
571
- reject([NSString stringWithFormat:@"%ld", (long)error.code], [error localizedDescription], error);
558
+ [self rejectPromiseWithBlock:reject unsupportedErrorDescription:@"Tried to present manage subscriptions sheet, but this functionality is only available on iOS devices."];
572
559
  #endif
573
560
  }
574
561
 
@@ -657,8 +644,7 @@ RCT_EXPORT_METHOD(recordPurchaseForProductID:(nonnull NSString *)productID
657
644
  completion:[self getResponseCompletionBlockWithResolve:resolve
658
645
  reject:reject]];
659
646
  } else {
660
- NSError *error = [self createUnsupportedErrorWithDescription:@"Tried to handle transaction made by your app, but this functionality is only available on iOS 15.0 or greater."];
661
- reject([NSString stringWithFormat:@"%ld", (long) error.code], [error localizedDescription], error);
647
+ [self rejectPromiseWithBlock:reject unsupportedErrorDescription:@"Tried to handle transaction made by your app, but this functionality is only available on iOS 15.0 or greater."];
662
648
  }
663
649
  }
664
650
 
@@ -749,7 +735,15 @@ readyForPromotedProduct:(RCStoreProduct *)product
749
735
  #pragma mark Helper Methods
750
736
 
751
737
  - (void)rejectPromiseWithBlock:(RCTPromiseRejectBlock)reject error:(RCErrorContainer *)error {
752
- reject([NSString stringWithFormat:@"%ld", (long) error.code], error.message, error.error);
738
+ // React Native forwards only the NSError's userInfo to the JS layer, never the error
739
+ // container's info dictionary, so the payload has to travel inside userInfo.
740
+ NSMutableDictionary *userInfo = [error.error.userInfo mutableCopy];
741
+ [userInfo addEntriesFromDictionary:error.info];
742
+ NSError *errorWithInfo = [NSError errorWithDomain:error.error.domain
743
+ code:error.error.code
744
+ userInfo:userInfo];
745
+
746
+ reject([NSString stringWithFormat:@"%ld", (long) error.code], error.message, errorWithInfo);
753
747
  }
754
748
 
755
749
  - (void (^)(NSDictionary *, RCErrorContainer *))getResponseCompletionBlockWithResolve:(RCTPromiseResolveBlock)resolve
@@ -778,10 +772,12 @@ readyForPromotedProduct:(RCStoreProduct *)product
778
772
  };
779
773
  }
780
774
 
781
- - (NSError *)createUnsupportedErrorWithDescription:(NSString *)description {
782
- return [[NSError alloc] initWithDomain:RCPurchasesErrorCodeDomain
783
- code:RCUnsupportedError
784
- userInfo:@{NSLocalizedDescriptionKey : description}];
775
+ - (void)rejectPromiseWithBlock:(RCTPromiseRejectBlock)reject unsupportedErrorDescription:(NSString *)description {
776
+ NSError *error = [[NSError alloc] initWithDomain:RCPurchasesErrorCodeDomain
777
+ code:RCUnsupportedError
778
+ userInfo:@{NSLocalizedDescriptionKey : description}];
779
+ [self rejectPromiseWithBlock:reject
780
+ error:[[RCErrorContainer alloc] initWithError:error extraPayload:@{}]];
785
781
  }
786
782
 
787
783
  - (NSString *)platformFlavor {
@@ -789,7 +785,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
789
785
  }
790
786
 
791
787
  - (NSString *)platformFlavorVersion {
792
- return @"10.10.0";
788
+ return @"10.10.2";
793
789
  }
794
790
 
795
791
  @end
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-purchases",
3
3
  "title": "React Native Purchases",
4
- "version": "10.10.0",
4
+ "version": "10.10.2",
5
5
  "description": "React Native in-app purchases and subscriptions made easy. Supports iOS and Android. ",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -118,7 +118,7 @@
118
118
  ]
119
119
  },
120
120
  "dependencies": {
121
- "@revenuecat/purchases-js-hybrid-mappings": "19.0.0",
122
- "@revenuecat/purchases-typescript-internal": "19.0.0"
121
+ "@revenuecat/purchases-js-hybrid-mappings": "19.3.1",
122
+ "@revenuecat/purchases-typescript-internal": "19.3.1"
123
123
  }
124
124
  }