@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,116 @@
1
1
  # @chipmobilesdk/rn-payment
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Every package now ships built JavaScript with declaration files, instead of asking the
8
+ app to compile its TypeScript. ([#22](https://github.com/operationd8979/chip-mobile-sdk/pull/22))
9
+
10
+ Each tarball carries `lib/commonjs`, `lib/module` and `lib/typescript` (built with
11
+ `react-native-builder-bob`), and `src/` alongside them. What that changes for a
12
+ consumer:
13
+
14
+ - **Nothing to add to `transformIgnorePatterns`.** `require` resolves to the CommonJS
15
+ build, so an app's Jest loads this package without being told to transform it. That
16
+ was the one thing every consuming app had to know about us (DEP-04).
17
+ - **Typechecking reads our `.d.ts`** rather than compiling our source under our
18
+ `tsconfig`. A consumer's stricter — or looser — settings no longer meet our code.
19
+ - **`import` resolves to ESM**, so a bundler can tree-shake what it does not use.
20
+
21
+ No exported name changed, and no subpath moved: `.`, `./testing`, `./push`,
22
+ `./advanced`, `./app-auth`, `./keychain` and rn-core's twelve subpaths resolve exactly
23
+ as before, each now with its own declarations for both module systems. publint and
24
+ `attw --profile node16` pass on all twelve packages, which they could not before.
25
+
26
+ Inside the monorepo nothing changed either, and that is deliberate: every subpath also
27
+ declares a private `chipmobilesdk-source` condition pointing at its TypeScript, and
28
+ Metro, Jest and `tsc` here ask for that condition first. The demo app bundles 371
29
+ modules straight from `packages/*/src`, so editing a package still changes the app with
30
+ no build step, and coverage is still measured on the source. The condition is named for
31
+ this organization rather than using the conventional `source` because third-party
32
+ packages declare that one too — `@dr.pogodin/react-native-fs` does — and asking for it
33
+ pulled their sources into our stricter compile.
34
+
35
+ `npm run build:packages` builds everything, `prepack` rebuilds before any `npm pack`,
36
+ and `lib/` is git-ignored: the published bytes are produced by the release, never
37
+ committed. `npm run check:manifests` now fails a package whose `main`, `module`,
38
+ `types`, `source` condition, `files`, build script or `prepack` do not match this shape.
39
+
40
+ ### Patch Changes
41
+
42
+ - Every peer range has an upper bound, and no package declares a peer it does not use. ([#21](https://github.com/operationd8979/chip-mobile-sdk/pull/21))
43
+
44
+ A peer range is now a caret, a tilde or an explicit `<`, except for `react` and
45
+ `react-native`: an app brings exactly one of each, so a floor is the only useful thing
46
+ to say about them. Every other peer is a library the app installs beside us, and an
47
+ open `>=` was a promise about versions nobody had run — mmkv 3→4 lost entitlements and
48
+ pending purchases exactly that way.
49
+
50
+ **Four of the new ceilings exclude a version that is already published**, so an app
51
+ that took the open range at its word may now see a peer warning. The new bound is the
52
+ major this release is tested against, which is the thing the old range failed to say:
53
+
54
+ | Peer | Was | Now | Published above the ceiling |
55
+ |---|---|---|---|
56
+ | `react-native-app-auth` (rn-auth) | `>=8` | `^8.0.0` | 9.0.0 |
57
+ | `react-native-keychain` (rn-auth) | `>=10` | `^10.0.0` | 11.0.0 |
58
+ | `@op-engineering/op-sqlite` (rn-local-db) | `>=17.1.0` | `^17.1.0` | 18.x, 19.x |
59
+ | `@react-native-firebase/messaging` (rn-notification) | `>=26.0.0` | `^26.0.0` | 27.x |
60
+
61
+ The others — `react-native-vision-camera` `^5.1.1`, `react-native-svg` `^15.15.0`,
62
+ `react-native-unistyles` `^3.2.0`, `@dr.pogodin/react-native-fs` `^2.39.2`,
63
+ `react-native-quick-crypto` `^1.0.0`, `react-native-notify-kit` `^10.5.0`,
64
+ `react-native-localize` `^3.7.0`, `react-native-mmkv` `^4.0.0` — exclude nothing that
65
+ exists today. rn-payment's mmkv range was already bounded (`>=4.0.0 <5`) and is now
66
+ written as the caret that means the same thing.
67
+
68
+ Peers nothing imports are gone. `rn-theme`, `rn-local-db` and `rn-notification` asked
69
+ for `react` without having a component or a hook between them; `rn-auth`, `rn-ai` and
70
+ `rn-i18n` asked for `react-native` without touching a React Native API (rn-auth reaches
71
+ both native modules through `lazyPeer`, rn-i18n formats on `Intl`); `rn-notification`
72
+ asked for `@react-native-firebase/app`, which messaging declares itself. `rn-ai` no
73
+ longer peers on `@chipmobilesdk/rn-auth` at all — it asks for a `TokenProvider`, a
74
+ two-method interface rn-auth's `auth` satisfies, so an app with its own token source
75
+ installs nothing extra. An app that enables push or signs in through rn-auth installs
76
+ the same packages as before; it is the manifest that stopped overstating.
77
+
78
+ `react-native-localize` is declared optional, which is what the code already did: the
79
+ time-zone reader goes through `lazyPeer` and falls back to `Intl` without it. The
80
+ `peerDependenciesMeta` entries that said `optional: false` are gone — that is npm's
81
+ default, and writing it down only invited the question of which peers were undecided.
82
+
83
+ `npm run check:manifests` now fails on an unbounded peer range, a peer nothing in
84
+ `src/` imports, and a `peerDependenciesMeta` entry for either, so the policy holds
85
+ without anyone remembering it.
86
+
87
+ - Each package's public API and its weight are now recorded in the repository, so a change
88
+ to either is reviewed rather than discovered. ([#23](https://github.com/operationd8979/chip-mobile-sdk/pull/23))
89
+
90
+ `packages/<pkg>/etc/*.api.md` is an api-extractor report per entrypoint — twenty-seven
91
+ of them, generated from the declarations the package publishes and committed. A renamed
92
+ type, a widened union, one more optional field: all of it shows up in a pull request's
93
+ diff. `npm run check:api` fails when a report is out of date and `npm run api:update`
94
+ rewrites them.
95
+
96
+ A report that moves now needs a **minor or major** changeset for that package.
97
+ `check:changesets` enforces it, because the report is generated from what the package
98
+ publishes, and a patch release that moves the public surface is how a consumer's build
99
+ breaks on `npm update`. A report added for the first time is a baseline, not a change.
100
+ `./testing` deliberately has no report: test doubles are not a surface a release is
101
+ gated on.
102
+
103
+ `npm run check:size` holds every entrypoint to a budget in `.size-limit.json`, measured
104
+ on the ESM build with peers and rn-core treated as external — they are what an app
105
+ installs beside us, not our weight. Each budget started at today's measurement plus five
106
+ per cent, so growth becomes a decision someone makes instead of a drift nobody sees. The
107
+ current figures run from 500 B (`rn-core/lazy`) to 19 kB (rn-notification).
108
+
109
+ No behaviour or API changed in this release; the entry is here so the changelog records
110
+ when the reports and the budgets began.
111
+ - Updated dependencies ([#22](https://github.com/operationd8979/chip-mobile-sdk/pull/22), [#23](https://github.com/operationd8979/chip-mobile-sdk/pull/23)):
112
+ - @chipmobilesdk/rn-core@0.2.0
113
+
3
114
  ## 0.6.0
4
115
 
5
116
  ### Minor Changes
package/README.md CHANGED
@@ -115,7 +115,7 @@ Verified against this repository's toolchain, not assumed:
115
115
  | Android `minSdk` / `compileSdk` / `targetSdk` | 24 / 36 / 36 |
116
116
  | Kotlin | 2.1.20 |
117
117
  | `react-native-iap` | >= 16.7.3 < 17 (verified 16.7.3) |
118
- | `react-native-mmkv` | >= 4.0.0 < 5 (the store uses v4's `createMMKV`) |
118
+ | `react-native-mmkv` | `^4.0.0` (the store uses v4's `createMMKV`) |
119
119
  | `react-native-nitro-modules` | as required by `react-native-iap` (not a peer of this package) |
120
120
 
121
121
  **Why the `react-native-iap` ceiling is the next major.** Both the Nitro peer
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createStoreProvider = createStoreProvider;
7
+ exports.createUnsupportedProvider = createUnsupportedProvider;
8
+ var _reactNative = require("react-native");
9
+ var _iapAdapter = require("./iap-adapter.js");
10
+ /**
11
+ * Platform selection for the store adapter.
12
+ *
13
+ * This exists so the public surface never names a store. An app writes
14
+ * `createStoreProvider()`, not `createIapAdapter()` — the same call will pick the
15
+ * StoreKit adapter once iOS exists, and no consumer line changes (FR-002, FR-004,
16
+ * FR-007).
17
+ *
18
+ * On a platform with no adapter the result is a stub that reports
19
+ * `platform_unsupported` rather than throwing. That is what lets a host app start
20
+ * and run normally where selling is impossible, losing only the ability to sell
21
+ * (FR-021, FR-023).
22
+ */
23
+
24
+ const UNSUPPORTED_CAPABILITIES = {
25
+ supportsSubscriptions: false,
26
+ supportsPlanChange: false,
27
+ supportsPriceChangeConfirmation: false,
28
+ reportsGraceAndHoldDistinctly: false,
29
+ supportsExternalTransactions: false,
30
+ /** Nothing here can charge anyone, so the environment guard has nothing to block. */
31
+ createsRealTransactions: false,
32
+ purchaseOutcomeIncludesStoreTime: false
33
+ };
34
+
35
+ /**
36
+ * The no-adapter stub.
37
+ *
38
+ * Every operation fails safely and predictably. Notably `queryOwned` returns an
39
+ * empty list rather than throwing: the engine then computes `not_entitled` after a
40
+ * successful-but-empty sync, which is honest — on a platform with no store, the
41
+ * user genuinely holds nothing this package can verify.
42
+ */
43
+ function createUnsupportedProvider() {
44
+ return {
45
+ async connect() {
46
+ return {
47
+ ok: false,
48
+ reason: 'platform_unsupported',
49
+ retryable: false
50
+ };
51
+ },
52
+ async disconnect() {
53
+ // Nothing was ever connected.
54
+ },
55
+ observeConnection() {
56
+ return () => undefined;
57
+ },
58
+ async queryProducts() {
59
+ return [];
60
+ },
61
+ async queryOwned() {
62
+ return [];
63
+ },
64
+ async launchPurchase() {
65
+ return {
66
+ ok: false,
67
+ reason: 'not_ready',
68
+ detail: 'platform_unsupported'
69
+ };
70
+ },
71
+ observePurchases() {
72
+ return () => undefined;
73
+ },
74
+ async acknowledge() {
75
+ // No transaction can exist to acknowledge.
76
+ },
77
+ async consume() {
78
+ // As above.
79
+ },
80
+ async openSubscriptionManagement() {
81
+ // No store screen to open.
82
+ },
83
+ async confirmPriceChange() {
84
+ return {
85
+ ok: false,
86
+ reason: 'not_ready'
87
+ };
88
+ },
89
+ capabilities: () => UNSUPPORTED_CAPABILITIES
90
+ };
91
+ }
92
+ /**
93
+ * The platform's store adapter.
94
+ *
95
+ * iOS deliberately returns the stub today rather than throwing: the contract is
96
+ * prepared for StoreKit, the implementation is not, and an app running on iOS
97
+ * should degrade to "cannot sell here" instead of crashing.
98
+ */
99
+ function createStoreProvider(options = {}) {
100
+ if (options.forceUnsupported) {
101
+ return createUnsupportedProvider();
102
+ }
103
+ if (_reactNative.Platform.OS === 'android') {
104
+ return (0, _iapAdapter.createIapAdapter)();
105
+ }
106
+ return createUnsupportedProvider();
107
+ }
108
+
109
+ /** Exported for a test or a screen that needs the stub explicitly. */
110
+ //# sourceMappingURL=createStoreProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_iapAdapter","UNSUPPORTED_CAPABILITIES","supportsSubscriptions","supportsPlanChange","supportsPriceChangeConfirmation","reportsGraceAndHoldDistinctly","supportsExternalTransactions","createsRealTransactions","purchaseOutcomeIncludesStoreTime","createUnsupportedProvider","connect","ok","reason","retryable","disconnect","observeConnection","undefined","queryProducts","queryOwned","launchPurchase","detail","observePurchases","acknowledge","consume","openSubscriptionManagement","confirmPriceChange","capabilities","createStoreProvider","options","forceUnsupported","Platform","OS","createIapAdapter"],"sourceRoot":"../../../src","sources":["adapter/createStoreProvider.ts"],"mappings":";;;;;;;AAcA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA,MAAME,wBAA8C,GAAG;EACtDC,qBAAqB,EAAE,KAAK;EAC5BC,kBAAkB,EAAE,KAAK;EACzBC,+BAA+B,EAAE,KAAK;EACtCC,6BAA6B,EAAE,KAAK;EACpCC,4BAA4B,EAAE,KAAK;EACnC;EACAC,uBAAuB,EAAE,KAAK;EAC9BC,gCAAgC,EAAE;AACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,yBAAyBA,CAAA,EAAiB;EAClD,OAAO;IACN,MAAMC,OAAOA,CAAA,EAAoC;MAChD,OAAO;QAAEC,EAAE,EAAE,KAAK;QAAEC,MAAM,EAAE,sBAAsB;QAAEC,SAAS,EAAE;MAAM,CAAC;IACvE,CAAC;IACD,MAAMC,UAAUA,CAAA,EAAkB;MACjC;IAAA,CACA;IACDC,iBAAiBA,CAAA,EAAgB;MAChC,OAAO,MAAMC,SAAS;IACvB,CAAC;IACD,MAAMC,aAAaA,CAAA,EAA+B;MACjD,OAAO,EAAE;IACV,CAAC;IACD,MAAMC,UAAUA,CAAA,EAAgC;MAC/C,OAAO,EAAE;IACV,CAAC;IACD,MAAMC,cAAcA,CAAA,EAAqC;MACxD,OAAO;QAAER,EAAE,EAAE,KAAK;QAAEC,MAAM,EAAE,WAAW;QAAEQ,MAAM,EAAE;MAAuB,CAAC;IAC1E,CAAC;IACDC,gBAAgBA,CAAA,EAAgB;MAC/B,OAAO,MAAML,SAAS;IACvB,CAAC;IACD,MAAMM,WAAWA,CAAA,EAAkB;MAClC;IAAA,CACA;IACD,MAAMC,OAAOA,CAAA,EAAkB;MAC9B;IAAA,CACA;IACD,MAAMC,0BAA0BA,CAAA,EAAkB;MACjD;IAAA,CACA;IACD,MAAMC,kBAAkBA,CAAA,EAAwC;MAC/D,OAAO;QAAEd,EAAE,EAAE,KAAK;QAAEC,MAAM,EAAE;MAAY,CAAC;IAC1C,CAAC;IACDc,YAAY,EAAEA,CAAA,KAAMzB;EACrB,CAAC;AACF;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS0B,mBAAmBA,CAACC,OAA6B,GAAG,CAAC,CAAC,EAAgB;EACrF,IAAIA,OAAO,CAACC,gBAAgB,EAAE;IAC7B,OAAOpB,yBAAyB,CAAC,CAAC;EACnC;EACA,IAAIqB,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;IAC9B,OAAO,IAAAC,4BAAgB,EAAC,CAAC;EAC1B;EACA,OAAOvB,yBAAyB,CAAC,CAAC;AACnC;;AAEA","ignoreList":[]}
@@ -0,0 +1,393 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createIapAdapter = createIapAdapter;
7
+ Object.defineProperty(exports, "toProviderPurchaseState", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _iapShapes.toProviderPurchaseState;
11
+ }
12
+ });
13
+ exports.toRequestProps = toRequestProps;
14
+ var _rnCore = require("@chipmobilesdk/rn-core");
15
+ var _iapShapes = require("./iapShapes.js");
16
+ var _errors = require("../diagnostics/errors.js");
17
+ /**
18
+ * Android adapter over `react-native-iap` (Play Billing).
19
+ *
20
+ * **The only file in this package that touches the billing library.** Everything
21
+ * above it talks to `ProviderPort`, which is what keeps the binding replaceable
22
+ * and lets an iOS adapter be added without changing a consumer call (FR-002,
23
+ * FR-007). ESLint enforces that boundary.
24
+ *
25
+ * ## Verified against react-native-iap 16.7.3
26
+ *
27
+ * 0.3.0 was written before the binding was installed, from its documentation, and
28
+ * no purchase could complete on a device. Checked against the installed 16.7.3
29
+ * source for 0.3.1, two facts shape the purchase path:
30
+ *
31
+ * - The request is keyed by store: `google` / `apple`. 0.3.0 sent `android`, which
32
+ * the binding rejects (`empty-sku-list`) before Play opens. The request type is
33
+ * now the binding's own `RequestPurchaseProps`, so a renamed key fails to
34
+ * typecheck here instead of failing on a user's device.
35
+ * - On Android `requestPurchase` resolves with an **empty list** once the flow
36
+ * ends, whatever happened. The outcome (bought, pending, cancelled, failed)
37
+ * arrives only through `purchaseUpdatedListener` / `purchaseErrorListener`, so
38
+ * `launchPurchase` waits for those events.
39
+ *
40
+ * The module is still required lazily, and `IapModule` still names exactly the
41
+ * surface used. `__tests__/iap-adapter.test.ts` drives this file through a fake
42
+ * binding that behaves as 16.7.3 does; the rest of the suite uses the fake store.
43
+ *
44
+ * ## Known upstream defect this guards against
45
+ *
46
+ * openiap#408: the Android bridge did not clear its internal `isInitialized` flag
47
+ * on disconnect, so `connected` stayed true, later calls failed with
48
+ * `E_NOT_PREPARED`, and `reconnect()` reported success without rebuilding
49
+ * anything. This adapter therefore (a) tracks connection state itself rather than
50
+ * trusting the binding's flag, and (b) always performs a full
51
+ * `endConnection` + `initConnection` cycle instead of calling any reconnect
52
+ * shortcut.
53
+ */
54
+
55
+ // Translation lives in `iapShapes`; it is published from here, where every
56
+ // consumer has always imported it from.
57
+
58
+ /**
59
+ * Exactly what this adapter needs from the binding.
60
+ *
61
+ * Declared narrowly on purpose: it documents the coupling, and it means a binding
62
+ * upgrade that changes one of these shapes fails to typecheck here instead of
63
+ * failing silently at runtime on a user's device.
64
+ */
65
+
66
+ /**
67
+ * How long to wait for the outcome event after `requestPurchase` has resolved.
68
+ * The binding emits the event before or as it resolves, so this only bounds the
69
+ * case where none ever comes; it never runs while the user is in Play's UI.
70
+ */
71
+ const RESULT_EVENT_GRACE_MS = 2_000;
72
+
73
+ /** Play's replacement modes, by the codes the engine passes (`engine/subscriptions.ts`). */
74
+ const REPLACEMENT_MODES = {
75
+ WITH_TIME_PRORATION: 'with-time-proration',
76
+ CHARGE_FULL_PRICE: 'charge-full-price',
77
+ CHARGE_PRORATED_PRICE: 'charge-prorated-price',
78
+ DEFERRED: 'deferred'
79
+ };
80
+
81
+ /** The request in the binding's 16.7 shape: keyed `google`, not `android`. */
82
+ function toRequestProps(request) {
83
+ const google = {
84
+ skus: [request.storeProductId],
85
+ ...(request.obfuscatedAccountId ? {
86
+ obfuscatedAccountId: request.obfuscatedAccountId
87
+ } : {})
88
+ };
89
+ if (request.productType !== 'subscription') {
90
+ return {
91
+ request: {
92
+ google
93
+ },
94
+ type: 'in-app'
95
+ };
96
+ }
97
+ const replacementMode = request.prorationMode ? REPLACEMENT_MODES[request.prorationMode] : undefined;
98
+ return {
99
+ request: {
100
+ google: {
101
+ ...google,
102
+ ...(request.offerKey ? {
103
+ subscriptionOffers: [{
104
+ sku: request.storeProductId,
105
+ offerToken: request.offerKey
106
+ }]
107
+ } : {}),
108
+ // A plan change: the token of the purchase being replaced, and — for
109
+ // the replacement mode to apply — its product id (Billing 8.1+).
110
+ ...(request.replacePurchaseToken ? {
111
+ purchaseToken: request.replacePurchaseToken
112
+ } : {}),
113
+ ...(request.replacePurchaseToken && request.replaceStoreProductId && replacementMode ? {
114
+ subscriptionProductReplacementParams: {
115
+ oldProductId: request.replaceStoreProductId,
116
+ replacementMode
117
+ }
118
+ } : {})
119
+ }
120
+ },
121
+ type: 'subs'
122
+ };
123
+ }
124
+ const iapPeer = (0, _rnCore.lazyPeer)('react-native-iap', () => {
125
+ // Inside `try`, so Metro bundles an app that leaves this optional peer out.
126
+ try {
127
+ return require('react-native-iap');
128
+ } catch (cause) {
129
+ throw cause;
130
+ }
131
+ });
132
+ function loadModule() {
133
+ return iapPeer.require((peer, cause) => new _errors.PaymentError({
134
+ code: 'PAYMENT_UNAVAILABLE',
135
+ message: `${peer} is not installed or its native module is not linked`,
136
+ operation: 'initialize',
137
+ cause: (0, _errors.redact)(cause)
138
+ }));
139
+ }
140
+ const ANDROID_CAPABILITIES = {
141
+ supportsSubscriptions: true,
142
+ supportsPlanChange: true,
143
+ supportsPriceChangeConfirmation: false,
144
+ /**
145
+ * False, and this is a platform fact rather than a gap in this adapter.
146
+ *
147
+ * Client-side Play Billing cannot separate grace period from account hold: a
148
+ * grace-period subscription is still returned as active, and one in account
149
+ * hold stops being returned at all — indistinguishable from expired, cancelled,
150
+ * or refunded. The entitlement layer reads this flag and reports
151
+ * `indeterminate` rather than inventing a distinction (research.md R5).
152
+ */
153
+ reportsGraceAndHoldDistinctly: false,
154
+ supportsExternalTransactions: false,
155
+ /** This one really does move money, which is what arms the environment guard. */
156
+ createsRealTransactions: true,
157
+ /** The outcome event comes only when the user leaves Play's purchase UI. */
158
+ purchaseOutcomeIncludesStoreTime: true
159
+ };
160
+ function createIapAdapter(options = {}) {
161
+ let iap = options.module;
162
+
163
+ /** Tracked here, never read from the binding — see the openiap#408 note above. */
164
+ let connected = false;
165
+ const connectionListeners = (0, _rnCore.createListenerSet)();
166
+ const purchaseListeners = (0, _rnCore.createListenerSet)();
167
+ /** Only an in-flight `launchPurchase` listens here; see there. */
168
+ const purchaseErrorListeners = (0, _rnCore.createListenerSet)();
169
+ let updateSub;
170
+ let errorSub;
171
+ const module = () => {
172
+ if (!iap) {
173
+ iap = loadModule();
174
+ }
175
+ return iap;
176
+ };
177
+ const notifyConnection = (next, reason) => {
178
+ if (connected === next) {
179
+ return;
180
+ }
181
+ connected = next;
182
+ connectionListeners.notify(next, reason);
183
+ };
184
+ const attachListeners = () => {
185
+ // Every connect attaches, so whatever an earlier connect left must go first.
186
+ // Overwriting the handles orphaned the old native listeners, which kept
187
+ // firing — every purchase update reached the engine once per connect.
188
+ detachListeners();
189
+ const mod = module();
190
+ updateSub = mod.purchaseUpdatedListener(raw => {
191
+ purchaseListeners.notify((0, _iapShapes.normalizePurchase)(raw));
192
+ });
193
+ errorSub = mod.purchaseErrorListener(error => {
194
+ // A `not-prepared` error is the one signal the binding gives that the
195
+ // service went away underneath us, so it is treated as a disconnect
196
+ // rather than as a purchase failure.
197
+ if ((0, _iapShapes.mapErrorCode)(error.code) === 'not_ready') {
198
+ notifyConnection(false, 'not_prepared');
199
+ }
200
+ purchaseErrorListeners.notify(error);
201
+ });
202
+ };
203
+ const detachListeners = () => {
204
+ updateSub?.remove();
205
+ updateSub = undefined;
206
+ errorSub?.remove();
207
+ errorSub = undefined;
208
+ };
209
+ return {
210
+ async connect() {
211
+ try {
212
+ const mod = module();
213
+ // Always a full cycle. The binding's own reconnect has reported success
214
+ // without rebuilding anything, so we never rely on it (openiap#408).
215
+ if (connected) {
216
+ await mod.endConnection().catch(() => undefined);
217
+ connected = false;
218
+ }
219
+ const ok = await mod.initConnection();
220
+ if (!ok) {
221
+ return {
222
+ ok: false,
223
+ reason: 'no_billing_service',
224
+ retryable: true
225
+ };
226
+ }
227
+ attachListeners();
228
+ notifyConnection(true);
229
+ return {
230
+ ok: true
231
+ };
232
+ } catch (error) {
233
+ const code = error.code;
234
+ // A missing or too-old Play Services install is not the same as a
235
+ // transient error, and the app shows different things for each (FR-021).
236
+ if (code === 'E_IAP_NOT_AVAILABLE' || code === 'iap-not-available') {
237
+ return {
238
+ ok: false,
239
+ reason: 'no_billing_service',
240
+ retryable: false
241
+ };
242
+ }
243
+ if (code === 'E_SERVICE_ERROR') {
244
+ return {
245
+ ok: false,
246
+ reason: 'billing_service_outdated',
247
+ retryable: true
248
+ };
249
+ }
250
+ return {
251
+ ok: false,
252
+ reason: 'store_error',
253
+ retryable: true
254
+ };
255
+ }
256
+ },
257
+ async disconnect() {
258
+ detachListeners();
259
+ try {
260
+ await module().endConnection();
261
+ } catch {
262
+ // Already down; nothing to tear down.
263
+ }
264
+ notifyConnection(false, 'disconnect');
265
+ },
266
+ observeConnection(listener) {
267
+ return connectionListeners.add(listener);
268
+ },
269
+ async queryProducts(storeProductIds, productType) {
270
+ const raw = await module().fetchProducts({
271
+ skus: storeProductIds,
272
+ type: productType === 'subscription' ? 'subs' : 'in-app'
273
+ });
274
+ return raw.map(product => (0, _iapShapes.normalizeProduct)(product, productType));
275
+ },
276
+ async queryOwned() {
277
+ const raw = await module().getAvailablePurchases();
278
+ // Pending purchases are mapped through, flagged rather than filtered: the
279
+ // engine needs to see them to raise the pending signal (FR-038).
280
+ return raw.map(_iapShapes.normalizePurchase);
281
+ },
282
+ /**
283
+ * Settles on the first outcome event for this product: a purchase update
284
+ * (bought or pending) or a purchase error (cancelled, already owned, …).
285
+ *
286
+ * The binding's promise is not the outcome: on Android it resolves with an
287
+ * empty list when the flow ends, whatever happened. Its listeners also feed
288
+ * `observePurchases`, so the engine sees a bought purchase twice — here and
289
+ * as a store update — and grants it once (FR-044).
290
+ */
291
+ launchPurchase(request) {
292
+ const sku = request.storeProductId;
293
+ return new Promise(resolve => {
294
+ let settled = false;
295
+ let grace;
296
+ const onPurchase = purchase => {
297
+ if (purchase.storeProductId === sku) {
298
+ finish({
299
+ ok: true,
300
+ purchase
301
+ });
302
+ }
303
+ };
304
+ const onError = error => {
305
+ if (error.productId && error.productId !== sku) {
306
+ return;
307
+ }
308
+ finish({
309
+ ok: false,
310
+ reason: (0, _iapShapes.mapErrorCode)(error.code),
311
+ detail: error.code
312
+ });
313
+ };
314
+ const fail = error => {
315
+ const code = error?.code;
316
+ finish({
317
+ ok: false,
318
+ reason: (0, _iapShapes.mapErrorCode)(code),
319
+ detail: code
320
+ });
321
+ };
322
+ function finish(outcome) {
323
+ if (settled) {
324
+ return;
325
+ }
326
+ settled = true;
327
+ clearTimeout(grace);
328
+ stopPurchase();
329
+ stopError();
330
+ resolve(outcome);
331
+ }
332
+ const stopPurchase = purchaseListeners.add(onPurchase);
333
+ const stopError = purchaseErrorListeners.add(onError);
334
+ try {
335
+ module().requestPurchase(toRequestProps(request)).then(() => {
336
+ if (!settled) {
337
+ grace = setTimeout(() => finish({
338
+ ok: false,
339
+ reason: 'store_error',
340
+ detail: 'no purchase event'
341
+ }), RESULT_EVENT_GRACE_MS);
342
+ }
343
+ }, fail);
344
+ } catch (error) {
345
+ fail(error);
346
+ }
347
+ });
348
+ },
349
+ observePurchases(listener) {
350
+ return purchaseListeners.add(listener);
351
+ },
352
+ async acknowledge(token) {
353
+ // Idempotent at the store: acknowledging an already-acknowledged purchase
354
+ // is accepted, which is what FR-044 relies on.
355
+ await module().finishTransaction({
356
+ purchase: {
357
+ purchaseToken: token
358
+ },
359
+ isConsumable: false
360
+ });
361
+ },
362
+ async consume(token) {
363
+ await module().finishTransaction({
364
+ purchase: {
365
+ purchaseToken: token
366
+ },
367
+ isConsumable: true
368
+ });
369
+ },
370
+ async openSubscriptionManagement(storeProductId) {
371
+ // The store's own screen. Platforms forbid a self-built cancellation
372
+ // screen, so there is deliberately no alternative path here (FR-066).
373
+ const mod = module();
374
+ if (!mod.deepLinkToSubscriptions) {
375
+ return;
376
+ }
377
+ await mod.deepLinkToSubscriptions({
378
+ skuAndroid: storeProductId
379
+ });
380
+ },
381
+ async confirmPriceChange() {
382
+ // Play has no client-side price-change confirmation flow; it notifies the
383
+ // user itself. Reported as unsupported rather than faked, matching
384
+ // `supportsPriceChangeConfirmation: false` (FR-067).
385
+ return {
386
+ ok: false,
387
+ reason: 'store_error'
388
+ };
389
+ },
390
+ capabilities: () => ANDROID_CAPABILITIES
391
+ };
392
+ }
393
+ //# sourceMappingURL=iap-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_rnCore","require","_iapShapes","_errors","RESULT_EVENT_GRACE_MS","REPLACEMENT_MODES","WITH_TIME_PRORATION","CHARGE_FULL_PRICE","CHARGE_PRORATED_PRICE","DEFERRED","toRequestProps","request","google","skus","storeProductId","obfuscatedAccountId","productType","type","replacementMode","prorationMode","undefined","offerKey","subscriptionOffers","sku","offerToken","replacePurchaseToken","purchaseToken","replaceStoreProductId","subscriptionProductReplacementParams","oldProductId","iapPeer","lazyPeer","cause","loadModule","peer","PaymentError","code","message","operation","redact","ANDROID_CAPABILITIES","supportsSubscriptions","supportsPlanChange","supportsPriceChangeConfirmation","reportsGraceAndHoldDistinctly","supportsExternalTransactions","createsRealTransactions","purchaseOutcomeIncludesStoreTime","createIapAdapter","options","iap","module","connected","connectionListeners","createListenerSet","purchaseListeners","purchaseErrorListeners","updateSub","errorSub","notifyConnection","next","reason","notify","attachListeners","detachListeners","mod","purchaseUpdatedListener","raw","normalizePurchase","purchaseErrorListener","error","mapErrorCode","remove","connect","endConnection","catch","ok","initConnection","retryable","disconnect","observeConnection","listener","add","queryProducts","storeProductIds","fetchProducts","map","product","normalizeProduct","queryOwned","getAvailablePurchases","launchPurchase","Promise","resolve","settled","grace","onPurchase","purchase","finish","onError","productId","detail","fail","outcome","clearTimeout","stopPurchase","stopError","requestPurchase","then","setTimeout","observePurchases","acknowledge","token","finishTransaction","isConsumable","consume","openSubscriptionManagement","deepLinkToSubscriptions","skuAndroid","confirmPriceChange","capabilities"],"sourceRoot":"../../../src","sources":["adapter/iap-adapter.ts"],"mappings":";;;;;;;;;;;;;AAsCA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAD,OAAA;AAQA,IAAAE,OAAA,GAAAF,OAAA;AAnDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA6BA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACA,MAAMG,qBAAqB,GAAG,KAAK;;AAEnC;AACA,MAAMC,iBAAqE,GAAG;EAC7EC,mBAAmB,EAAE,qBAAqB;EAC1CC,iBAAiB,EAAE,mBAAmB;EACtCC,qBAAqB,EAAE,uBAAuB;EAC9CC,QAAQ,EAAE;AACX,CAAC;;AAED;AACO,SAASC,cAAcA,CAACC,OAAgC,EAAwB;EACtF,MAAMC,MAAM,GAAG;IACdC,IAAI,EAAE,CAACF,OAAO,CAACG,cAAc,CAAC;IAC9B,IAA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