react-native-iap 11.0.0-alpha.6 → 11.0.0-alpha.7

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.
Files changed (91) hide show
  1. package/README.md +28 -112
  2. package/android/src/amazon/java/com/dooboolab/RNIap/RNIapAmazonModule.kt +1 -2
  3. package/ios/RNIapIos.swift +19 -9
  4. package/lib/commonjs/eventEmitter.js +9 -6
  5. package/lib/commonjs/eventEmitter.js.map +1 -1
  6. package/lib/commonjs/hooks/index.js +19 -0
  7. package/lib/commonjs/hooks/index.js.map +1 -0
  8. package/lib/commonjs/hooks/useIAP.js +8 -4
  9. package/lib/commonjs/hooks/useIAP.js.map +1 -1
  10. package/lib/commonjs/iap.js +81 -59
  11. package/lib/commonjs/iap.js.map +1 -1
  12. package/lib/commonjs/modules/amazon.js +12 -0
  13. package/lib/commonjs/modules/amazon.js.map +1 -0
  14. package/lib/commonjs/modules/android.js +12 -0
  15. package/lib/commonjs/modules/android.js.map +1 -0
  16. package/lib/commonjs/modules/common.js +2 -0
  17. package/lib/commonjs/modules/common.js.map +1 -0
  18. package/lib/commonjs/modules/index.js +58 -0
  19. package/lib/commonjs/modules/index.js.map +1 -0
  20. package/lib/commonjs/modules/ios.js +6 -0
  21. package/lib/commonjs/modules/ios.js.map +1 -0
  22. package/lib/commonjs/modules/iosSk2.js +6 -0
  23. package/lib/commonjs/modules/iosSk2.js.map +1 -0
  24. package/lib/commonjs/purchaseError.js +1 -0
  25. package/lib/commonjs/purchaseError.js.map +1 -1
  26. package/lib/commonjs/types/amazon.js.map +1 -1
  27. package/lib/commonjs/types/apple.js +0 -163
  28. package/lib/commonjs/types/apple.js.map +1 -1
  29. package/lib/commonjs/types/{appleSK2.js → appleSk2.js} +1 -1
  30. package/lib/commonjs/types/{appleSK2.js.map → appleSk2.js.map} +1 -1
  31. package/lib/commonjs/types/index.js +11 -1
  32. package/lib/commonjs/types/index.js.map +1 -1
  33. package/lib/module/eventEmitter.js +9 -5
  34. package/lib/module/eventEmitter.js.map +1 -1
  35. package/lib/module/hooks/index.js +2 -0
  36. package/lib/module/hooks/index.js.map +1 -0
  37. package/lib/module/hooks/useIAP.js +6 -4
  38. package/lib/module/hooks/useIAP.js.map +1 -1
  39. package/lib/module/iap.js +76 -49
  40. package/lib/module/iap.js.map +1 -1
  41. package/lib/module/modules/amazon.js +3 -0
  42. package/lib/module/modules/amazon.js.map +1 -0
  43. package/lib/module/modules/android.js +3 -0
  44. package/lib/module/modules/android.js.map +1 -0
  45. package/lib/module/modules/common.js +2 -0
  46. package/lib/module/modules/common.js.map +1 -0
  47. package/lib/module/modules/index.js +5 -0
  48. package/lib/module/modules/index.js.map +1 -0
  49. package/lib/module/modules/ios.js +2 -0
  50. package/lib/module/modules/ios.js.map +1 -0
  51. package/lib/module/modules/iosSk2.js +2 -0
  52. package/lib/module/modules/iosSk2.js.map +1 -0
  53. package/lib/module/purchaseError.js +1 -0
  54. package/lib/module/purchaseError.js.map +1 -1
  55. package/lib/module/types/amazon.js.map +1 -1
  56. package/lib/module/types/apple.js +0 -151
  57. package/lib/module/types/apple.js.map +1 -1
  58. package/lib/module/types/{appleSK2.js → appleSk2.js} +1 -1
  59. package/lib/module/types/{appleSK2.js.map → appleSk2.js.map} +1 -1
  60. package/lib/module/types/index.js +9 -0
  61. package/lib/module/types/index.js.map +1 -1
  62. package/lib/typescript/hooks/index.d.ts +1 -0
  63. package/lib/typescript/hooks/useIAP.d.ts +6 -3
  64. package/lib/typescript/iap.d.ts +23 -23
  65. package/lib/typescript/modules/amazon.d.ts +23 -0
  66. package/lib/typescript/modules/android.d.ts +24 -0
  67. package/lib/typescript/modules/common.d.ts +13 -0
  68. package/lib/typescript/modules/index.d.ts +4 -0
  69. package/lib/typescript/modules/ios.d.ts +32 -0
  70. package/lib/typescript/modules/iosSk2.d.ts +33 -0
  71. package/lib/typescript/purchaseError.d.ts +2 -1
  72. package/lib/typescript/types/amazon.d.ts +8 -0
  73. package/lib/typescript/types/apple.d.ts +0 -399
  74. package/lib/typescript/types/{appleSK2.d.ts → appleSk2.d.ts} +3 -3
  75. package/lib/typescript/types/index.d.ts +21 -0
  76. package/package.json +3 -1
  77. package/src/eventEmitter.ts +8 -8
  78. package/src/hooks/index.ts +1 -0
  79. package/src/hooks/useIAP.ts +11 -5
  80. package/src/iap.ts +114 -70
  81. package/src/modules/amazon.ts +40 -0
  82. package/src/modules/android.ts +65 -0
  83. package/src/modules/common.ts +16 -0
  84. package/src/modules/index.ts +4 -0
  85. package/src/modules/ios.ts +57 -0
  86. package/src/modules/iosSk2.ts +54 -0
  87. package/src/purchaseError.ts +1 -0
  88. package/src/types/amazon.ts +9 -0
  89. package/src/types/apple.ts +0 -438
  90. package/src/types/{appleSK2.ts → appleSk2.ts} +3 -3
  91. package/src/types/index.ts +32 -0
