@chipmobilesdk/rn-payment 0.6.0 → 0.7.0

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 (295) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/README.md +1 -1
  3. package/lib/commonjs/adapter/createStoreProvider.js +110 -0
  4. package/lib/commonjs/adapter/createStoreProvider.js.map +1 -0
  5. package/lib/commonjs/adapter/iap-adapter.js +393 -0
  6. package/lib/commonjs/adapter/iap-adapter.js.map +1 -0
  7. package/lib/commonjs/adapter/iapShapes.js +169 -0
  8. package/lib/commonjs/adapter/iapShapes.js.map +1 -0
  9. package/lib/commonjs/adapter/port.js +6 -0
  10. package/lib/commonjs/adapter/port.js.map +1 -0
  11. package/lib/commonjs/config/types.js +2 -0
  12. package/lib/commonjs/config/types.js.map +1 -0
  13. package/lib/commonjs/config/validate.js +181 -0
  14. package/lib/commonjs/config/validate.js.map +1 -0
  15. package/lib/commonjs/core/mutex.js +31 -0
  16. package/lib/commonjs/core/mutex.js.map +1 -0
  17. package/lib/commonjs/core/retry.js +37 -0
  18. package/lib/commonjs/core/retry.js.map +1 -0
  19. package/lib/commonjs/core/timers.js +207 -0
  20. package/lib/commonjs/core/timers.js.map +1 -0
  21. package/lib/commonjs/diagnostics/errors.js +83 -0
  22. package/lib/commonjs/diagnostics/errors.js.map +1 -0
  23. package/lib/commonjs/diagnostics/events.js +126 -0
  24. package/lib/commonjs/diagnostics/events.js.map +1 -0
  25. package/lib/commonjs/diagnostics/messageKeys.js +70 -0
  26. package/lib/commonjs/diagnostics/messageKeys.js.map +1 -0
  27. package/lib/commonjs/engine/connection.js +189 -0
  28. package/lib/commonjs/engine/connection.js.map +1 -0
  29. package/lib/commonjs/engine/engine.js +279 -0
  30. package/lib/commonjs/engine/engine.js.map +1 -0
  31. package/lib/commonjs/engine/finalize.js +325 -0
  32. package/lib/commonjs/engine/finalize.js.map +1 -0
  33. package/lib/commonjs/engine/foreground.js +26 -0
  34. package/lib/commonjs/engine/foreground.js.map +1 -0
  35. package/lib/commonjs/engine/internals.js +31 -0
  36. package/lib/commonjs/engine/internals.js.map +1 -0
  37. package/lib/commonjs/engine/pending.js +102 -0
  38. package/lib/commonjs/engine/pending.js.map +1 -0
  39. package/lib/commonjs/engine/products.js +198 -0
  40. package/lib/commonjs/engine/products.js.map +1 -0
  41. package/lib/commonjs/engine/purchase.js +395 -0
  42. package/lib/commonjs/engine/purchase.js.map +1 -0
  43. package/lib/commonjs/engine/purchaseFailure.js +77 -0
  44. package/lib/commonjs/engine/purchaseFailure.js.map +1 -0
  45. package/lib/commonjs/engine/receiptValidation.js +90 -0
  46. package/lib/commonjs/engine/receiptValidation.js.map +1 -0
  47. package/lib/commonjs/engine/state.js +201 -0
  48. package/lib/commonjs/engine/state.js.map +1 -0
  49. package/lib/commonjs/engine/subscriptions.js +122 -0
  50. package/lib/commonjs/engine/subscriptions.js.map +1 -0
  51. package/lib/commonjs/engine/sync.js +163 -0
  52. package/lib/commonjs/engine/sync.js.map +1 -0
  53. package/lib/commonjs/entitlements/aggregate.js +212 -0
  54. package/lib/commonjs/entitlements/aggregate.js.map +1 -0
  55. package/lib/commonjs/entitlements/mapping.js +41 -0
  56. package/lib/commonjs/entitlements/mapping.js.map +1 -0
  57. package/lib/commonjs/entitlements/policy.js +110 -0
  58. package/lib/commonjs/entitlements/policy.js.map +1 -0
  59. package/lib/commonjs/index.js +266 -0
  60. package/lib/commonjs/index.js.map +1 -0
  61. package/lib/commonjs/package.json +1 -0
  62. package/lib/commonjs/persistence/mmkv-store.js +149 -0
  63. package/lib/commonjs/persistence/mmkv-store.js.map +1 -0
  64. package/lib/commonjs/persistence/snapshot.js +229 -0
  65. package/lib/commonjs/persistence/snapshot.js.map +1 -0
  66. package/lib/commonjs/react/PaymentProvider.js +96 -0
  67. package/lib/commonjs/react/PaymentProvider.js.map +1 -0
  68. package/lib/commonjs/react/hooks.js +202 -0
  69. package/lib/commonjs/react/hooks.js.map +1 -0
  70. package/lib/commonjs/testing/conformance.js +136 -0
  71. package/lib/commonjs/testing/conformance.js.map +1 -0
  72. package/lib/commonjs/testing/fakeStore.js +281 -0
  73. package/lib/commonjs/testing/fakeStore.js.map +1 -0
  74. package/lib/commonjs/testing/index.js +45 -0
  75. package/lib/commonjs/testing/index.js.map +1 -0
  76. package/lib/module/adapter/createStoreProvider.js +106 -0
  77. package/lib/module/adapter/createStoreProvider.js.map +1 -0
  78. package/lib/module/adapter/iap-adapter.js +383 -0
  79. package/lib/module/adapter/iap-adapter.js.map +1 -0
  80. package/lib/module/adapter/iapShapes.js +160 -0
  81. package/lib/module/adapter/iapShapes.js.map +1 -0
  82. package/lib/module/adapter/port.js +4 -0
  83. package/lib/module/adapter/port.js.map +1 -0
  84. package/lib/module/config/types.js +2 -0
  85. package/lib/module/config/types.js.map +1 -0
  86. package/lib/module/config/validate.js +175 -0
  87. package/lib/module/config/validate.js.map +1 -0
  88. package/lib/module/core/mutex.js +22 -0
  89. package/lib/module/core/mutex.js.map +1 -0
  90. package/lib/module/core/retry.js +33 -0
  91. package/lib/module/core/retry.js.map +1 -0
  92. package/lib/module/core/timers.js +198 -0
  93. package/lib/module/core/timers.js.map +1 -0
  94. package/lib/module/diagnostics/errors.js +76 -0
  95. package/lib/module/diagnostics/errors.js.map +1 -0
  96. package/lib/module/diagnostics/events.js +117 -0
  97. package/lib/module/diagnostics/events.js.map +1 -0
  98. package/lib/module/diagnostics/messageKeys.js +64 -0
  99. package/lib/module/diagnostics/messageKeys.js.map +1 -0
  100. package/lib/module/engine/connection.js +185 -0
  101. package/lib/module/engine/connection.js.map +1 -0
  102. package/lib/module/engine/engine.js +274 -0
  103. package/lib/module/engine/engine.js.map +1 -0
  104. package/lib/module/engine/finalize.js +322 -0
  105. package/lib/module/engine/finalize.js.map +1 -0
  106. package/lib/module/engine/foreground.js +21 -0
  107. package/lib/module/engine/foreground.js.map +1 -0
  108. package/lib/module/engine/internals.js +26 -0
  109. package/lib/module/engine/internals.js.map +1 -0
  110. package/lib/module/engine/pending.js +95 -0
  111. package/lib/module/engine/pending.js.map +1 -0
  112. package/lib/module/engine/products.js +195 -0
  113. package/lib/module/engine/products.js.map +1 -0
  114. package/lib/module/engine/purchase.js +390 -0
  115. package/lib/module/engine/purchase.js.map +1 -0
  116. package/lib/module/engine/purchaseFailure.js +72 -0
  117. package/lib/module/engine/purchaseFailure.js.map +1 -0
  118. package/lib/module/engine/receiptValidation.js +87 -0
  119. package/lib/module/engine/receiptValidation.js.map +1 -0
  120. package/lib/module/engine/state.js +196 -0
  121. package/lib/module/engine/state.js.map +1 -0
  122. package/lib/module/engine/subscriptions.js +119 -0
  123. package/lib/module/engine/subscriptions.js.map +1 -0
  124. package/lib/module/engine/sync.js +158 -0
  125. package/lib/module/engine/sync.js.map +1 -0
  126. package/lib/module/entitlements/aggregate.js +204 -0
  127. package/lib/module/entitlements/aggregate.js.map +1 -0
  128. package/lib/module/entitlements/mapping.js +35 -0
  129. package/lib/module/entitlements/mapping.js.map +1 -0
  130. package/lib/module/entitlements/policy.js +104 -0
  131. package/lib/module/entitlements/policy.js.map +1 -0
  132. package/lib/module/index.js +59 -0
  133. package/lib/module/index.js.map +1 -0
  134. package/lib/module/package.json +1 -0
  135. package/lib/module/persistence/mmkv-store.js +144 -0
  136. package/lib/module/persistence/mmkv-store.js.map +1 -0
  137. package/lib/module/persistence/snapshot.js +221 -0
  138. package/lib/module/persistence/snapshot.js.map +1 -0
  139. package/lib/module/react/PaymentProvider.js +90 -0
  140. package/lib/module/react/PaymentProvider.js.map +1 -0
  141. package/lib/module/react/hooks.js +192 -0
  142. package/lib/module/react/hooks.js.map +1 -0
  143. package/lib/module/testing/conformance.js +130 -0
  144. package/lib/module/testing/conformance.js.map +1 -0
  145. package/lib/module/testing/fakeStore.js +276 -0
  146. package/lib/module/testing/fakeStore.js.map +1 -0
  147. package/lib/module/testing/index.js +13 -0
  148. package/lib/module/testing/index.js.map +1 -0
  149. package/lib/typescript/commonjs/adapter/createStoreProvider.d.ts +45 -0
  150. package/lib/typescript/commonjs/adapter/createStoreProvider.d.ts.map +1 -0
  151. package/lib/typescript/commonjs/adapter/iap-adapter.d.ts +80 -0
  152. package/lib/typescript/commonjs/adapter/iap-adapter.d.ts.map +1 -0
  153. package/lib/typescript/commonjs/adapter/iapShapes.d.ts +94 -0
  154. package/lib/typescript/commonjs/adapter/iapShapes.d.ts.map +1 -0
  155. package/lib/typescript/commonjs/adapter/port.d.ts +184 -0
  156. package/lib/typescript/commonjs/adapter/port.d.ts.map +1 -0
  157. package/lib/typescript/commonjs/config/types.d.ts +326 -0
  158. package/lib/typescript/commonjs/config/types.d.ts.map +1 -0
  159. package/lib/typescript/commonjs/config/validate.d.ts +63 -0
  160. package/lib/typescript/commonjs/config/validate.d.ts.map +1 -0
  161. package/lib/typescript/commonjs/core/mutex.d.ts +17 -0
  162. package/lib/typescript/commonjs/core/mutex.d.ts.map +1 -0
  163. package/lib/typescript/commonjs/core/retry.d.ts +19 -0
  164. package/lib/typescript/commonjs/core/retry.d.ts.map +1 -0
  165. package/lib/typescript/commonjs/core/timers.d.ts +142 -0
  166. package/lib/typescript/commonjs/core/timers.d.ts.map +1 -0
  167. package/lib/typescript/commonjs/diagnostics/errors.d.ts +55 -0
  168. package/lib/typescript/commonjs/diagnostics/errors.d.ts.map +1 -0
  169. package/lib/typescript/commonjs/diagnostics/events.d.ts +158 -0
  170. package/lib/typescript/commonjs/diagnostics/events.d.ts.map +1 -0
  171. package/lib/typescript/commonjs/diagnostics/messageKeys.d.ts +54 -0
  172. package/lib/typescript/commonjs/diagnostics/messageKeys.d.ts.map +1 -0
  173. package/lib/typescript/commonjs/engine/connection.d.ts +30 -0
  174. package/lib/typescript/commonjs/engine/connection.d.ts.map +1 -0
  175. package/lib/typescript/commonjs/engine/engine.d.ts +93 -0
  176. package/lib/typescript/commonjs/engine/engine.d.ts.map +1 -0
  177. package/lib/typescript/commonjs/engine/finalize.d.ts +53 -0
  178. package/lib/typescript/commonjs/engine/finalize.d.ts.map +1 -0
  179. package/lib/typescript/commonjs/engine/foreground.d.ts +15 -0
  180. package/lib/typescript/commonjs/engine/foreground.d.ts.map +1 -0
  181. package/lib/typescript/commonjs/engine/internals.d.ts +28 -0
  182. package/lib/typescript/commonjs/engine/internals.d.ts.map +1 -0
  183. package/lib/typescript/commonjs/engine/pending.d.ts +51 -0
  184. package/lib/typescript/commonjs/engine/pending.d.ts.map +1 -0
  185. package/lib/typescript/commonjs/engine/products.d.ts +82 -0
  186. package/lib/typescript/commonjs/engine/products.d.ts.map +1 -0
  187. package/lib/typescript/commonjs/engine/purchase.d.ts +61 -0
  188. package/lib/typescript/commonjs/engine/purchase.d.ts.map +1 -0
  189. package/lib/typescript/commonjs/engine/purchaseFailure.d.ts +15 -0
  190. package/lib/typescript/commonjs/engine/purchaseFailure.d.ts.map +1 -0
  191. package/lib/typescript/commonjs/engine/receiptValidation.d.ts +42 -0
  192. package/lib/typescript/commonjs/engine/receiptValidation.d.ts.map +1 -0
  193. package/lib/typescript/commonjs/engine/state.d.ts +46 -0
  194. package/lib/typescript/commonjs/engine/state.d.ts.map +1 -0
  195. package/lib/typescript/commonjs/engine/subscriptions.d.ts +61 -0
  196. package/lib/typescript/commonjs/engine/subscriptions.d.ts.map +1 -0
  197. package/lib/typescript/commonjs/engine/sync.d.ts +36 -0
  198. package/lib/typescript/commonjs/engine/sync.d.ts.map +1 -0
  199. package/lib/typescript/commonjs/entitlements/aggregate.d.ts +97 -0
  200. package/lib/typescript/commonjs/entitlements/aggregate.d.ts.map +1 -0
  201. package/lib/typescript/commonjs/entitlements/mapping.d.ts +27 -0
  202. package/lib/typescript/commonjs/entitlements/mapping.d.ts.map +1 -0
  203. package/lib/typescript/commonjs/entitlements/policy.d.ts +75 -0
  204. package/lib/typescript/commonjs/entitlements/policy.d.ts.map +1 -0
  205. package/lib/typescript/commonjs/index.d.ts +44 -0
  206. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  207. package/lib/typescript/commonjs/package.json +1 -0
  208. package/lib/typescript/commonjs/persistence/mmkv-store.d.ts +45 -0
  209. package/lib/typescript/commonjs/persistence/mmkv-store.d.ts.map +1 -0
  210. package/lib/typescript/commonjs/persistence/snapshot.d.ts +106 -0
  211. package/lib/typescript/commonjs/persistence/snapshot.d.ts.map +1 -0
  212. package/lib/typescript/commonjs/react/PaymentProvider.d.ts +57 -0
  213. package/lib/typescript/commonjs/react/PaymentProvider.d.ts.map +1 -0
  214. package/lib/typescript/commonjs/react/hooks.d.ts +80 -0
  215. package/lib/typescript/commonjs/react/hooks.d.ts.map +1 -0
  216. package/lib/typescript/commonjs/testing/conformance.d.ts +41 -0
  217. package/lib/typescript/commonjs/testing/conformance.d.ts.map +1 -0
  218. package/lib/typescript/commonjs/testing/fakeStore.d.ts +69 -0
  219. package/lib/typescript/commonjs/testing/fakeStore.d.ts.map +1 -0
  220. package/lib/typescript/commonjs/testing/index.d.ts +12 -0
  221. package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
  222. package/lib/typescript/module/adapter/createStoreProvider.d.ts +45 -0
  223. package/lib/typescript/module/adapter/createStoreProvider.d.ts.map +1 -0
  224. package/lib/typescript/module/adapter/iap-adapter.d.ts +80 -0
  225. package/lib/typescript/module/adapter/iap-adapter.d.ts.map +1 -0
  226. package/lib/typescript/module/adapter/iapShapes.d.ts +94 -0
  227. package/lib/typescript/module/adapter/iapShapes.d.ts.map +1 -0
  228. package/lib/typescript/module/adapter/port.d.ts +184 -0
  229. package/lib/typescript/module/adapter/port.d.ts.map +1 -0
  230. package/lib/typescript/module/config/types.d.ts +326 -0
  231. package/lib/typescript/module/config/types.d.ts.map +1 -0
  232. package/lib/typescript/module/config/validate.d.ts +63 -0
  233. package/lib/typescript/module/config/validate.d.ts.map +1 -0
  234. package/lib/typescript/module/core/mutex.d.ts +17 -0
  235. package/lib/typescript/module/core/mutex.d.ts.map +1 -0
  236. package/lib/typescript/module/core/retry.d.ts +19 -0
  237. package/lib/typescript/module/core/retry.d.ts.map +1 -0
  238. package/lib/typescript/module/core/timers.d.ts +142 -0
  239. package/lib/typescript/module/core/timers.d.ts.map +1 -0
  240. package/lib/typescript/module/diagnostics/errors.d.ts +55 -0
  241. package/lib/typescript/module/diagnostics/errors.d.ts.map +1 -0
  242. package/lib/typescript/module/diagnostics/events.d.ts +158 -0
  243. package/lib/typescript/module/diagnostics/events.d.ts.map +1 -0
  244. package/lib/typescript/module/diagnostics/messageKeys.d.ts +54 -0
  245. package/lib/typescript/module/diagnostics/messageKeys.d.ts.map +1 -0
  246. package/lib/typescript/module/engine/connection.d.ts +30 -0
  247. package/lib/typescript/module/engine/connection.d.ts.map +1 -0
  248. package/lib/typescript/module/engine/engine.d.ts +93 -0
  249. package/lib/typescript/module/engine/engine.d.ts.map +1 -0
  250. package/lib/typescript/module/engine/finalize.d.ts +53 -0
  251. package/lib/typescript/module/engine/finalize.d.ts.map +1 -0
  252. package/lib/typescript/module/engine/foreground.d.ts +15 -0
  253. package/lib/typescript/module/engine/foreground.d.ts.map +1 -0
  254. package/lib/typescript/module/engine/internals.d.ts +28 -0
  255. package/lib/typescript/module/engine/internals.d.ts.map +1 -0
  256. package/lib/typescript/module/engine/pending.d.ts +51 -0
  257. package/lib/typescript/module/engine/pending.d.ts.map +1 -0
  258. package/lib/typescript/module/engine/products.d.ts +82 -0
  259. package/lib/typescript/module/engine/products.d.ts.map +1 -0
  260. package/lib/typescript/module/engine/purchase.d.ts +61 -0
  261. package/lib/typescript/module/engine/purchase.d.ts.map +1 -0
  262. package/lib/typescript/module/engine/purchaseFailure.d.ts +15 -0
  263. package/lib/typescript/module/engine/purchaseFailure.d.ts.map +1 -0
  264. package/lib/typescript/module/engine/receiptValidation.d.ts +42 -0
  265. package/lib/typescript/module/engine/receiptValidation.d.ts.map +1 -0
  266. package/lib/typescript/module/engine/state.d.ts +46 -0
  267. package/lib/typescript/module/engine/state.d.ts.map +1 -0
  268. package/lib/typescript/module/engine/subscriptions.d.ts +61 -0
  269. package/lib/typescript/module/engine/subscriptions.d.ts.map +1 -0
  270. package/lib/typescript/module/engine/sync.d.ts +36 -0
  271. package/lib/typescript/module/engine/sync.d.ts.map +1 -0
  272. package/lib/typescript/module/entitlements/aggregate.d.ts +97 -0
  273. package/lib/typescript/module/entitlements/aggregate.d.ts.map +1 -0
  274. package/lib/typescript/module/entitlements/mapping.d.ts +27 -0
  275. package/lib/typescript/module/entitlements/mapping.d.ts.map +1 -0
  276. package/lib/typescript/module/entitlements/policy.d.ts +75 -0
  277. package/lib/typescript/module/entitlements/policy.d.ts.map +1 -0
  278. package/lib/typescript/module/index.d.ts +44 -0
  279. package/lib/typescript/module/index.d.ts.map +1 -0
  280. package/lib/typescript/module/package.json +1 -0
  281. package/lib/typescript/module/persistence/mmkv-store.d.ts +45 -0
  282. package/lib/typescript/module/persistence/mmkv-store.d.ts.map +1 -0
  283. package/lib/typescript/module/persistence/snapshot.d.ts +106 -0
  284. package/lib/typescript/module/persistence/snapshot.d.ts.map +1 -0
  285. package/lib/typescript/module/react/PaymentProvider.d.ts +57 -0
  286. package/lib/typescript/module/react/PaymentProvider.d.ts.map +1 -0
  287. package/lib/typescript/module/react/hooks.d.ts +80 -0
  288. package/lib/typescript/module/react/hooks.d.ts.map +1 -0
  289. package/lib/typescript/module/testing/conformance.d.ts +41 -0
  290. package/lib/typescript/module/testing/conformance.d.ts.map +1 -0
  291. package/lib/typescript/module/testing/fakeStore.d.ts +69 -0
  292. package/lib/typescript/module/testing/fakeStore.d.ts.map +1 -0
  293. package/lib/typescript/module/testing/index.d.ts +12 -0
  294. package/lib/typescript/module/testing/index.d.ts.map +1 -0
  295. package/package.json +49 -13
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mapErrorCode = mapErrorCode;
7
+ exports.normalizeOffer = normalizeOffer;
8
+ exports.normalizeProduct = normalizeProduct;
9
+ exports.normalizePurchase = normalizePurchase;
10
+ exports.toMicros = toMicros;
11
+ exports.toProviderPurchaseState = toProviderPurchaseState;
12
+ /**
13
+ * The binding's shapes, and their translation into the port's vocabulary
14
+ * (PAY-12).
15
+ *
16
+ * The binding speaks Google Play: prices as micros in strings, offer tokens,
17
+ * numeric purchase states, store error codes. The port speaks this package's
18
+ * own. Keeping the translation here, with no I/O, no listeners and no module
19
+ * loading, is what makes it checkable against recorded payloads — and leaves
20
+ * the adapter next door about the calls it actually makes.
21
+ *
22
+ * The raw types are declared narrowly on purpose: they document the coupling,
23
+ * and a binding upgrade that changes one of these shapes fails to typecheck
24
+ * here rather than failing silently on a user's device.
25
+ */
26
+
27
+ /** What `purchaseErrorListener` delivers. */
28
+
29
+ /** Play's `PurchaseState`: 0 unspecified, 1 purchased, 2 pending. */
30
+ const PLAY_STATE_PURCHASED = 1;
31
+ const PLAY_STATE_PENDING = 2;
32
+
33
+ // Required lazily (rn-core's lazy peer) so importing the package does not require
34
+ // the native module.
35
+
36
+ function toMicros(value) {
37
+ if (typeof value === 'number') {
38
+ return value;
39
+ }
40
+ if (typeof value === 'string') {
41
+ const parsed = Number.parseInt(value, 10);
42
+ return Number.isFinite(parsed) ? parsed : 0;
43
+ }
44
+ return 0;
45
+ }
46
+ function normalizeProduct(raw, productType) {
47
+ const oneTime = raw.oneTimePurchaseOfferDetails;
48
+ const currencyCode = oneTime?.priceCurrencyCode ?? raw.currencyCode ?? raw.currency ?? '';
49
+ return {
50
+ storeProductId: raw.id ?? raw.productId ?? '',
51
+ productType,
52
+ title: raw.title ?? raw.name ?? '',
53
+ description: raw.description ?? '',
54
+ // Store-formatted, never built here: only the store knows the right currency
55
+ // symbol, separator, and placement for the user's locale (FR-028).
56
+ formattedPrice: oneTime?.formattedPrice ?? raw.displayPrice ?? raw.localizedPrice ?? '',
57
+ currencyCode,
58
+ priceAmountMicros: toMicros(oneTime?.priceAmountMicros ?? raw.price),
59
+ offers: (raw.subscriptionOfferDetails ?? []).map(offer => normalizeOffer(offer, currencyCode))
60
+ };
61
+ }
62
+ function normalizeOffer(offer, fallbackCurrency) {
63
+ const phases = offer.pricingPhases?.pricingPhaseList ?? [];
64
+ // The last phase is the recurring price; earlier ones are trial or
65
+ // introductory. Play orders them that way.
66
+ const recurring = phases[phases.length - 1];
67
+ const intro = phases.length > 1 ? phases[0] : undefined;
68
+ const isFreeTrial = intro !== undefined && toMicros(intro.priceAmountMicros) === 0;
69
+ return {
70
+ offerKey: offer.offerToken ?? offer.offerId ?? offer.basePlanId ?? '',
71
+ billingPeriod: recurring?.billingPeriod ?? '',
72
+ formattedPrice: recurring?.formattedPrice ?? '',
73
+ priceAmountMicros: toMicros(recurring?.priceAmountMicros),
74
+ currencyCode: recurring?.priceCurrencyCode ?? fallbackCurrency,
75
+ trialPeriod: isFreeTrial ? intro?.billingPeriod : undefined,
76
+ introductoryPrice: intro && !isFreeTrial ? {
77
+ formattedPrice: intro.formattedPrice ?? '',
78
+ period: intro.billingPeriod ?? '',
79
+ cycles: intro.billingCycleCount ?? 1
80
+ } : undefined,
81
+ // Play decides eligibility by only returning offers the user qualifies for,
82
+ // so forwarding `true` reports the store's determination rather than
83
+ // computing our own (FR-026).
84
+ isEligible: true
85
+ };
86
+ }
87
+
88
+ /**
89
+ * Reads the purchase state from whichever field the binding filled.
90
+ *
91
+ * Pending is preserved, never flattened to purchased: that distinction is what
92
+ * stops an entitlement being granted for money that has not arrived (FR-037).
93
+ * And an unrecognized or missing state is `unspecified`, never `purchased`.
94
+ *
95
+ * 0.1.0 read only Play's numeric state and treated anything else as purchased.
96
+ * The 16.x binding hands JavaScript the *string* state and does not carry the
97
+ * numeric one across, so on a device every pending purchase arrived as a string,
98
+ * fell through to the default, and was granted. Unit tests could not see it: they
99
+ * drive the fake store, which never passes through here.
100
+ */
101
+ function toProviderPurchaseState(raw) {
102
+ let numeric;
103
+ if (typeof raw.purchaseStateAndroid === 'number') {
104
+ numeric = raw.purchaseStateAndroid;
105
+ } else if (typeof raw.purchaseState === 'number') {
106
+ numeric = raw.purchaseState;
107
+ }
108
+ if (numeric !== undefined) {
109
+ if (numeric === PLAY_STATE_PENDING) {
110
+ return 'pending';
111
+ }
112
+ return numeric === PLAY_STATE_PURCHASED ? 'purchased' : 'unspecified';
113
+ }
114
+ switch (typeof raw.purchaseState === 'string' ? raw.purchaseState.toLowerCase() : '') {
115
+ case 'purchased':
116
+ case 'restored':
117
+ return 'purchased';
118
+ case 'pending':
119
+ case 'deferred':
120
+ return 'pending';
121
+ default:
122
+ return 'unspecified';
123
+ }
124
+ }
125
+ function normalizePurchase(raw) {
126
+ return {
127
+ storeProductId: raw.productId ?? raw.ids?.[0] ?? '',
128
+ transactionId: raw.id ?? raw.transactionId ?? raw.purchaseToken ?? '',
129
+ token: raw.purchaseToken ?? '',
130
+ state: toProviderPurchaseState(raw),
131
+ purchasedAt: raw.transactionDate ?? Date.now(),
132
+ isAcknowledged: raw.isAcknowledgedAndroid ?? raw.isAcknowledged ?? false,
133
+ expiresAt: raw.expirationDateAndroid,
134
+ willAutoRenew: raw.autoRenewingAndroid ?? raw.isAutoRenewing,
135
+ // Opaque material for the app's backend. Carried here and handed to the
136
+ // validation hook only — never logged or put in an event (FR-074).
137
+ verificationPayload: raw.transactionReceipt ?? raw.dataAndroid
138
+ };
139
+ }
140
+
141
+ /** Maps a binding error code onto the port's vocabulary, so no store code escapes. */
142
+ function mapErrorCode(code) {
143
+ switch (code) {
144
+ case 'E_USER_CANCELLED':
145
+ case 'user-cancelled':
146
+ return 'user_cancelled';
147
+ case 'E_ALREADY_OWNED':
148
+ case 'already-owned':
149
+ case 'item-already-owned':
150
+ return 'already_owned';
151
+ case 'E_ITEM_UNAVAILABLE':
152
+ case 'item-unavailable':
153
+ case 'sku-not-found':
154
+ return 'unknown_product';
155
+ case 'E_NOT_PREPARED':
156
+ case 'not-prepared':
157
+ return 'not_ready';
158
+ case 'E_NETWORK_ERROR':
159
+ case 'network-error':
160
+ return 'network_error';
161
+ case 'E_DEFERRED_PAYMENT':
162
+ // Not a failure — a pending purchase. The caller resolves it from the
163
+ // purchase update rather than from this error.
164
+ return 'store_error';
165
+ default:
166
+ return 'store_error';
167
+ }
168
+ }
169
+ //# sourceMappingURL=iapShapes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PLAY_STATE_PURCHASED","PLAY_STATE_PENDING","toMicros","value","parsed","Number","parseInt","isFinite","normalizeProduct","raw","productType","oneTime","oneTimePurchaseOfferDetails","currencyCode","priceCurrencyCode","currency","storeProductId","id","productId","title","name","description","formattedPrice","displayPrice","localizedPrice","priceAmountMicros","price","offers","subscriptionOfferDetails","map","offer","normalizeOffer","fallbackCurrency","phases","pricingPhases","pricingPhaseList","recurring","length","intro","undefined","isFreeTrial","offerKey","offerToken","offerId","basePlanId","billingPeriod","trialPeriod","introductoryPrice","period","cycles","billingCycleCount","isEligible","toProviderPurchaseState","numeric","purchaseStateAndroid","purchaseState","toLowerCase","normalizePurchase","ids","transactionId","purchaseToken","token","state","purchasedAt","transactionDate","Date","now","isAcknowledged","isAcknowledgedAndroid","expiresAt","expirationDateAndroid","willAutoRenew","autoRenewingAndroid","isAutoRenewing","verificationPayload","transactionReceipt","dataAndroid","mapErrorCode","code"],"sourceRoot":"../../../src","sources":["adapter/iapShapes.ts"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0DA;;AAOA;AACA,MAAMA,oBAAoB,GAAG,CAAC;AAC9B,MAAMC,kBAAkB,GAAG,CAAC;;AAE5B;AACA;;AAEO,SAASC,QAAQA,CAACC,KAAkC,EAAU;EACpE,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC9B,OAAOA,KAAK;EACb;EACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC9B,MAAMC,MAAM,GAAGC,MAAM,CAACC,QAAQ,CAACH,KAAK,EAAE,EAAE,CAAC;IACzC,OAAOE,MAAM,CAACE,QAAQ,CAACH,MAAM,CAAC,GAAGA,MAAM,GAAG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Ae;IACvB,KAAK,oBAAoB;IACzB,KAAK,kBAAkB;IACvB,KAAK,eAAe;MACnB,OAAO,iBAAiB;IACzB,KAAK,gBAAgB;IACrB,KAAK,cAAc;MAClB,OAAO,WAAW;IACnB,KAAK,iBAAiB;IACtB,KAAK,eAAe;MACnB,OAAO,eAAe;IACvB,KAAK,oBAAoB;MACxB;MACA;MACA,OAAO,aAAa;IACrB;MACC,OAAO,aAAa;EACtB;AACD","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=port.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["adapter/port.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["config/types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.assertEnvironmentSafe = assertEnvironmentSafe;
7
+ exports.mayCreateRealTransaction = mayCreateRealTransaction;
8
+ exports.validateConfig = validateConfig;
9
+ var _errors = require("../diagnostics/errors.js");
10
+ var _timers = require("../core/timers.js");
11
+ /**
12
+ * Catalog validation (FR-011).
13
+ *
14
+ * Runs at `configure`, before any connection is opened, so a bad catalog fails
15
+ * at configuration time rather than at the moment a user taps Buy. Every failure
16
+ * **names the offending entry** — "invalid catalog" alone is useless in an app
17
+ * with thirty products.
18
+ *
19
+ * All problems are collected rather than thrown one at a time, so a developer
20
+ * fixes the catalog in one pass instead of rerunning to find the next fault.
21
+ */
22
+
23
+ const PRODUCT_TYPES = ['one_time_permanent', 'one_time_consumable', 'subscription'];
24
+
25
+ /** The platform whose store identifiers a catalog must supply. */
26
+
27
+ /**
28
+ * A validated, indexed catalog plus every resolved policy value.
29
+ *
30
+ * Produced once so the hot paths never re-derive it, and so `getEntitlement` can
31
+ * stay a synchronous in-memory read (PERF-001).
32
+ */
33
+
34
+ function validateConfig(config, platform = 'android') {
35
+ const problems = [];
36
+ const offenders = [];
37
+ const entries = new Map();
38
+ const grants = new Map();
39
+ const sources = new Map();
40
+ const byStoreId = new Map();
41
+ if (config.catalog.length === 0) {
42
+ problems.push('catalog is empty');
43
+ offenders.push('catalog');
44
+ }
45
+ for (const entry of config.catalog) {
46
+ const key = entry.productKey;
47
+ if (!key || key.trim() === '') {
48
+ problems.push('a catalog entry has an empty productKey');
49
+ offenders.push('(empty productKey)');
50
+ continue;
51
+ }
52
+ if (entries.has(key)) {
53
+ problems.push(`duplicate productKey "${key}"`);
54
+ offenders.push(key);
55
+ continue;
56
+ }
57
+ if (!PRODUCT_TYPES.includes(entry.productType)) {
58
+ problems.push(`productKey "${key}" has invalid productType "${String(entry.productType)}"`);
59
+ offenders.push(key);
60
+ }
61
+ const storeId = entry.storeProductIds[platform];
62
+ if (!storeId || storeId.trim() === '') {
63
+ problems.push(`productKey "${key}" is missing a store product id for platform "${platform}"`);
64
+ offenders.push(key);
65
+ } else {
66
+ const existing = byStoreId.get(storeId);
67
+ if (existing !== undefined) {
68
+ // Two product keys pointing at one store id would make a store callback
69
+ // ambiguous, so the wrong entitlement could be granted.
70
+ problems.push(`store product id "${storeId}" is used by both "${existing}" and "${key}"`);
71
+ offenders.push(key);
72
+ } else {
73
+ byStoreId.set(storeId, key);
74
+ }
75
+ }
76
+ if (!Array.isArray(entry.grants) || entry.grants.length === 0) {
77
+ problems.push(`productKey "${key}" grants no entitlement`);
78
+ offenders.push(key);
79
+ }
80
+ entries.set(key, entry);
81
+ grants.set(key, [...(entry.grants ?? [])]);
82
+ for (const entitlement of entry.grants ?? []) {
83
+ const list = sources.get(entitlement);
84
+ if (list) {
85
+ list.push(key);
86
+ } else {
87
+ sources.set(entitlement, [key]);
88
+ }
89
+ }
90
+ }
91
+
92
+ // An entitlement the app intends to query but no product can grant is almost
93
+ // always a typo, and it would otherwise sit at `not_entitled` forever with no
94
+ // indication why.
95
+ for (const entitlement of config.entitlements) {
96
+ if (!sources.has(entitlement)) {
97
+ problems.push(`entitlement "${entitlement}" is declared but no catalog product grants it`);
98
+ offenders.push(entitlement);
99
+ }
100
+ }
101
+
102
+ // A product granting something the app never declared is the mirror problem:
103
+ // harmless at runtime, but a strong signal of a rename half-applied.
104
+ const declared = new Set(config.entitlements);
105
+ for (const entitlement of sources.keys()) {
106
+ if (!declared.has(entitlement)) {
107
+ problems.push(`entitlement "${entitlement}" is granted by a product but not declared in config.entitlements`);
108
+ offenders.push(entitlement);
109
+ }
110
+ }
111
+ if (problems.length > 0) {
112
+ throw new _errors.PaymentConfigError({
113
+ code: 'PAYMENT_INVALID_CATALOG',
114
+ message: `Payment catalog is invalid: ${problems.join('; ')}`,
115
+ operation: 'configure',
116
+ offenders: [...new Set(offenders)]
117
+ });
118
+ }
119
+ return {
120
+ entries,
121
+ grants,
122
+ sources: new Map([...sources].map(([k, v]) => [k, [...v]])),
123
+ byStoreId,
124
+ entitlementKeys: [...config.entitlements],
125
+ platform,
126
+ enabled: config.enabled ?? true,
127
+ gracePolicy: config.gracePolicy ?? 'grant',
128
+ holdPolicy: config.holdPolicy ?? 'withhold',
129
+ staleAfterMs: (0, _timers.resolveStaleAfterMs)(config.staleAfterMs),
130
+ productCacheTtlMs: (0, _timers.resolveProductCacheTtlMs)(config.productCacheTtlMs),
131
+ foregroundSyncMinIntervalMs: (0, _timers.resolveForegroundSyncMinIntervalMs)(config.foregroundSyncMinIntervalMs),
132
+ timeouts: (0, _timers.resolveTimeouts)(config.timeouts),
133
+ retry: (0, _timers.resolveRetry)(config.retry),
134
+ onValidationUnavailable: config.onValidationUnavailable ?? 'grant_and_queue'
135
+ };
136
+ }
137
+
138
+ /**
139
+ * The fail-closed environment guard (FR-015).
140
+ *
141
+ * Separate from catalog validation because it is not about the catalog's shape
142
+ * but about whether this binary is allowed to move real money at all. Checked
143
+ * before connecting, and it refuses rather than warns: a non-production build
144
+ * that declares `production` is one tap away from charging a real card, and
145
+ * continuing silently is exactly the failure this package exists to prevent.
146
+ */
147
+ function assertEnvironmentSafe(config) {
148
+ if (config.allowStoreTestPurchases === true && config.environment !== 'test') {
149
+ throw new _errors.PaymentConfigError({
150
+ code: 'PAYMENT_INVALID_CONFIG',
151
+ message: `allowStoreTestPurchases is only accepted with environment "test", not ` + `"${config.environment}": it exists for license testers, not for real users.`,
152
+ operation: 'configure',
153
+ offenders: ['allowStoreTestPurchases']
154
+ });
155
+ }
156
+ if (config.environment === 'production' && !config.isProductionBuild) {
157
+ throw new _errors.PaymentConfigError({
158
+ code: 'PAYMENT_PRODUCTION_CONFIG_IN_NON_PRODUCTION_BUILD',
159
+ message: 'environment is "production" but isProductionBuild is false. Refusing to ' + 'initialize: a non-production build must not be able to create a real ' + 'transaction.',
160
+ operation: 'configure',
161
+ offenders: ['environment']
162
+ });
163
+ }
164
+ }
165
+
166
+ /**
167
+ * Whether this configuration may hand a purchase to a real store (FR-014).
168
+ *
169
+ * True in a production build configured for production, and in a `test`
170
+ * environment that opted in with `allowStoreTestPurchases` (PAY-16). False
171
+ * everywhere else. The engine records each refusal in observable status so a
172
+ * test can assert the block happened — the difference between a guarantee and a
173
+ * hope.
174
+ */
175
+ function mayCreateRealTransaction(config) {
176
+ if (config.environment === 'test' && config.allowStoreTestPurchases === true) {
177
+ return true;
178
+ }
179
+ return config.environment === 'production' && config.isProductionBuild;
180
+ }
181
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_errors","require","_timers","PRODUCT_TYPES","validateConfig","config","platform","problems","offenders","entries","Map","grants","sources","byStoreId","catalog","length","push","entry","key","productKey","trim","has","includes","productType","String","storeId","storeProductIds","existing","get","undefined","set","Array","isArray","entitlement","list","entitlements","declared","Set","keys","PaymentConfigError","code","message","join","operation","map","k","v","entitlementKeys","enabled","gracePolicy","holdPolicy","staleAfterMs","resolveStaleAfterMs","productCacheTtlMs","resolveProductCacheTtlMs","foregroundSyncMinIntervalMs","resolveForegroundSyncMinIntervalMs","timeouts","resolveTimeouts","retry","resolveRetry","onValidationUnavailable","assertEnvironmentSafe","allowStoreTestPurchases","environment","isProductionBuild","mayCreateRealTransaction"],"sourceRoot":"../../../src","sources":["config/validate.ts"],"mappings":";;;;;;;;AAYA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsBA,MAAME,aAAqC,GAAG,CAC7C,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,CACd;;AAED;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAsBO,SAASC,cAAcA,CAC7BC,MAAqB,EACrBC,QAAwB,GAAG,SAAS,EACnB;EACjB,MAAMC,QAAkB,GAAG,EAAE;EAC7B,MAAMC,SAAmB,GAAG,EAAE;EAE9B,MAAMC,OAAO,GAAG,IAAIC,GAAG,CAA2B,CAAC;EACnD,MAAMC,MAAM,GAAG,IAAID,GAAG,CAAwC,CAAC;EAC/D,MAAME,OAAO,GAAG,IAAIF,GAAG,CAA+B,CAAC;EACvD,MAAMG,SAAS,GAAG,IAAIH,GAAG,CAAqB,CAAC;EAE/C,IAAIL,MAAM,CAACS,OAAO,CAACC,MAAM,KAAK,CAAC,EAAE;IAChCR,QAAQ,CAACS,IAAI,CAAC,kBAAkB,CAAC;IACjCR,SAAS,CAACQ,IAAI,CAAC,SAAS,CAAC;EAC1B;EAEA,KAAK,MAAMC,KAAK,IAAIZ,MAAM,CAACS,OAAO,EAAE;IACnC,MAAMI,GAAG,GAAGD,KAAK,CAACE,UAAU;IAE5B,IAAI,CAACD,GAAG,IAAIA,GAAG,CAACE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;MAC9Bb,QAAQ,CAACS,IAAI,CAAC,yCAAyC,CAAC;MACxDR,SAA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MAAM,CAAC0D,uBAAuB,KAAK,IAAI,IAAI1D,MAAM,CAAC2D,WAAW,KAAK,MAAM,EAAE;IAC7E,MAAM,IAAIzB,0BAAkB,CAAC;MAC5BC,IAAI,EAAE,wBAAwB;MAC9BC,OAAO,EACN,wEAAwE,GACxE,IAAIpC,MAAM,CAAC2D,WAAW,uDAAuD;MAC9ErB,SAAS,EAAE,WAAW;MACtBnC,SAAS,EAAE,CAAC,yBAAyB;IACtC,CAAC,CAAC;EACH;EACA,IAAIH,MAAM,CAAC2D,WAAW,KAAK,YAAY,IAAI,CAAC3D,MAAM,CAAC4D,iBAAiB,EAAE;IACrE,MAAM,IAAI1B,0BAAkB,CAAC;MAC5BC,IAAI,EAAE,mDAAmD;MACzDC,OAAO,EACN,0EAA0E,GAC1E,uEAAuE,GACvE,cAAc;MACfE,SAAS,EAAE,WAAW;MACtBnC,SAAS,EAAE,CAAC,aAAa;IAC1B,CAAC,CAAC;EACH;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS0D,wBAAwBA,CAAC7D,MAAqB,EAAW;EACxE,IAAIA,MAAM,CAAC2D,WAAW,KAAK,MAAM,IAAI3D,MAAM,CAAC0D,uBAAuB,KAAK,IAAI,EAAE;IAC7E,OAAO,IAAI;EACZ;EACA,OAAO1D,MAAM,CAAC2D,WAAW,KAAK,YAAY,IAAI3D,MAAM,CAAC4D,iBAAiB;AACvE","ignoreList":[]}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "createExclusive", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _rnCore.createExclusive;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "createRateLimiter", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _rnCore.createRateLimiter;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "createSingleFlight", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _rnCore.createSingleFlight;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "withTimeout", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _rnCore.withTimeout;
28
+ }
29
+ });
30
+ var _rnCore = require("@chipmobilesdk/rn-core");
31
+ //# sourceMappingURL=mutex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_rnCore","require"],"sourceRoot":"../../../src","sources":["core/mutex.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,IAAAA,OAAA,GAAAC,OAAA","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.backoffDelayMs = backoffDelayMs;
7
+ var _rnCore = require("@chipmobilesdk/rn-core");
8
+ /**
9
+ * Bounded backoff.
10
+ *
11
+ * "Bounded" is the whole point (FR-020, FR-045): an unbounded reconnect loop
12
+ * against a billing service that is down drains battery and hammers a system
13
+ * service, and an unbounded finalize loop hides a real failure behind noise.
14
+ *
15
+ * Delay computation is pure and separated from waiting so tests can assert the
16
+ * schedule without burning real time.
17
+ */
18
+
19
+ /**
20
+ * Delay before `attempt` (1-based), capped and optionally jittered.
21
+ *
22
+ * Jitter is full jitter over [0, capped]: several devices that lost the billing
23
+ * connection at the same moment should not retry in lockstep.
24
+ */
25
+ function backoffDelayMs(attempt, config, random = Math.random) {
26
+ return (0, _rnCore.computeBackoff)(attempt, toSpec(config), random);
27
+ }
28
+ function toSpec(config) {
29
+ return {
30
+ initialDelayMs: config.initialDelayMs,
31
+ maxDelayMs: config.maxDelayMs,
32
+ factor: config.factor,
33
+ jitter: config.jitter ? 'full' : 'none',
34
+ maxAttempts: config.maxAttempts
35
+ };
36
+ }
37
+ //# sourceMappingURL=retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_rnCore","require","backoffDelayMs","attempt","config","random","Math","computeBackoff","toSpec","initialDelayMs","maxDelayMs","factor","jitter","maxAttempts"],"sourceRoot":"../../../src","sources":["core/retry.ts"],"mappings":";;;;;;AAWA,IAAAA,OAAA,GAAAC,OAAA;AAXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAC7BC,OAAe,EACfC,MAA+B,EAC/BC,MAAoB,GAAGC,IAAI,CAACD,MAAM,EACzB;EACT,OAAO,IAAAE,sBAAc,EAACJ,OAAO,EAAEK,MAAM,CAACJ,MAAM,CAAC,EAAEC,MAAM,CAAC;AACvD;AAEA,SAASG,MAAMA,CAACJ,MAA+B,EAAE;EAChD,OAAO;IACNK,cAAc,EAAEL,MAAM,CAACK,cAAc;IACrCC,UAAU,EAAEN,MAAM,CAACM,UAAU;IAC7BC,MAAM,EAAEP,MAAM,CAACO,MAAM;IACrBC,MAAM,EAAER,MAAM,CAACQ,MAAM,GAAI,MAAM,GAAc,MAAgB;IAC7DC,WAAW,EAAET,MAAM,CAACS;EACrB,CAAC;AACF","ignoreList":[]}