@chipmobilesdk/rn-payment 0.5.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 (317) hide show
  1. package/CHANGELOG.md +172 -0
  2. package/README.md +47 -16
  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
  296. package/skills/sdk-rn-payment/SKILL.md +4 -4
  297. package/src/adapter/iap-adapter.ts +12 -216
  298. package/src/adapter/iapShapes.ts +232 -0
  299. package/src/config/types.ts +8 -0
  300. package/src/config/validate.ts +19 -4
  301. package/src/core/retry.ts +1 -58
  302. package/src/diagnostics/events.ts +1 -1
  303. package/src/engine/connection.ts +194 -0
  304. package/src/engine/engine.ts +140 -700
  305. package/src/engine/internals.ts +40 -0
  306. package/src/engine/products.ts +39 -17
  307. package/src/engine/purchase.ts +22 -130
  308. package/src/engine/purchaseFailure.ts +48 -0
  309. package/src/engine/receiptValidation.ts +101 -0
  310. package/src/engine/state.ts +253 -0
  311. package/src/engine/sync.ts +161 -0
  312. package/src/entitlements/aggregate.ts +3 -5
  313. package/src/entitlements/mapping.ts +0 -22
  314. package/src/persistence/mmkv-store.ts +10 -3
  315. package/src/persistence/snapshot.ts +102 -27
  316. package/src/react/PaymentProvider.tsx +73 -24
  317. package/src/react/hooks.ts +13 -3
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useEntitlement = useEntitlement;
7
+ exports.useEntitlements = useEntitlements;
8
+ exports.usePaymentStatus = usePaymentStatus;
9
+ exports.usePendingPurchases = usePendingPurchases;
10
+ exports.useProducts = useProducts;
11
+ exports.usePurchase = usePurchase;
12
+ exports.useSync = useSync;
13
+ var _react = require("@chipmobilesdk/rn-core/react");
14
+ var _react2 = require("react");
15
+ var _PaymentProvider = require("./PaymentProvider.js");
16
+ /**
17
+ * Hooks over the engine.
18
+ *
19
+ * Each subscribes on mount and unsubscribes on unmount, so repeated mount/unmount
20
+ * leaves no duplicate subscription and no surviving listener (FR-006, PERF-002).
21
+ *
22
+ * Reads are synchronous: the engine holds entitlements in memory, so a hook never
23
+ * returns a loading placeholder for an entitlement it already knows (PERF-001).
24
+ */
25
+
26
+ /**
27
+ * One entitlement, re-rendering only when that one changes.
28
+ *
29
+ * The returned `status` is `unknown` until the first sync completes. That is the
30
+ * point: an app must be able to tell "not yet known" from "not entitled" so a
31
+ * paying user never sees the unpaid experience flash (FR-047).
32
+ */
33
+ function useEntitlement(key) {
34
+ const engine = (0, _PaymentProvider.usePaymentEngine)();
35
+ // The engine keeps an unchanged entitlement's object across recomputes, so this
36
+ // selection only changes, and the component only re-renders, when it changes.
37
+ const select = (0, _react2.useCallback)(map => map[key] ?? engine.getEntitlement(key), [engine, key]);
38
+ return (0, _react.useExternalStore)(engine.subscribeEntitlements, engine.getAllEntitlements, select);
39
+ }
40
+
41
+ /** Every entitlement at once, for a screen that shows overall plan state. */
42
+ function useEntitlements() {
43
+ const engine = (0, _PaymentProvider.usePaymentEngine)();
44
+ return (0, _react.useExternalStore)(engine.subscribeEntitlements, engine.getAllEntitlements);
45
+ }
46
+ function narrowPending(state, keys) {
47
+ return keys ? {
48
+ ...state,
49
+ purchases: state.purchases.filter(p => keys.includes(p.productKey))
50
+ } : state;
51
+ }
52
+
53
+ /**
54
+ * Pending purchases, in this session or an earlier one (FR-101). Added in 0.2.0.
55
+ *
56
+ * Pass product keys to narrow it to the products one screen sells. Read
57
+ * `status` before the list: under `unknown`, an empty list is not "nothing
58
+ * pending", and a Buy button shown on it could charge a user twice.
59
+ */
60
+ function usePendingPurchases(productKeys) {
61
+ const engine = (0, _PaymentProvider.usePaymentEngine)();
62
+ // Joined so a caller passing a literal array does not resubscribe each render.
63
+ const keyToken = productKeys ? productKeys.join('|') : null;
64
+ const [state, setState] = (0, _react2.useState)(() => narrowPending(engine.getPendingPurchases(), productKeys ?? null));
65
+ (0, _react2.useEffect)(() => {
66
+ const keys = keyToken === null ? null : keyToken.split('|').filter(Boolean);
67
+ setState(narrowPending(engine.getPendingPurchases(), keys));
68
+ return engine.subscribePendingPurchases(next => setState(narrowPending(next, keys)));
69
+ }, [engine, keyToken]);
70
+ return state;
71
+ }
72
+
73
+ /** Package status, so an app can tell "cannot sell here" from "not paid" (FR-022). */
74
+ function usePaymentStatus() {
75
+ const engine = (0, _PaymentProvider.usePaymentEngine)();
76
+ return (0, _react.useExternalStore)(engine.subscribeStatus, engine.getStatus);
77
+ }
78
+ /**
79
+ * Starting a purchase.
80
+ *
81
+ * `lastResult` is the full typed union rather than a boolean, because a screen has
82
+ * to treat `user_cancelled` differently from `store_error` — showing an error
83
+ * banner to someone who simply changed their mind is the most common paywall bug.
84
+ */
85
+ function usePurchase() {
86
+ const engine = (0, _PaymentProvider.usePaymentEngine)();
87
+ const [isPurchasing, setIsPurchasing] = (0, _react2.useState)(false);
88
+ const [lastResult, setLastResult] = (0, _react2.useState)();
89
+ const purchase = (0, _react2.useCallback)(async (productKey, options) => {
90
+ setIsPurchasing(true);
91
+ try {
92
+ const result = await engine.purchase(productKey, options);
93
+ setLastResult(result);
94
+ return result;
95
+ } finally {
96
+ setIsPurchasing(false);
97
+ }
98
+ }, [engine]);
99
+ const consume = (0, _react2.useCallback)(ref => engine.consume(ref), [engine]);
100
+ return {
101
+ purchase,
102
+ consume,
103
+ isPurchasing,
104
+ lastResult
105
+ };
106
+ }
107
+ /**
108
+ * Store-supplied product information for a paywall.
109
+ *
110
+ * Every price here is already formatted by the store for the user's locale. An app
111
+ * must render `formattedPrice` and never build its own string from
112
+ * `priceAmountMicros` — that field exists for sorting and comparison only
113
+ * (FR-028).
114
+ */
115
+ function useProducts(productKeys) {
116
+ const engine = (0, _PaymentProvider.usePaymentEngine)();
117
+ const [products, setProducts] = (0, _react2.useState)([]);
118
+ const [missing, setMissing] = (0, _react2.useState)([]);
119
+ const [isLoading, setIsLoading] = (0, _react2.useState)(false);
120
+ const [error, setError] = (0, _react2.useState)();
121
+
122
+ // Joined so the effect depends on the contents rather than the array identity:
123
+ // a caller passing a literal would otherwise re-query on every render.
124
+ const keyToken = productKeys.join('|');
125
+ // Each load's number. Only the latest may write: when the keys change while a
126
+ // query is out, the older answer must not overwrite the newer one (PAY-20).
127
+ const latestRequest = (0, _react2.useRef)(0);
128
+ const load = (0, _react2.useCallback)(async fresh => {
129
+ const request = ++latestRequest.current;
130
+ const keys = keyToken === '' ? [] : keyToken.split('|');
131
+ if (keys.length === 0) {
132
+ setProducts([]);
133
+ setMissing([]);
134
+ return;
135
+ }
136
+ setIsLoading(true);
137
+ try {
138
+ const result = fresh ? await engine.refreshProducts(keys) : await engine.getProducts(keys);
139
+ if (request !== latestRequest.current) {
140
+ return;
141
+ }
142
+ if (result.ok) {
143
+ setProducts(result.products);
144
+ setMissing(result.missing);
145
+ setError(undefined);
146
+ } else {
147
+ setError(result.error);
148
+ }
149
+ } finally {
150
+ if (request === latestRequest.current) {
151
+ setIsLoading(false);
152
+ }
153
+ }
154
+ }, [engine, keyToken]);
155
+ (0, _react2.useEffect)(() => {
156
+ load(false).catch(() => undefined);
157
+ }, [load]);
158
+ const refresh = (0, _react2.useCallback)(() => load(true), [load]);
159
+ return {
160
+ products,
161
+ missing,
162
+ isLoading,
163
+ error,
164
+ refresh
165
+ };
166
+ }
167
+ /**
168
+ * Sync and restore, for a "Restore purchases" control.
169
+ *
170
+ * `restore`'s outcome distinguishes "restored" from "nothing found", so the app
171
+ * can avoid telling a user their purchases came back when none existed (FR-061).
172
+ */
173
+ function useSync() {
174
+ const engine = (0, _PaymentProvider.usePaymentEngine)();
175
+ const [isSyncing, setIsSyncing] = (0, _react2.useState)(false);
176
+ const [lastSyncedAt, setLastSyncedAt] = (0, _react2.useState)(() => engine.getLastSyncedAt());
177
+ const sync = (0, _react2.useCallback)(async () => {
178
+ setIsSyncing(true);
179
+ try {
180
+ return await engine.sync('manual');
181
+ } finally {
182
+ setIsSyncing(false);
183
+ setLastSyncedAt(engine.getLastSyncedAt());
184
+ }
185
+ }, [engine]);
186
+ const restore = (0, _react2.useCallback)(async () => {
187
+ setIsSyncing(true);
188
+ try {
189
+ return await engine.restore();
190
+ } finally {
191
+ setIsSyncing(false);
192
+ setLastSyncedAt(engine.getLastSyncedAt());
193
+ }
194
+ }, [engine]);
195
+ return {
196
+ sync,
197
+ restore,
198
+ isSyncing,
199
+ lastSyncedAt
200
+ };
201
+ }
202
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_react2","_PaymentProvider","useEntitlement","key","engine","usePaymentEngine","select","useCallback","map","getEntitlement","useExternalStore","subscribeEntitlements","getAllEntitlements","useEntitlements","narrowPending","state","keys","purchases","filter","p","includes","productKey","usePendingPurchases","productKeys","keyToken","join","setState","useState","getPendingPurchases","useEffect","split","Boolean","subscribePendingPurchases","next","usePaymentStatus","subscribeStatus","getStatus","usePurchase","isPurchasing","setIsPurchasing","lastResult","setLastResult","purchase","options","result","consume","ref","useProducts","products","setProducts","missing","setMissing","isLoading","setIsLoading","error","setError","latestRequest","useRef","load","fresh","request","current","length","refreshProducts","getProducts","ok","undefined","catch","refresh","useSync","isSyncing","setIsSyncing","lastSyncedAt","setLastSyncedAt","getLastSyncedAt","sync","restore"],"sourceRoot":"../../../src","sources":["react/hooks.ts"],"mappings":";;;;;;;;;;;;AAUA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AAZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,cAAcA,CAACC,GAAmB,EAAoB;EACrE,MAAMC,MAAM,GAAG,IAAAC,iCAAgB,EAAC,CAAC;EACjC;EACA;EACA,MAAMC,MAAM,GAAG,IAAAC,mBAAW,EACxBC,GAAmB,IAAKA,GAAG,CAACL,GAAG,CAAC,IAAIC,MAAM,CAACK,cAAc,CAACN,GAAG,CAAC,EAC/D,CAACC,MAAM,EAAED,GAAG,CACb,CAAC;EACD,OAAO,IAAAO,uBAAgB,EAACN,MAAM,CAACO,qBAAqB,EAAEP,MAAM,CAACQ,kBAAkB,EAAEN,MAAM,CAAC;AACzF;;AAEA;AACO,SAASO,eAAeA,CAAA,EAAmB;EACjD,MAAMT,MAAM,GAAG,IAAAC,iCAAgB,EAAC,CAAC;EACjC,OAAO,IAAAK,uBAAgB,EAACN,MAAM,CAACO,qBAAqB,EAAEP,MAAM,CAACQ,kBAAkB,CAAC;AACjF;AAEA,SAASE,aAAaA,CACrBC,KAA4B,EAC5BC,IAA8B,EACN;EACxB,OAAOA,IAAI,GACR;IAAE,GAAGD,KA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,EAAE,CAACtE,MAAM,CAAC,CAAC;EAEZ,OAAO;IAAEuE,IAAI;IAAEC,OAAO;IAAEN,SAAS;IAAEE;EAAa,CAAC;AAClD","ignoreList":[]}
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.providerPortChecks = exports.CONFORMANCE_STORE = void 0;
7
+ exports.runProviderPortConformance = runProviderPortConformance;
8
+ var _testing = require("@chipmobilesdk/rn-core/testing");
9
+ /**
10
+ * What any `ProviderPort` must do (IOS-12, PAY-13).
11
+ *
12
+ * The same checks run against the fake store and against the Play adapter over a
13
+ * simulated binding (or the real one, from a demo screen on a device), so a test
14
+ * that drives the fake proves something about the device path. Each check builds
15
+ * its own port over the same small store, through a harness.
16
+ */
17
+
18
+ /** The store every check runs against. */
19
+ const CONFORMANCE_STORE = exports.CONFORMANCE_STORE = {
20
+ products: [{
21
+ storeProductId: 'conformance.remove_ads',
22
+ productType: 'one_time_permanent',
23
+ formattedPrice: '€1.99'
24
+ }, {
25
+ storeProductId: 'conformance.coins',
26
+ productType: 'one_time_consumable',
27
+ formattedPrice: '€0.99'
28
+ }],
29
+ owned: [{
30
+ storeProductId: 'conformance.remove_ads',
31
+ token: 'token-owned',
32
+ state: 'purchased'
33
+ }, {
34
+ storeProductId: 'conformance.coins',
35
+ token: 'token-pending',
36
+ state: 'pending'
37
+ }]
38
+ };
39
+ const providerPortChecks = exports.providerPortChecks = [{
40
+ name: 'connects, and disconnects safely before a connect and twice',
41
+ async run(harness) {
42
+ const {
43
+ port
44
+ } = harness.create(CONFORMANCE_STORE);
45
+ await port.disconnect();
46
+ const outcome = await port.connect();
47
+ (0, _testing.ensure)(outcome.ok, `connect failed: ${JSON.stringify(outcome)}`);
48
+ await port.disconnect();
49
+ await port.disconnect();
50
+ }
51
+ }, {
52
+ name: 'reports a dropped service to observers, and nothing after unsubscribing',
53
+ async run(harness) {
54
+ const subject = harness.create(CONFORMANCE_STORE);
55
+ const seen = [];
56
+ const stop = subject.port.observeConnection(connected => seen.push(connected));
57
+ await subject.port.connect();
58
+ (0, _testing.ensure)(seen.at(-1) === true, `after connect observers saw ${JSON.stringify(seen)}`);
59
+ subject.dropService();
60
+ (0, _testing.ensure)(seen.at(-1) === false, `after the drop observers saw ${JSON.stringify(seen)}`);
61
+ stop();
62
+ const before = seen.length;
63
+ await subject.port.connect();
64
+ (0, _testing.ensure)(seen.length === before, 'notified after unsubscribing');
65
+ }
66
+ }, {
67
+ name: 'returns the requested products with the store-formatted price',
68
+ async run(harness) {
69
+ const {
70
+ port
71
+ } = harness.create(CONFORMANCE_STORE);
72
+ await port.connect();
73
+ const products = await port.queryProducts(['conformance.remove_ads'], 'one_time_permanent');
74
+ (0, _testing.ensure)(products.length === 1, `expected one product, got ${products.length}`);
75
+ const [product] = products;
76
+ (0, _testing.ensure)(product?.storeProductId === 'conformance.remove_ads', 'wrong product returned');
77
+ (0, _testing.ensure)(product.productType === 'one_time_permanent', `product type ${product.productType}`);
78
+ (0, _testing.ensure)(product.formattedPrice === '€1.99', `price ${product.formattedPrice}`);
79
+ }
80
+ }, {
81
+ name: 'flags a pending purchase rather than filtering it out',
82
+ async run(harness) {
83
+ const {
84
+ port
85
+ } = harness.create(CONFORMANCE_STORE);
86
+ await port.connect();
87
+ const owned = await port.queryOwned();
88
+ const pending = owned.find(purchase => purchase.token === 'token-pending');
89
+ const bought = owned.find(purchase => purchase.token === 'token-owned');
90
+ (0, _testing.ensure)(pending?.state === 'pending', `pending purchase reported as ${pending?.state}`);
91
+ (0, _testing.ensure)(bought?.state === 'purchased', `bought purchase reported as ${bought?.state}`);
92
+ }
93
+ }, {
94
+ name: 'reports a bought purchase for the product that was requested',
95
+ async run(harness) {
96
+ const subject = harness.create(CONFORMANCE_STORE);
97
+ await subject.port.connect();
98
+ subject.nextPurchaseEnds('bought');
99
+ const outcome = await subject.port.launchPurchase({
100
+ storeProductId: 'conformance.coins',
101
+ productType: 'one_time_consumable'
102
+ });
103
+ (0, _testing.ensure)(outcome.ok, `purchase failed: ${JSON.stringify(outcome)}`);
104
+ (0, _testing.ensure)(outcome.purchase.storeProductId === 'conformance.coins', 'purchase for another product');
105
+ (0, _testing.ensure)(outcome.purchase.token !== '', 'purchase has no token to finalize');
106
+ }
107
+ }, {
108
+ name: 'reports a cancelled flow as user_cancelled',
109
+ async run(harness) {
110
+ const subject = harness.create(CONFORMANCE_STORE);
111
+ await subject.port.connect();
112
+ subject.nextPurchaseEnds('cancelled');
113
+ const outcome = await subject.port.launchPurchase({
114
+ storeProductId: 'conformance.remove_ads',
115
+ productType: 'one_time_permanent'
116
+ });
117
+ (0, _testing.ensure)(!outcome.ok, 'a cancelled flow reported a purchase');
118
+ (0, _testing.ensure)(outcome.reason === 'user_cancelled', `reason ${outcome.reason}`);
119
+ }
120
+ }, {
121
+ name: 'acknowledges and consumes safely twice',
122
+ async run(harness) {
123
+ const {
124
+ port
125
+ } = harness.create(CONFORMANCE_STORE);
126
+ await port.connect();
127
+ await port.acknowledge('token-owned');
128
+ await port.acknowledge('token-owned');
129
+ await port.consume('token-pending');
130
+ await port.consume('token-pending');
131
+ }
132
+ }];
133
+ function runProviderPortConformance(harness) {
134
+ return (0, _testing.runChecks)(() => harness, providerPortChecks);
135
+ }
136
+ //# sourceMappingURL=conformance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_testing","require","CONFORMANCE_STORE","exports","products","storeProductId","productType","formattedPrice","owned","token","state","providerPortChecks","name","run","harness","port","create","disconnect","outcome","connect","ensure","ok","JSON","stringify","subject","seen","stop","observeConnection","connected","push","at","dropService","before","length","queryProducts","product","queryOwned","pending","find","purchase","bought","nextPurchaseEnds","launchPurchase","reason","acknowledge","consume","runProviderPortConformance","runChecks"],"sourceRoot":"../../../src","sources":["testing/conformance.ts"],"mappings":";;;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AARA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyCA;AACO,MAAM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C8B,OAAO,CAAC,eAAe,CAAC;IACnC,MAAM9B,IAAI,CAAC8B,OAAO,CAAC,eAAe,CAAC;EACpC;AACD,CAAC,CACD;AAEM,SAASC,0BAA0BA,CAAChC,OAAwB,EAA8B;EAChG,OAAO,IAAAiC,kBAAS,EAAC,MAAMjC,OAAO,EAAEH,kBAAkB,CAAC;AACpD","ignoreList":[]}
@@ -0,0 +1,281 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFakeStore = createFakeStore;
7
+ exports.makePurchase = makePurchase;
8
+ var _rnCore = require("@chipmobilesdk/rn-core");
9
+ /**
10
+ * Fake store — a full `ProviderPort` implementation for automated tests.
11
+ *
12
+ * Lives behind `@chipmobilesdk/rn-payment/testing` so test doubles cannot reach a
13
+ * production bundle.
14
+ *
15
+ * Nearly every requirement in this package concerns a rare ordering or failure
16
+ * path — a pending purchase settling two sessions later, an app killed between
17
+ * payment and acknowledgement, a billing connection dropping mid-sync. None of
18
+ * those are reachable on a real device on demand, so this is what makes them
19
+ * testable at all (NFR-007, SC-008).
20
+ */
21
+
22
+ const DEFAULT_CAPABILITIES = {
23
+ supportsSubscriptions: true,
24
+ supportsPlanChange: true,
25
+ supportsPriceChangeConfirmation: true,
26
+ // Matches Android reality: grace and hold are not separable client-side.
27
+ reportsGraceAndHoldDistinctly: false,
28
+ supportsExternalTransactions: false,
29
+ // The whole point of the fake: it moves no money, so the environment guard
30
+ // lets a test complete a purchase while still blocking the real adapter
31
+ // outside production (FR-014).
32
+ createsRealTransactions: false,
33
+ // Its launch returns at once, so the engine's launch timeout applies and stays
34
+ // testable (FR-035).
35
+ purchaseOutcomeIncludesStoreTime: false
36
+ };
37
+ let sequence = 0;
38
+
39
+ /** A purchase with sensible defaults, so tests state only what they care about. */
40
+ function makePurchase(overrides = {}) {
41
+ sequence += 1;
42
+ return {
43
+ storeProductId: overrides.storeProductId ?? 'store.product.default',
44
+ transactionId: overrides.transactionId ?? `txn_${sequence}`,
45
+ token: overrides.token ?? `token_${sequence}`,
46
+ state: overrides.state ?? 'purchased',
47
+ purchasedAt: overrides.purchasedAt ?? 1_700_000_000_000,
48
+ isAcknowledged: overrides.isAcknowledged ?? false,
49
+ expiresAt: overrides.expiresAt,
50
+ willAutoRenew: overrides.willAutoRenew,
51
+ verificationPayload: overrides.verificationPayload ?? 'fake-verification'
52
+ };
53
+ }
54
+ function createFakeStore(options = {}) {
55
+ let connectOutcome = options.connectOutcome ?? {
56
+ ok: true
57
+ };
58
+ const androidBinding = options.mode === 'android-16.7';
59
+ let capabilities = {
60
+ ...DEFAULT_CAPABILITIES,
61
+ ...(androidBinding ? {
62
+ supportsPriceChangeConfirmation: false
63
+ } : {}),
64
+ ...options.capabilities
65
+ };
66
+ let products = [...(options.products ?? [])];
67
+ let owned = [...(options.owned ?? [])];
68
+ let scripted;
69
+ let finalizeFails = false;
70
+ let connected = false;
71
+ /** Why each pending purchase ended, for the ones `expirePending` or `cancelPending` ended. */
72
+ const endReasons = new Map();
73
+ const acknowledgedTokens = [];
74
+ const consumedTokens = [];
75
+ const managementOpenedFor = [];
76
+ // The same listener sets as the real adapter, so a throwing observer behaves
77
+ // identically here and on a device (PAY-17).
78
+ const connectionListeners = (0, _rnCore.createListenerSet)();
79
+ const purchaseListeners = (0, _rnCore.createListenerSet)();
80
+ let connectCalls = 0;
81
+ let launchCalls = 0;
82
+ let queryOwnedCalls = 0;
83
+ let disconnectCalls = 0;
84
+ const notifyConnection = (next, reason) => {
85
+ connected = next;
86
+ connectionListeners.notify(next, reason);
87
+ };
88
+ return {
89
+ // --- ProviderPort ------------------------------------------------------
90
+ async connect() {
91
+ connectCalls += 1;
92
+ if (connectOutcome.ok) {
93
+ notifyConnection(true);
94
+ }
95
+ return connectOutcome;
96
+ },
97
+ async disconnect() {
98
+ disconnectCalls += 1;
99
+ if (connected) {
100
+ notifyConnection(false, 'disconnect');
101
+ }
102
+ },
103
+ observeConnection(listener) {
104
+ return connectionListeners.add(listener);
105
+ },
106
+ async queryProducts(storeProductIds, productType) {
107
+ return products.filter(p => storeProductIds.includes(p.storeProductId) && p.productType === productType);
108
+ },
109
+ async queryOwned() {
110
+ queryOwnedCalls += 1;
111
+ // Pending purchases are returned flagged, never filtered out: the engine
112
+ // must see them to raise the pending signal while never granting.
113
+ return [...owned];
114
+ },
115
+ async launchPurchase(request) {
116
+ launchCalls += 1;
117
+ const script = scripted;
118
+ scripted = undefined;
119
+ if (!script) {
120
+ return {
121
+ ok: false,
122
+ reason: 'store_error',
123
+ detail: 'no script set'
124
+ };
125
+ }
126
+ if (script.kind === 'failure') {
127
+ return {
128
+ ok: false,
129
+ reason: script.reason
130
+ };
131
+ }
132
+ const purchase = makePurchase({
133
+ storeProductId: request.storeProductId,
134
+ state: script.kind === 'pending' ? 'pending' : 'purchased',
135
+ ...script.overrides
136
+ });
137
+ owned = [...owned.filter(p => p.transactionId !== purchase.transactionId), purchase];
138
+ if (androidBinding) {
139
+ // The binding's update listener fires for every observer, the session-long
140
+ // one included, before the launch settles.
141
+ purchaseListeners.notify(purchase);
142
+ }
143
+ return {
144
+ ok: true,
145
+ purchase
146
+ };
147
+ },
148
+ observePurchases(listener) {
149
+ return purchaseListeners.add(listener);
150
+ },
151
+ async acknowledge(token) {
152
+ if (finalizeFails) {
153
+ throw new Error('fake acknowledge failure');
154
+ }
155
+ // Safe to call for an already-acknowledged transaction (FR-044).
156
+ if (!acknowledgedTokens.includes(token)) {
157
+ acknowledgedTokens.push(token);
158
+ }
159
+ owned = owned.map(p => p.token === token ? {
160
+ ...p,
161
+ isAcknowledged: true
162
+ } : p);
163
+ },
164
+ async consume(token) {
165
+ if (finalizeFails) {
166
+ throw new Error('fake consume failure');
167
+ }
168
+ if (!consumedTokens.includes(token)) {
169
+ consumedTokens.push(token);
170
+ }
171
+ // A consumed purchase stops being owned, which is what lets the same
172
+ // product be bought again (FR-043).
173
+ owned = owned.filter(p => p.token !== token);
174
+ },
175
+ async openSubscriptionManagement(storeProductId) {
176
+ managementOpenedFor.push(storeProductId);
177
+ },
178
+ async confirmPriceChange() {
179
+ return {
180
+ ok: true,
181
+ confirmed: true
182
+ };
183
+ },
184
+ capabilities: () => capabilities,
185
+ pendingEndReason: transactionId => endReasons.get(transactionId),
186
+ // --- Scripting ---------------------------------------------------------
187
+ scriptPurchaseSuccess(overrides) {
188
+ scripted = {
189
+ kind: 'success',
190
+ overrides
191
+ };
192
+ },
193
+ scriptPurchaseFailure(reason) {
194
+ scripted = {
195
+ kind: 'failure',
196
+ reason
197
+ };
198
+ },
199
+ scriptPurchasePending(overrides) {
200
+ scripted = {
201
+ kind: 'pending',
202
+ overrides
203
+ };
204
+ },
205
+ // --- Store state -------------------------------------------------------
206
+ setOwned(purchases) {
207
+ owned = [...purchases];
208
+ },
209
+ pushPurchaseUpdate(purchase) {
210
+ owned = [...owned.filter(p => p.transactionId !== purchase.transactionId), purchase];
211
+ purchaseListeners.notify(purchase);
212
+ },
213
+ revoke(transactionId) {
214
+ owned = owned.filter(p => p.transactionId !== transactionId);
215
+ },
216
+ settlePending(transactionId) {
217
+ owned = owned.map(p => p.transactionId === transactionId ? {
218
+ ...p,
219
+ state: 'purchased'
220
+ } : p);
221
+ },
222
+ cancelPending(transactionId) {
223
+ owned = owned.filter(p => p.transactionId !== transactionId);
224
+ endReasons.set(transactionId, 'cancelled');
225
+ },
226
+ expirePending(transactionId) {
227
+ owned = owned.filter(p => p.transactionId !== transactionId);
228
+ endReasons.set(transactionId, 'expired');
229
+ },
230
+ setProducts(next) {
231
+ products = [...next];
232
+ },
233
+ // --- Connection --------------------------------------------------------
234
+ setConnectOutcome(outcome) {
235
+ connectOutcome = outcome;
236
+ },
237
+ dropConnection(reason = 'service_disconnected') {
238
+ notifyConnection(false, reason);
239
+ },
240
+ restoreConnection() {
241
+ notifyConnection(true);
242
+ },
243
+ // --- Finalization ------------------------------------------------------
244
+ setFinalizeFailure(failing) {
245
+ finalizeFails = failing;
246
+ },
247
+ // --- Inspection --------------------------------------------------------
248
+ acknowledged: () => [...acknowledgedTokens],
249
+ consumed: () => [...consumedTokens],
250
+ connectCount: () => connectCalls,
251
+ launchCount: () => launchCalls,
252
+ queryOwnedCount: () => queryOwnedCalls,
253
+ disconnectCount: () => disconnectCalls,
254
+ subscriptionManagementOpenedFor: () => [...managementOpenedFor],
255
+ reset() {
256
+ connectOutcome = {
257
+ ok: true
258
+ };
259
+ capabilities = {
260
+ ...DEFAULT_CAPABILITIES,
261
+ ...options.capabilities
262
+ };
263
+ products = [];
264
+ owned = [];
265
+ scripted = undefined;
266
+ finalizeFails = false;
267
+ connected = false;
268
+ endReasons.clear();
269
+ acknowledgedTokens.length = 0;
270
+ consumedTokens.length = 0;
271
+ managementOpenedFor.length = 0;
272
+ connectionListeners.clear();
273
+ purchaseListeners.clear();
274
+ connectCalls = 0;
275
+ launchCalls = 0;
276
+ queryOwnedCalls = 0;
277
+ disconnectCalls = 0;
278
+ }
279
+ };
280
+ }
281
+ //# sourceMappingURL=fakeStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_rnCore","require","DEFAULT_CAPABILITIES","supportsSubscriptions","supportsPlanChange","supportsPriceChangeConfirmation","reportsGraceAndHoldDistinctly","supportsExternalTransactions","createsRealTransactions","purchaseOutcomeIncludesStoreTime","sequence","makePurchase","overrides","storeProductId","transactionId","token","state","purchasedAt","isAcknowledged","expiresAt","willAutoRenew","verificationPayload","createFakeStore","options","connectOutcome","ok","androidBinding","mode","capabilities","products","owned","scripted","finalizeFails","connected","endReasons","Map","acknowledgedTokens","consumedTokens","managementOpenedFor","connectionListeners","createListenerSet","purchaseListeners","connectCalls","launchCalls","queryOwnedCalls","disconnectCalls","notifyConnection","next","reason","notify","connect","disconnect","observeConnection","listener","add","queryProducts","storeProductIds","productType","filter","p","includes","queryOwned","launchPurchase","request","script","undefined","detail","kind","purchase","observePurchases","acknowledge","Error","push","map","consume","openSubscriptionManagement","confirmPriceChange","confirmed","pendingEndReason","get","scriptPurchaseSuccess","scriptPurchaseFailure","scriptPurchasePending","setOwned","purchases","pushPurchaseUpdate","revoke","settlePending","cancelPending","set","expirePending","setProducts","setConnectOutcome","outcome","dropConnection","restoreConnection","setFinalizeFailure","failing","acknowledged","consumed","connectCount","launchCount","queryOwnedCount","disconnectCount","subscriptionManagementOpenedFor","reset","clear","length"],"sourceRoot":"../../../src","sources":["testing/fakeStore.ts"],"mappings":";;;;;;;AAaA,IAAAA,OAAA,GAAAC,OAAA;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuFA,MAAMC,oBAA0C,GAAG;EAClDC,qBAAqB,EAAE,IAAI;EAC3BC,kBAAkB,EAAE,IAAI;EACxBC,+BAA+B,EAAE,IAAI;EACrC;EACAC,6BAA6B,EAAE,KAAK;EACpCC,4BAA4B,EAAE,KAAK;EACnC;EACA;EACA;EACAC,uBAAuB,EAAE,KAAK;EAC9B;EACA;EACAC,gCAAgC,EAAE;AACnC,CAAC;AAED,IAAIC,QAAQ,GAAG,CAAC;;AAEhB;AACO,SAASC,YAAYA,CAACC,SAAoC,GAAG,CAAC,CAAC,EAAoB;EACzFF,QAAQ,IAAI,CAAC;EACb,OAAO;IACNG,cAAc,EAAED,SAAS,CAACC,cAAc,IAAI,uBAAuB;IACnEC,aAAa,EAAEF,SAAS,CAACE,aAAa,IAAI,OAAOJ,QAAQ,EAAE;IAC3DK,KAAK,EAAEH,SAAS,CAACG,KAAK,IAAI,SAASL,QAAQ,EAAE;IAC7CM,KAAK,EAAEJ,SAAS,CAACI,KAAK,IAAI,WAAW;IACrCC,WAAW,EAAEL,SAAS,CAACK,WAAW,IAAI,iBAAiB;IACvDC,cAAc,EAAEN,SAAS,CAACM,cAAc,IAAI,KAAK;IACjDC,SAAS,EAAEP,SAAS,CAACO,SAAS;IAC9BC,aAAa,EAAER,SAAS,CAACQ,aAAa;IACtCC,mBAAmB,EAAET,SAAS,CAACS,mBAAmB,IAAI;EACvD,CAAC;AACF;AAEO,S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