package/README.md CHANGED
@@ -1,23 +1,18 @@
1
- # ![image](https://user-images.githubusercontent.com/27461460/75094417-20321b00-55ce-11ea-8de7-a1df42a4b7df.png)
1
+ ![image](https://user-images.githubusercontent.com/27461460/75094417-20321b00-55ce-11ea-8de7-a1df42a4b7df.png)
2
+
3
+ ---
2
4
 
3
5
  [![Version](http://img.shields.io/npm/v/react-native-iap.svg?style=flat-square)](https://npmjs.org/package/react-native-iap)
4
6
  [![Next Version](https://img.shields.io/npm/v/react-native-iap/next)](https://npmjs.org/package/react-native-iap)
5
-
6
7
  [![Download](http://img.shields.io/npm/dm/react-native-iap.svg?style=flat-square)](https://npmjs.org/package/react-native-iap)
7
- [![CI](https://github.com/dooboolab/react-native-iap/actions/workflows/ci.yml/badge.svg)](https://github.com/dooboolab/react-native-iap/actions/workflows/ci.yml)
8
- [![document](https://github.com/dooboolab/react-native-iap/actions/workflows/deploy-documentation.yml/badge.svg)](https://github.com/dooboolab/react-native-iap/actions/workflows/deploy-documentation.yml)
9
- [![License](https://img.shields.io/npm/l/react-native-iap.svg)](https://npmjs.org/package/react-native-iap)
10
- [![Vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/dooboolab/react-native-iap.svg)](https://github.com/dooboolab/react-native-iap)
11
- [![Issue Opened](https://img.shields.io/opencollective/all/react-native-iap.svg)](https://opencollective.com/react-native-iap#backers)
12
- [![Issue Opened](https://img.shields.io/github/issues/dooboolab/react-native-iap.svg)](https://github.com/dooboolab/react-native-iap/issues)
13
- [![Issue Closed](https://img.shields.io/github/issues-closed/dooboolab/react-native-iap.svg)](https://github.com/dooboolab/react-native-iap/issues?q=is%3Aissue+is%3Aclosed)
14
- [![PR Opened](https://img.shields.io/github/issues-pr/dooboolab/react-native-iap.svg)](https://github.com/dooboolab/react-native-iap/pulls)
15
- [![PR Closed](https://img.shields.io/github/issues-pr-closed/dooboolab/react-native-iap.svg)](https://github.com/dooboolab/react-native-iap/pulls?q=is%3Apr+is%3Aclosed)
8
+ [![Backers and Sponsors](https://img.shields.io/opencollective/all/react-native-iap.svg)](https://opencollective.com/react-native-iap)
16
9
  [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fdooboolab%2Freact-native-iap.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fdooboolab%2Freact-native-iap?ref=badge_shield)
17
10
 
11
+ ---
12
+
18
13
  ## Documentation
19
14
 
20
- Published in [website](https://react-native-iap.dooboolab.com).
15
+ Read the [documentation](https://react-native-iap.dooboolab.com). See the [troubleshooting](https://react-native-iap.dooboolab.com/docs/guides/troubleshooting#common-issues) for the common issues to avoid.
21
16
 
22
17
  ## Our maintainers
23
18
 
@@ -54,109 +49,26 @@ Please [fund the project](https://opencollective.com/react-native-iap) if you ar
54
49
 
55
50
  - The sample code is out in [Sponsor page](https://github.com/hyochan/dooboolab.com/blob/main/src/components/pages/Sponsor.tsx) in [dooboolab.com](https://github.com/hyochan/dooboolab.com) repository which sadly is rejected by Apple because of lacking product features. I will work on another example project to support this module. More information in [#1241 commment](https://github.com/dooboolab/react-native-iap/issues/1241#issuecomment-798540785).
56
51
 
57
- ## Introduction
58
-
59
- This react-native module will help you access the In-app purchases capabilities of your phone on the `Android`, `iOS` platforms and the `Amazon` platform (Beta).
60
-
61
- **Keep in mind** `react-native-iap` will provide the basic features you need but is not a turnkey solution, implementing In-app purchases in your app will still require quite some work.<br/>
62
- Also, implementing the client side is only one side of the coin, you'll have to implement the server side to validate your receipts (which is probably the most time consuming part to do it correctly).
63
-
64
- If you're looking for a module going further than react-native-iap, we recommend using [react-native-iaphub](https://github.com/iaphub/react-native-iaphub) which is taking care of everything from the client side to the server side.
65
-
66
- ⚠️ Most of users experiencing issues are caused by:
67
-
68
- - A device simulator, use a real device for testing!
69
- - The sandbox environment of the project not being configured properly ([Configure android sandbox](https://www.iaphub.com/docs/set-up-android/configure-sandbox-testing), [Configure ios sandbox](https://www.iaphub.com/docs/set-up-ios/configure-sandbox-testing/))
70
- - An incorrect usage of the library
71
-
72
- ## Demo
73
-
74
- > ![demo.gif](https://user-images.githubusercontent.com/27461460/52619625-87aa8a80-2ee5-11e9-9aee-6691c34408f3.gif)
75
-
76
- <!-- Inline anchors -->
77
-
78
- [a-acknowledge-purchase-android]: #finishing-a-purchase
79
- [a-migration-guide]: #migration-guide
80
- [a-purchase-flow]: #new-purchase-flow
81
-
82
- <!-- Official Blog -->
83
-
84
- [blog-config-steps]: https://medium.com/p/121622d26b67
85
- [blog-v3-note]: https://medium.com/p/1259e0b0c017
86
-
87
- <!-- Internals -->
88
-
89
- [contribute]: https://github.com/dooboolab/react-native-iap/blob/main/CONTRIBUTING.md
90
- [example]: https://github.com/dooboolab/react-native-iap/tree/main/IapExample
91
- [issue-126-c1]: https://github.com/dooboolab/react-native-iap/issues/126#issuecomment-439084872
92
- [issue-174]: https://github.com/dooboolab/react-native-iap/issues/174
93
- [issue-203]: https://github.com/dooboolab/react-native-iap/issues/203
94
- [issue-237]: https://github.com/dooboolab/react-native-iap/issues/237
95
- [issue-256]: https://github.com/dooboolab/react-native-iap/issues/256
96
- [issue-263]: https://github.com/dooboolab/react-native-iap/issues/263
97
- [issue-283]: https://github.com/dooboolab/react-native-iap/issues/283
98
- [issue-307-c1]: https://github.com/dooboolab/react-native-iap/issues/307#issuecomment-447745027
99
- [issue-307]: https://github.com/dooboolab/react-native-iap/issues/307
100
- [open-collective-backer]: https://opencollective.com/react-native-iap#backer
101
- [open-collective-sponsor]: https://opencollective.com/react-native-iap#sponsor
102
- [open-collective]: https://opencollective.com/react-native-iap
103
- [readme-deprecated]: https://github.com/dooboolab/react-native-iap/blob/main/README_DEPRECATED.md
104
-
105
- <!-- Externals -->
106
-
107
- [android-acknowledge-purchase]: https://developer.android.com/reference/com/android/billingclient/api/BillingClient.html#acknowledgePurchase(com.android.billingclient.api.AcknowledgePurchaseParams,%20com.android.billingclient.api.AcknowledgePurchaseResponseListener) 'BillingClient#acknowledgePurchase()'
108
- [android-end-connection]: https://developer.android.com/reference/com/android/billingclient/api/BillingClient.html#endConnection() 'BillingClient#endConnection()'
109
- [android-iap-validation-guide]: https://developer.android.com/google/play/billing/billing_library_overview
110
- [android-migrate-androidx]: https://developer.android.com/jetpack/androidx/migrate
111
- [android-sku-details]: https://developer.android.com/reference/com/android/billingclient/api/SkuDetails
112
- [apple-iap-promoting]: https://developer.apple.com/app-store/promoting-in-app-purchases/
113
- [apple-iap-validation-guide]: https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html
114
- [apple-store-kit-flow]: https://forums.developer.apple.com/thread/6431#14831
115
- [google-api-nodejs-client]: https://github.com/googleapis/google-api-nodejs-client/
116
- [google-play-console]: https://play.google.com/apps/publish/
117
- [stackoverflow-android-iap-validation]: https://stackoverflow.com/questions/35127086
118
- [android-access-token-example-repo]: https://github.com/Bang9/android-get-access-token-example
119
-
120
- ## Quick News
52
+ ## Configuration of Play Store & App Store Connect
121
53
 
122
- - We had hard time supporting `react-native-iap` issues that did not provide working codes or any other examples. Therefore, we've decided to make an `example` app called [DoobooIAP](https://github.com/hyochan/DoobooIAP), which will contain all the features of `IAP`'s and willing to continuously improve to support real-life examples. [@Bang9](http://github.com/bang9) who had been helping many others for `react-native-iap`, is willing to support this repo so he will grant $300 of our income in `opencollective` as described in [#855](https://github.com/dooboolab/react-native-iap/issues/855) :tada:.
123
- - `react-native-iap@4.0.8` ~ `react-native-iap@4.1.0` is incompatible with `react-native <0.61`. This is fixed in `react-native-iap@4.1.1` and above.
124
- - `react-native-iap@4.0.0` has been released. You can see [#716](https://github.com/dooboolab/react-native-iap/pull/716) for updates.
125
- - In the past, `react-native-iap@^3.*` has been updated very promptly for migration issues.
126
- Don't get surprised too much on why it is bumping up version so quickly these days.
127
- 1. Migrated to new `AndroidX` APIs.
128
- 2. Migrated to new `Android` billing client which is `> 2.0.0`.
129
- - [`acknowledgePurchase()`][android-acknowledge-purchase] has been added since `3.2.0` which is very important.
130
- 3. New [Purchase Flow][a-purchase-flow]
131
- 4. More is coming in `iOS 13`.
54
+ - Please refer to this [Blog post](https://medium.com/p/121622d26b67).
132
55
 
133
- ## Breaking Changes
134
-
135
- [7.4.0]
136
-
137
- - Now using React's Context to manage IAP state
138
- - Introduce `withIAPContext` HOC ([how to use](docs/docs/usage_instructions/using_hooks.md))
139
-
140
- [7.1.0]
56
+ ## Example
141
57
 
142
- - `androidOldSku` is no longer required [#1438](https://github.com/dooboolab/react-native-iap/pull/1438).
58
+ Follow [this guide](./IapExample/README.md) to get the example running.
143
59
 
144
- [6.1.0]
60
+ ## Our maintainers
145
61
 
146
- - Creates two variants: `play` and `amazon` and only uses the required code.
147
- ```
148
- NOTE: This would be a breaking change with a very simple fix described in the documentation. To add: `missingDimensionStrategy 'store', 'play'` `in build.gradle`
149
- ```
150
- [3.0.0+]
151
- [react-native-iap V3 note][blog-v3-note]
62
+ Please [fund the project](https://opencollective.com/react-native-iap) if you are willing the maintainers to make the repository sustainable.
152
63
 
153
- ## Configuration of Google Play & iTunes Connect
64
+ - [andresesfm](https://github.com/andresesfm)
65
+ - [jeremybarbet](https://github.com/jeremybarbet)
154
66
 
155
- - Please refer to [Blog][blog-config-steps].
67
+ > The fund goes to maintainers.
156
68
 
157
- ## Example
69
+ ## Acknowledgements
158
70
 
159
- Follow [this guide](./IapExample/README.md) to get the example running.
71
+ If you're looking for a module going further than `react-native-iap`, we recommend using [react-native-iaphub](https://github.com/iaphub/react-native-iaphub) which is taking care of everything from the client-side to the server-side.
160
72
 
161
73
  ## Sponsoring
162
74
 
@@ -164,24 +76,28 @@ Since `IAP` itself is not perfect on each platform, we desperately need
164
76
  this project to be maintained. If you'd like to help us, please consider being
165
77
  with us in [Open Collective](https://opencollective.com/react-native-iap).
166
78
 
79
+ ### Supporter
80
+
81
+ - [hyochan](https://github.com/hyochan)
82
+
167
83
  ### Sponsors
168
84
 
169
85
  Support this project by becoming a sponsor. Your logo will show up here with
170
- a link to your website. [Become a sponsor][open-collective-sponsor].
171
- <a href="https://opencollective.com/react-native-iap#sponsors" target="_blank"><img src="https://opencollective.com/react-native-iap/sponsors.svg?width=890"></a>
86
+ a link to your website. [Become a sponsor](https://opencollective.com/react-native-iap#sponsor).
87
+ <a href="https://opencollective.com/react-native-iap#sponsors" target="_blank"><img src="https://opencollective.com/react-native-iap/sponsors.svg?width=890" /></a>
172
88
 
173
89
  ### Backers
174
90
 
175
- Please be our [Backers][open-collective-backer].
176
- <a href="https://opencollective.com/react-native-iap#backers" target="_blank"><img src="https://opencollective.com/react-native-iap/backers.svg?width=890"></a>
91
+ Please be our [Backers](https://opencollective.com/react-native-iap#backer).
92
+ <a href="https://opencollective.com/react-native-iap#backers" target="_blank"><img src="https://opencollective.com/react-native-iap/backers.svg?width=890" /></a>
177
93
 
178
94
  ### Contributing
179
95
 
180
- Please make sure to read the [Contributing Guide][contribute] before making a pull request.
96
+ Please make sure to read the [Contributing Guide](https://github.com/dooboolab/react-native-iap/blob/main/CONTRIBUTING.md) before making a pull request.
181
97
  Thank you to all the people who helped to maintain and upgrade this project!
182
98
 
183
99
  <a href="graphs/contributors"><img src="https://opencollective.com/react-native-iap/contributors.svg?width=890" /></a>
184
100
 
185
- <hr>
101
+ ---
186
102
 
187
103
  [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fdooboolab%2Freact-native-iap.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fdooboolab%2Freact-native-iap?ref=badge_large)
@@ -50,8 +50,7 @@ class RNIapAmazonModule(reactContext: ReactApplicationContext) :
50
50
  @ReactMethod
51
51
  fun flushFailedPurchasesCachedAsPending(promise: Promise) {
52
52
  // No-op
53
- val items = WritableNativeArray()
54
- promise.resolve(items)
53
+ promise.resolve(true)
55
54
  }
56
55
 
57
56
  @ReactMethod
@@ -301,6 +301,7 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
301
301
  }
302
302
  }
303
303
  if let prod = product {
304
+ addPromise(forKey: prod.productIdentifier, resolve: resolve, reject: reject)
304
305
  let payment = SKMutablePayment(product: prod)
305
306
  payment.quantity = quantity
306
307
  SKPaymentQueue.default().add(payment)
@@ -550,7 +551,13 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
550
551
  SKPaymentQueue.default().finishTransaction(transaction)
551
552
 
552
553
  myQueue.sync(execute: { [self] in
553
- let nsError = transaction.error as NSError?
554
+ var nsError = transaction.error as? NSError
555
+ // From https://developer.apple.com/forums/thread/674081
556
+ if let underlyingError = nsError?.userInfo["NSUnderlyingError"] as? NSError,
557
+ underlyingError.code == 3038 {
558
+ // General conditions have changed, don't display an error for the interrupted transaction
559
+ nsError = underlyingError
560
+ }
554
561
 
555
562
  if hasListeners {
556
563
  let code = nsError?.code
@@ -653,6 +660,9 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
653
660
  guard let code = code else {
654
661
  return descriptions[0]
655
662
  }
663
+ if code == 3038 { // Purchase interrupted so user can accept terms and conditions
664
+ return "E_INTERRUPTED"
665
+ }
656
666
 
657
667
  if code > descriptions.count - 1 || code < 0 { // Fix crash app without internet connection
658
668
  return descriptions[0]
@@ -714,15 +724,15 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
714
724
  switch product.introductoryPrice?.paymentMode {
715
725
  case .freeTrial:
716
726
  introductoryPricePaymentMode = "FREETRIAL"
717
- introductoryPriceNumberOfPeriods = NSNumber(value: product.introductoryPrice?.subscriptionPeriod.numberOfUnits ?? 0).stringValue
727
+ introductoryPriceNumberOfPeriods = String( product.introductoryPrice?.subscriptionPeriod.numberOfUnits ?? 0)
718
728
 
719
729
  case .payAsYouGo:
720
730
  introductoryPricePaymentMode = "PAYASYOUGO"
721
- introductoryPriceNumberOfPeriods = NSNumber(value: product.introductoryPrice?.numberOfPeriods ?? 0).stringValue
731
+ introductoryPriceNumberOfPeriods = String( product.introductoryPrice?.numberOfPeriods ?? 0)
722
732
 
723
733
  case .payUpFront:
724
734
  introductoryPricePaymentMode = "PAYUPFRONT"
725
- introductoryPriceNumberOfPeriods = NSNumber(value: product.introductoryPrice?.subscriptionPeriod.numberOfUnits ?? 0).stringValue
735
+ introductoryPriceNumberOfPeriods = String( product.introductoryPrice?.subscriptionPeriod.numberOfUnits ?? 0)
726
736
 
727
737
  default:
728
738
  introductoryPricePaymentMode = ""
@@ -799,8 +809,8 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
799
809
  let formatter = NumberFormatter()
800
810
  formatter.numberStyle = .currency
801
811
  let priceLocale: Locale? = discount.priceLocale
802
- if let pLocale = priceLocale {
803
- formatter.locale = pLocale
812
+ if let priceLocale = priceLocale {
813
+ formatter.locale = priceLocale
804
814
  }
805
815
  localizedPrice = formatter.string(from: discount.price)
806
816
  var numberOfPeriods: String?
@@ -808,17 +818,17 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
808
818
  switch discount.paymentMode {
809
819
  case .freeTrial:
810
820
  paymendMode = "FREETRIAL"
811
- numberOfPeriods = NSNumber(value: discount.subscriptionPeriod.numberOfUnits ).stringValue
821
+ numberOfPeriods = String(discount.subscriptionPeriod.numberOfUnits)
812
822
  break
813
823
 
814
824
  case .payAsYouGo:
815
825
  paymendMode = "PAYASYOUGO"
816
- numberOfPeriods = NSNumber(value: discount.numberOfPeriods).stringValue
826
+ numberOfPeriods = String(discount.numberOfPeriods)
817
827
  break
818
828
 
819
829
  case .payUpFront:
820
830
  paymendMode = "PAYUPFRONT"
821
- numberOfPeriods = NSNumber(value: discount.subscriptionPeriod.numberOfUnits ).stringValue
831
+ numberOfPeriods = String(discount.subscriptionPeriod.numberOfUnits )
822
832
  break
823
833
 
824
834
  default:
@@ -7,20 +7,19 @@ exports.purchaseUpdatedListener = exports.purchaseErrorListener = exports.promot
7
7
 
8
8
  var _reactNative = require("react-native");
9
9
 
10
- var _appleSK = require("./types/appleSK2");
10
+ var _appleSk = require("./types/appleSk2");
11
11
 
12
12
  var _iap = require("./iap");
13
13
 
14
14
  var _internal = require("./internal");
15
15
 
16
- const eventEmitter = new _reactNative.NativeEventEmitter((0, _iap.getNativeModule)());
17
16
  /**
18
17
  * Add IAP purchase event
19
18
  */
20
-
21
19
  const purchaseUpdatedListener = listener => {
20
+ const eventEmitter = new _reactNative.NativeEventEmitter((0, _iap.getNativeModule)());
22
21
  const proxyListener = (0, _iap.isIosStorekit2)() ? event => {
23
- listener((0, _appleSK.transactionSk2Map)(event));
22
+ listener((0, _appleSk.transactionSk2Map)(event));
24
23
  } : listener;
25
24
  const emitterSubscription = eventEmitter.addListener('purchase-updated', proxyListener);
26
25
 
@@ -37,7 +36,10 @@ const purchaseUpdatedListener = listener => {
37
36
 
38
37
  exports.purchaseUpdatedListener = purchaseUpdatedListener;
39
38
 
40
- const purchaseErrorListener = listener => eventEmitter.addListener('purchase-error', listener);
39
+ const purchaseErrorListener = listener => {
40
+ const eventEmitter = new _reactNative.NativeEventEmitter((0, _iap.getNativeModule)());
41
+ return eventEmitter.addListener('purchase-error', listener);
42
+ };
41
43
  /**
42
44
  * Add IAP promoted subscription event
43
45
  *
@@ -49,7 +51,8 @@ exports.purchaseErrorListener = purchaseErrorListener;
49
51
 
50
52
  const promotedProductListener = listener => {
51
53
  if (_internal.isIos) {
52
- return new _reactNative.NativeEventEmitter((0, _iap.getIosModule)()).addListener('iap-promoted-product', listener);
54
+ const eventEmitter = new _reactNative.NativeEventEmitter((0, _iap.getIosModule)());
55
+ return eventEmitter.addListener('iap-promoted-product', listener);
53
56
  }
54
57
 
55
58
  return null;
@@ -1 +1 @@
1
- {"version":3,"names":["eventEmitter","NativeEventEmitter","getNativeModule","purchaseUpdatedListener","listener","proxyListener","isIosStorekit2","event","transactionSk2Map","emitterSubscription","addListener","isAndroid","getAndroidModule","startListening","purchaseErrorListener","promotedProductListener","isIos","getIosModule"],"sources":["eventEmitter.ts"],"sourcesContent":["import {EmitterSubscription, NativeEventEmitter} from 'react-native';\n\nimport {transactionSk2Map} from './types/appleSK2';\nimport {\n getAndroidModule,\n getIosModule,\n getNativeModule,\n isIosStorekit2,\n} from './iap';\nimport {isAndroid, isIos} from './internal';\nimport type {PurchaseError} from './purchaseError';\nimport type {Purchase} from './types';\n\nconst eventEmitter = new NativeEventEmitter(getNativeModule());\n\n/**\n * Add IAP purchase event\n */\nexport const purchaseUpdatedListener = (\n listener: (event: Purchase) => void,\n) => {\n const proxyListener = isIosStorekit2()\n ? (event: Purchase) => {\n listener(transactionSk2Map(event as any));\n }\n : listener;\n const emitterSubscription = eventEmitter.addListener(\n 'purchase-updated',\n proxyListener,\n );\n\n if (isAndroid) {\n getAndroidModule().startListening();\n }\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n */\nexport const purchaseErrorListener = (\n listener: (error: PurchaseError) => void,\n): EmitterSubscription => eventEmitter.addListener('purchase-error', listener);\n\n/**\n * Add IAP promoted subscription event\n *\n * @platform iOS\n */\nexport const promotedProductListener = (listener: () => void) => {\n if (isIos) {\n return new NativeEventEmitter(getIosModule()).addListener(\n 'iap-promoted-product',\n listener,\n );\n }\n\n return null;\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAMA;;AAIA,MAAMA,YAAY,GAAG,IAAIC,+BAAJ,CAAuB,IAAAC,oBAAA,GAAvB,CAArB;AAEA;AACA;AACA;;AACO,MAAMC,uBAAuB,GAClCC,QADqC,IAElC;EACH,MAAMC,aAAa,GAAG,IAAAC,mBAAA,MACjBC,KAAD,IAAqB;IACnBH,QAAQ,CAAC,IAAAI,0BAAA,EAAkBD,KAAlB,CAAD,CAAR;EACD,CAHiB,GAIlBH,QAJJ;EAKA,MAAMK,mBAAmB,GAAGT,YAAY,CAACU,WAAb,CAC1B,kBAD0B,EAE1BL,aAF0B,CAA5B;;EAKA,IAAIM,mBAAJ,EAAe;IACb,IAAAC,qBAAA,IAAmBC,cAAnB;EACD;;EAED,OAAOJ,mBAAP;AACD,CAlBM;AAoBP;AACA;AACA;;;;;AACO,MAAMK,qBAAqB,GAChCV,QADmC,IAEXJ,YAAY,CAACU,WAAb,CAAyB,gBAAzB,EAA2CN,QAA3C,CAFnB;AAIP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMW,uBAAuB,GAAIX,QAAD,IAA0B;EAC/D,IAAIY,eAAJ,EAAW;IACT,OAAO,IAAIf,+BAAJ,CAAuB,IAAAgB,iBAAA,GAAvB,EAAuCP,WAAvC,CACL,sBADK,EAELN,QAFK,CAAP;EAID;;EAED,OAAO,IAAP;AACD,CATM"}
1
+ {"version":3,"names":["purchaseUpdatedListener","listener","eventEmitter","NativeEventEmitter","getNativeModule","proxyListener","isIosStorekit2","event","transactionSk2Map","emitterSubscription","addListener","isAndroid","getAndroidModule","startListening","purchaseErrorListener","promotedProductListener","isIos","getIosModule"],"sources":["eventEmitter.ts"],"sourcesContent":["import {EmitterSubscription, NativeEventEmitter} from 'react-native';\n\nimport {transactionSk2Map} from './types/appleSk2';\nimport {\n getAndroidModule,\n getIosModule,\n getNativeModule,\n isIosStorekit2,\n} from './iap';\nimport {isAndroid, isIos} from './internal';\nimport type {PurchaseError} from './purchaseError';\nimport type {Purchase} from './types';\n\n/**\n * Add IAP purchase event\n */\nexport const purchaseUpdatedListener = (\n listener: (event: Purchase) => void,\n) => {\n const eventEmitter = new NativeEventEmitter(getNativeModule());\n const proxyListener = isIosStorekit2()\n ? (event: Purchase) => {\n listener(transactionSk2Map(event as any));\n }\n : listener;\n const emitterSubscription = eventEmitter.addListener(\n 'purchase-updated',\n proxyListener,\n );\n\n if (isAndroid) {\n getAndroidModule().startListening();\n }\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n */\nexport const purchaseErrorListener = (\n listener: (error: PurchaseError) => void,\n): EmitterSubscription => {\n const eventEmitter = new NativeEventEmitter(getNativeModule());\n return eventEmitter.addListener('purchase-error', listener);\n};\n\n/**\n * Add IAP promoted subscription event\n *\n * @platform iOS\n */\nexport const promotedProductListener = (listener: () => void) => {\n if (isIos) {\n const eventEmitter = new NativeEventEmitter(getIosModule());\n return eventEmitter.addListener('iap-promoted-product', listener);\n }\n\n return null;\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAMA;;AAIA;AACA;AACA;AACO,MAAMA,uBAAuB,GAClCC,QADqC,IAElC;EACH,MAAMC,YAAY,GAAG,IAAIC,+BAAJ,CAAuB,IAAAC,oBAAA,GAAvB,CAArB;EACA,MAAMC,aAAa,GAAG,IAAAC,mBAAA,MACjBC,KAAD,IAAqB;IACnBN,QAAQ,CAAC,IAAAO,0BAAA,EAAkBD,KAAlB,CAAD,CAAR;EACD,CAHiB,GAIlBN,QAJJ;EAKA,MAAMQ,mBAAmB,GAAGP,YAAY,CAACQ,WAAb,CAC1B,kBAD0B,EAE1BL,aAF0B,CAA5B;;EAKA,IAAIM,mBAAJ,EAAe;IACb,IAAAC,qBAAA,IAAmBC,cAAnB;EACD;;EAED,OAAOJ,mBAAP;AACD,CAnBM;AAqBP;AACA;AACA;;;;;AACO,MAAMK,qBAAqB,GAChCb,QADmC,IAEX;EACxB,MAAMC,YAAY,GAAG,IAAIC,+BAAJ,CAAuB,IAAAC,oBAAA,GAAvB,CAArB;EACA,OAAOF,YAAY,CAACQ,WAAb,CAAyB,gBAAzB,EAA2CT,QAA3C,CAAP;AACD,CALM;AAOP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMc,uBAAuB,GAAId,QAAD,IAA0B;EAC/D,IAAIe,eAAJ,EAAW;IACT,MAAMd,YAAY,GAAG,IAAIC,+BAAJ,CAAuB,IAAAc,iBAAA,GAAvB,CAArB;IACA,OAAOf,YAAY,CAACQ,WAAb,CAAyB,sBAAzB,EAAiDT,QAAjD,CAAP;EACD;;EAED,OAAO,IAAP;AACD,CAPM"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _useIAP = require("./useIAP");
8
+
9
+ Object.keys(_useIAP).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _useIAP[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _useIAP[key];
16
+ }
17
+ });
18
+ });
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './useIAP';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useIAP = useIAP;
6
+ exports.useIAP = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
@@ -11,7 +11,7 @@ var _iap = require("../iap");
11
11
 
12
12
  var _withIAPContext = require("./withIAPContext");
13
13
 
14
- function useIAP() {
14
+ const useIAP = () => {
15
15
  const {
16
16
  connected,
17
17
  products,
@@ -90,7 +90,11 @@ function useIAP() {
90
90
  getProducts,
91
91
  getSubscriptions,
92
92
  getAvailablePurchases,
93
- getPurchaseHistory
93
+ getPurchaseHistory,
94
+ requestPurchase: _iap.requestPurchase,
95
+ requestSubscription: _iap.requestSubscription
94
96
  };
95
- }
97
+ };
98
+
99
+ exports.useIAP = useIAP;
96
100
  //# sourceMappingURL=useIAP.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useIAP","connected","products","promotedProductsIOS","subscriptions","purchaseHistory","availablePurchases","currentPurchase","currentPurchaseError","initConnectionError","setProducts","setSubscriptions","setAvailablePurchases","setPurchaseHistory","setCurrentPurchase","setCurrentPurchaseError","useIAPContext","getProducts","useCallback","skus","iapGetProducts","getSubscriptions","iapGetSubscriptions","getAvailablePurchases","iapGetAvailablePurchases","getPurchaseHistory","iapGetPurchaseHistory","finishTransaction","purchase","isConsumable","developerPayloadAndroid","iapFinishTransaction","err","productId","undefined"],"sources":["useIAP.ts"],"sourcesContent":["import {useCallback} from 'react';\n\nimport {\n finishTransaction as iapFinishTransaction,\n getAvailablePurchases as iapGetAvailablePurchases,\n getProducts as iapGetProducts,\n getPurchaseHistory as iapGetPurchaseHistory,\n getSubscriptions as iapGetSubscriptions,\n} from '../iap';\nimport type {PurchaseError} from '../purchaseError';\nimport type {Product, Purchase, Subscription} from '../types';\n\nimport {useIAPContext} from './withIAPContext';\n\ntype IAP_STATUS = {\n connected: boolean;\n products: Product[];\n promotedProductsIOS: Product[];\n subscriptions: Subscription[];\n purchaseHistory: Purchase[];\n availablePurchases: Purchase[];\n currentPurchase?: Purchase;\n currentPurchaseError?: PurchaseError;\n initConnectionError?: Error;\n finishTransaction: ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n }) => Promise<string | void>;\n getAvailablePurchases: () => Promise<void>;\n getPurchaseHistory: () => Promise<void>;\n getProducts: ({skus}: {skus: string[]}) => Promise<void>;\n getSubscriptions: ({skus}: {skus: string[]}) => Promise<void>;\n};\n\nexport function useIAP(): IAP_STATUS {\n const {\n connected,\n products,\n promotedProductsIOS,\n subscriptions,\n purchaseHistory,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n setProducts,\n setSubscriptions,\n setAvailablePurchases,\n setPurchaseHistory,\n setCurrentPurchase,\n setCurrentPurchaseError,\n } = useIAPContext();\n\n const getProducts = useCallback(\n async ({skus}: {skus: string[]}): Promise<void> => {\n setProducts(await iapGetProducts({skus}));\n },\n [setProducts],\n );\n\n const getSubscriptions = useCallback(\n async ({skus}: {skus: string[]}): Promise<void> => {\n setSubscriptions(await iapGetSubscriptions({skus}));\n },\n [setSubscriptions],\n );\n\n const getAvailablePurchases = useCallback(async (): Promise<void> => {\n setAvailablePurchases(await iapGetAvailablePurchases());\n }, [setAvailablePurchases]);\n\n const getPurchaseHistory = useCallback(async (): Promise<void> => {\n setPurchaseHistory(await iapGetPurchaseHistory());\n }, [setPurchaseHistory]);\n\n const finishTransaction = useCallback(\n async ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n }): Promise<string | void> => {\n try {\n return await iapFinishTransaction({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n });\n } catch (err) {\n throw err;\n } finally {\n if (purchase.productId === currentPurchase?.productId) {\n setCurrentPurchase(undefined);\n }\n\n if (purchase.productId === currentPurchaseError?.productId) {\n setCurrentPurchaseError(undefined);\n }\n }\n },\n [\n currentPurchase?.productId,\n currentPurchaseError?.productId,\n setCurrentPurchase,\n setCurrentPurchaseError,\n ],\n );\n\n return {\n connected,\n products,\n promotedProductsIOS,\n subscriptions,\n purchaseHistory,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n finishTransaction,\n getProducts,\n getSubscriptions,\n getAvailablePurchases,\n getPurchaseHistory,\n };\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAUA;;AA2BO,SAASA,MAAT,GAA8B;EACnC,MAAM;IACJC,SADI;IAEJC,QAFI;IAGJC,mBAHI;IAI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Q,CAACK,SAAT,MAAuB1B,eAAvB,aAAuBA,eAAvB,uBAAuBA,eAAe,CAAE0B,SAAxC,CAAJ,EAAuD;QACrDnB,kBAAkB,CAACoB,SAAD,CAAlB;MACD;;MAED,IAAIN,QAAQ,CAACK,SAAT,MAAuBzB,oBAAvB,aAAuBA,oBAAvB,uBAAuBA,oBAAoB,CAAEyB,SAA7C,CAAJ,EAA4D;QAC1DlB,uBAAuB,CAACmB,SAAD,CAAvB;MACD;IACF;EACF,CA3BuB,EA4BxB,CACE3B,eADF,aACEA,eADF,uBACEA,eAAe,CAAE0B,SADnB,EAEEzB,oBAFF,aAEEA,oBAFF,uBAEEA,oBAAoB,CAAEyB,SAFxB,EAGEnB,kBAHF,EAIEC,uBAJF,CA5BwB,CAA1B;EAoCA,OAAO;IACLd,SADK;IAELC,QAFK;IAGLC,mBAHK;IAILC,aAJK;IAKLC,eALK;IAMLC,kBANK;IAOLC,eAPK;IAQLC,oBARK;IASLC,mBATK;IAULkB,iBAVK;IAWLV,WAXK;IAYLI,gBAZK;IAaLE,qBAbK;IAcLE;EAdK,CAAP;AAgBD"}
1
+ {"version":3,"names":["useIAP","connected","products","promotedProductsIOS","subscriptions","purchaseHistory","availablePurchases","currentPurchase","currentPurchaseError","initConnectionError","setProducts","setSubscriptions","setAvailablePurchases","setPurchaseHistory","setCurrentPurchase","setCurrentPurchaseError","useIAPContext","getProducts","useCallback","skus","iapGetProducts","getSubscriptions","iapGetSubscriptions","getAvailablePurchases","iapGetAvailablePurchases","getPurchaseHistory","iapGetPurchaseHistory","finishTransaction","purchase","isConsumable","developerPayloadAndroid","iapFinishTransaction","err","productId","undefined","requestPurchase","iapRequestPurchase","requestSubscription","iapRequestSubscription"],"sources":["useIAP.ts"],"sourcesContent":["import {useCallback} from 'react';\n\nimport {\n finishTransaction as iapFinishTransaction,\n getAvailablePurchases as iapGetAvailablePurchases,\n getProducts as iapGetProducts,\n getPurchaseHistory as iapGetPurchaseHistory,\n getSubscriptions as iapGetSubscriptions,\n requestPurchase as iapRequestPurchase,\n requestSubscription as iapRequestSubscription,\n} from '../iap';\nimport type {PurchaseError} from '../purchaseError';\nimport type {Product, Purchase, PurchaseResult, Subscription} from '../types';\n\nimport {useIAPContext} from './withIAPContext';\n\ntype IAP_STATUS = {\n connected: boolean;\n products: Product[];\n promotedProductsIOS: Product[];\n subscriptions: Subscription[];\n purchaseHistory: Purchase[];\n availablePurchases: Purchase[];\n currentPurchase?: Purchase;\n currentPurchaseError?: PurchaseError;\n initConnectionError?: Error;\n finishTransaction: ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n }) => Promise<string | boolean | PurchaseResult | void>;\n getAvailablePurchases: () => Promise<void>;\n getPurchaseHistory: () => Promise<void>;\n getProducts: ({skus}: {skus: string[]}) => Promise<void>;\n getSubscriptions: ({skus}: {skus: string[]}) => Promise<void>;\n requestPurchase: typeof iapRequestPurchase;\n requestSubscription: typeof iapRequestSubscription;\n};\n\nexport const useIAP = (): IAP_STATUS => {\n const {\n connected,\n products,\n promotedProductsIOS,\n subscriptions,\n purchaseHistory,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n setProducts,\n setSubscriptions,\n setAvailablePurchases,\n setPurchaseHistory,\n setCurrentPurchase,\n setCurrentPurchaseError,\n } = useIAPContext();\n\n const getProducts = useCallback(\n async ({skus}: {skus: string[]}): Promise<void> => {\n setProducts(await iapGetProducts({skus}));\n },\n [setProducts],\n );\n\n const getSubscriptions = useCallback(\n async ({skus}: {skus: string[]}): Promise<void> => {\n setSubscriptions(await iapGetSubscriptions({skus}));\n },\n [setSubscriptions],\n );\n\n const getAvailablePurchases = useCallback(async (): Promise<void> => {\n setAvailablePurchases(await iapGetAvailablePurchases());\n }, [setAvailablePurchases]);\n\n const getPurchaseHistory = useCallback(async (): Promise<void> => {\n setPurchaseHistory(await iapGetPurchaseHistory());\n }, [setPurchaseHistory]);\n\n const finishTransaction = useCallback(\n async ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n }): Promise<string | boolean | PurchaseResult | void> => {\n try {\n return await iapFinishTransaction({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n });\n } catch (err) {\n throw err;\n } finally {\n if (purchase.productId === currentPurchase?.productId) {\n setCurrentPurchase(undefined);\n }\n\n if (purchase.productId === currentPurchaseError?.productId) {\n setCurrentPurchaseError(undefined);\n }\n }\n },\n [\n currentPurchase?.productId,\n currentPurchaseError?.productId,\n setCurrentPurchase,\n setCurrentPurchaseError,\n ],\n );\n\n return {\n connected,\n products,\n promotedProductsIOS,\n subscriptions,\n purchaseHistory,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n finishTransaction,\n getProducts,\n getSubscriptions,\n getAvailablePurchases,\n getPurchaseHistory,\n requestPurchase: iapRequestPurchase,\n requestSubscription: iapRequestSubscription,\n };\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAYA;;AA6BO,MAAMA,MAAM,GAAG,MAAkB;EACtC,MAAM;IACJC,SADI;IAEJC,QAFI;IAGJC,mBAHI;IAIJC,aAJI;IAKJC,eALI;IAMJC,kBANI;IAOJC,eAPI;IAQJC,oBARI;IASJC,mBATI;IAUJC,WAVI;IAWJC,gBAXI;IAYJC,qBAZI;IAaJC,kBAbI;IAcJC,kBAdI;IAeJC;EAfI,IAgBF,IAAAC,6BAAA,GAhBJ;EAkBA,MAAMC,WAAW,GAAG,IAAAC,kBAAA,EAClB,cAAmD;IAAA,IAA5C;MAACC;IAAD,CAA4C;IACjDT,WAAW,CAAC,MAAM,IAAAU,gBAAA,EAAe;MAACD;IAAD,CAAf,CAAP,CAAX;EACD,CAHiB,EAIlB,CAACT,WAAD,CAJkB,CAApB;EAOA,MAAMW,gBAAgB,GAAG,IAAAH,kBAAA,EACvB,eAAmD;IAAA,IAA5C;MAACC;IA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