@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 @@
1
+ {"version":3,"names":["ensure","runChecks","CONFORMANCE_STORE","products","storeProductId","productType","formattedPrice","owned","token","state","providerPortChecks","name","run","harness","port","create","disconnect","outcome","connect","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"],"sourceRoot":"../../../src","sources":["testing/conformance.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACCA,MAAM,EACNC,SAAS,QAGH,gCAAgC;AAmCvC;AACA,OAAO,MAAMC,iBAAgC,GAAG;EAC/CC,QAAQ,EAAE,CACT;IACCC,cAAc,EAAE,wBAAwB;IACxCC,WAAW,EAAE,oBAAoB;IACjCC,cAAc,EAAE;EACjB,CAAC,EACD;IACCF,cAAc,EAAE,mBAAmB;IACnCC,WAAW,EAAE,qBAAqB;IAClCC,cAAc,EAAE;EACjB,CAAC,CACD;EACDC,KAAK,EAAE,CACN;IAAEH,cAAc,EAAE,wBAAwB;IAAEI,KAAK,EAAE,aAAa;IAAEC,KAAK,EAAE;EAAY,CAAC,EACtF;IAAEL,cAAc,EAAE,mBAAmB;IAAEI,KAAK,EAAE,eAAe;IAAEC,KAAK,EAAE;EAAU,CAAC;AAEnF,CAAC;AA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CAACiB,gBAAgB,CAAC,WAAW,CAAC;IACrC,MAAMtB,OAAO,GAAG,MAAMK,OAAO,CAACR,IAAI,CAAC0B,cAAc,CAAC;MACjDpC,cAAc,EAAE,wBAAwB;MACxCC,WAAW,EAAE;IACd,CAAC,CAAC;IACFL,MAAM,CAAC,CAACiB,OAAO,CAACE,EAAE,EAAE,sCAAsC,CAAC;IAC3DnB,MAAM,CAACiB,OAAO,CAACwB,MAAM,KAAK,gBAAgB,EAAE,UAAUxB,OAAO,CAACwB,MAAM,EAAE,CAAC;EACxE;AACD,CAAC,EACD;EACC9B,IAAI,EAAE,wCAAwC;EAC9C,MAAMC,GAAGA,CAACC,OAAO,EAAE;IAClB,MAAM;MAAEC;IAAK,CAAC,GAAGD,OAAO,CAACE,MAAM,CAACb,iBAAiB,CAAC;IAClD,MAAMY,IAAI,CAACI,OAAO,CAAC,CAAC;IACpB,MAAMJ,IAAI,CAAC4B,WAAW,CAAC,aAAa,CAAC;IACrC,MAAM5B,IAAI,CAAC4B,WAAW,CAAC,aAAa,CAAC;IACrC,MAAM5B,IAAI,CAAC6B,OAAO,CAAC,eAAe,CAAC;IACnC,MAAM7B,IAAI,CAAC6B,OAAO,CAAC,eAAe,CAAC;EACpC;AACD,CAAC,CACD;AAED,OAAO,SAASC,0BAA0BA,CAAC/B,OAAwB,EAA8B;EAChG,OAAOZ,SAAS,CAAC,MAAMY,OAAO,EAAEH,kBAAkB,CAAC;AACpD","ignoreList":[]}
@@ -0,0 +1,276 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Fake store — a full `ProviderPort` implementation for automated tests.
5
+ *
6
+ * Lives behind `@chipmobilesdk/rn-payment/testing` so test doubles cannot reach a
7
+ * production bundle.
8
+ *
9
+ * Nearly every requirement in this package concerns a rare ordering or failure
10
+ * path — a pending purchase settling two sessions later, an app killed between
11
+ * payment and acknowledgement, a billing connection dropping mid-sync. None of
12
+ * those are reachable on a real device on demand, so this is what makes them
13
+ * testable at all (NFR-007, SC-008).
14
+ */
15
+
16
+ import { createListenerSet } from '@chipmobilesdk/rn-core';
17
+ const DEFAULT_CAPABILITIES = {
18
+ supportsSubscriptions: true,
19
+ supportsPlanChange: true,
20
+ supportsPriceChangeConfirmation: true,
21
+ // Matches Android reality: grace and hold are not separable client-side.
22
+ reportsGraceAndHoldDistinctly: false,
23
+ supportsExternalTransactions: false,
24
+ // The whole point of the fake: it moves no money, so the environment guard
25
+ // lets a test complete a purchase while still blocking the real adapter
26
+ // outside production (FR-014).
27
+ createsRealTransactions: false,
28
+ // Its launch returns at once, so the engine's launch timeout applies and stays
29
+ // testable (FR-035).
30
+ purchaseOutcomeIncludesStoreTime: false
31
+ };
32
+ let sequence = 0;
33
+
34
+ /** A purchase with sensible defaults, so tests state only what they care about. */
35
+ export function makePurchase(overrides = {}) {
36
+ sequence += 1;
37
+ return {
38
+ storeProductId: overrides.storeProductId ?? 'store.product.default',
39
+ transactionId: overrides.transactionId ?? `txn_${sequence}`,
40
+ token: overrides.token ?? `token_${sequence}`,
41
+ state: overrides.state ?? 'purchased',
42
+ purchasedAt: overrides.purchasedAt ?? 1_700_000_000_000,
43
+ isAcknowledged: overrides.isAcknowledged ?? false,
44
+ expiresAt: overrides.expiresAt,
45
+ willAutoRenew: overrides.willAutoRenew,
46
+ verificationPayload: overrides.verificationPayload ?? 'fake-verification'
47
+ };
48
+ }
49
+ export function createFakeStore(options = {}) {
50
+ let connectOutcome = options.connectOutcome ?? {
51
+ ok: true
52
+ };
53
+ const androidBinding = options.mode === 'android-16.7';
54
+ let capabilities = {
55
+ ...DEFAULT_CAPABILITIES,
56
+ ...(androidBinding ? {
57
+ supportsPriceChangeConfirmation: false
58
+ } : {}),
59
+ ...options.capabilities
60
+ };
61
+ let products = [...(options.products ?? [])];
62
+ let owned = [...(options.owned ?? [])];
63
+ let scripted;
64
+ let finalizeFails = false;
65
+ let connected = false;
66
+ /** Why each pending purchase ended, for the ones `expirePending` or `cancelPending` ended. */
67
+ const endReasons = new Map();
68
+ const acknowledgedTokens = [];
69
+ const consumedTokens = [];
70
+ const managementOpenedFor = [];
71
+ // The same listener sets as the real adapter, so a throwing observer behaves
72
+ // identically here and on a device (PAY-17).
73
+ const connectionListeners = createListenerSet();
74
+ const purchaseListeners = createListenerSet();
75
+ let connectCalls = 0;
76
+ let launchCalls = 0;
77
+ let queryOwnedCalls = 0;
78
+ let disconnectCalls = 0;
79
+ const notifyConnection = (next, reason) => {
80
+ connected = next;
81
+ connectionListeners.notify(next, reason);
82
+ };
83
+ return {
84
+ // --- ProviderPort ------------------------------------------------------
85
+ async connect() {
86
+ connectCalls += 1;
87
+ if (connectOutcome.ok) {
88
+ notifyConnection(true);
89
+ }
90
+ return connectOutcome;
91
+ },
92
+ async disconnect() {
93
+ disconnectCalls += 1;
94
+ if (connected) {
95
+ notifyConnection(false, 'disconnect');
96
+ }
97
+ },
98
+ observeConnection(listener) {
99
+ return connectionListeners.add(listener);
100
+ },
101
+ async queryProducts(storeProductIds, productType) {
102
+ return products.filter(p => storeProductIds.includes(p.storeProductId) && p.productType === productType);
103
+ },
104
+ async queryOwned() {
105
+ queryOwnedCalls += 1;
106
+ // Pending purchases are returned flagged, never filtered out: the engine
107
+ // must see them to raise the pending signal while never granting.
108
+ return [...owned];
109
+ },
110
+ async launchPurchase(request) {
111
+ launchCalls += 1;
112
+ const script = scripted;
113
+ scripted = undefined;
114
+ if (!script) {
115
+ return {
116
+ ok: false,
117
+ reason: 'store_error',
118
+ detail: 'no script set'
119
+ };
120
+ }
121
+ if (script.kind === 'failure') {
122
+ return {
123
+ ok: false,
124
+ reason: script.reason
125
+ };
126
+ }
127
+ const purchase = makePurchase({
128
+ storeProductId: request.storeProductId,
129
+ state: script.kind === 'pending' ? 'pending' : 'purchased',
130
+ ...script.overrides
131
+ });
132
+ owned = [...owned.filter(p => p.transactionId !== purchase.transactionId), purchase];
133
+ if (androidBinding) {
134
+ // The binding's update listener fires for every observer, the session-long
135
+ // one included, before the launch settles.
136
+ purchaseListeners.notify(purchase);
137
+ }
138
+ return {
139
+ ok: true,
140
+ purchase
141
+ };
142
+ },
143
+ observePurchases(listener) {
144
+ return purchaseListeners.add(listener);
145
+ },
146
+ async acknowledge(token) {
147
+ if (finalizeFails) {
148
+ throw new Error('fake acknowledge failure');
149
+ }
150
+ // Safe to call for an already-acknowledged transaction (FR-044).
151
+ if (!acknowledgedTokens.includes(token)) {
152
+ acknowledgedTokens.push(token);
153
+ }
154
+ owned = owned.map(p => p.token === token ? {
155
+ ...p,
156
+ isAcknowledged: true
157
+ } : p);
158
+ },
159
+ async consume(token) {
160
+ if (finalizeFails) {
161
+ throw new Error('fake consume failure');
162
+ }
163
+ if (!consumedTokens.includes(token)) {
164
+ consumedTokens.push(token);
165
+ }
166
+ // A consumed purchase stops being owned, which is what lets the same
167
+ // product be bought again (FR-043).
168
+ owned = owned.filter(p => p.token !== token);
169
+ },
170
+ async openSubscriptionManagement(storeProductId) {
171
+ managementOpenedFor.push(storeProductId);
172
+ },
173
+ async confirmPriceChange() {
174
+ return {
175
+ ok: true,
176
+ confirmed: true
177
+ };
178
+ },
179
+ capabilities: () => capabilities,
180
+ pendingEndReason: transactionId => endReasons.get(transactionId),
181
+ // --- Scripting ---------------------------------------------------------
182
+ scriptPurchaseSuccess(overrides) {
183
+ scripted = {
184
+ kind: 'success',
185
+ overrides
186
+ };
187
+ },
188
+ scriptPurchaseFailure(reason) {
189
+ scripted = {
190
+ kind: 'failure',
191
+ reason
192
+ };
193
+ },
194
+ scriptPurchasePending(overrides) {
195
+ scripted = {
196
+ kind: 'pending',
197
+ overrides
198
+ };
199
+ },
200
+ // --- Store state -------------------------------------------------------
201
+ setOwned(purchases) {
202
+ owned = [...purchases];
203
+ },
204
+ pushPurchaseUpdate(purchase) {
205
+ owned = [...owned.filter(p => p.transactionId !== purchase.transactionId), purchase];
206
+ purchaseListeners.notify(purchase);
207
+ },
208
+ revoke(transactionId) {
209
+ owned = owned.filter(p => p.transactionId !== transactionId);
210
+ },
211
+ settlePending(transactionId) {
212
+ owned = owned.map(p => p.transactionId === transactionId ? {
213
+ ...p,
214
+ state: 'purchased'
215
+ } : p);
216
+ },
217
+ cancelPending(transactionId) {
218
+ owned = owned.filter(p => p.transactionId !== transactionId);
219
+ endReasons.set(transactionId, 'cancelled');
220
+ },
221
+ expirePending(transactionId) {
222
+ owned = owned.filter(p => p.transactionId !== transactionId);
223
+ endReasons.set(transactionId, 'expired');
224
+ },
225
+ setProducts(next) {
226
+ products = [...next];
227
+ },
228
+ // --- Connection --------------------------------------------------------
229
+ setConnectOutcome(outcome) {
230
+ connectOutcome = outcome;
231
+ },
232
+ dropConnection(reason = 'service_disconnected') {
233
+ notifyConnection(false, reason);
234
+ },
235
+ restoreConnection() {
236
+ notifyConnection(true);
237
+ },
238
+ // --- Finalization ------------------------------------------------------
239
+ setFinalizeFailure(failing) {
240
+ finalizeFails = failing;
241
+ },
242
+ // --- Inspection --------------------------------------------------------
243
+ acknowledged: () => [...acknowledgedTokens],
244
+ consumed: () => [...consumedTokens],
245
+ connectCount: () => connectCalls,
246
+ launchCount: () => launchCalls,
247
+ queryOwnedCount: () => queryOwnedCalls,
248
+ disconnectCount: () => disconnectCalls,
249
+ subscriptionManagementOpenedFor: () => [...managementOpenedFor],
250
+ reset() {
251
+ connectOutcome = {
252
+ ok: true
253
+ };
254
+ capabilities = {
255
+ ...DEFAULT_CAPABILITIES,
256
+ ...options.capabilities
257
+ };
258
+ products = [];
259
+ owned = [];
260
+ scripted = undefined;
261
+ finalizeFails = false;
262
+ connected = false;
263
+ endReasons.clear();
264
+ acknowledgedTokens.length = 0;
265
+ consumedTokens.length = 0;
266
+ managementOpenedFor.length = 0;
267
+ connectionListeners.clear();
268
+ purchaseListeners.clear();
269
+ connectCalls = 0;
270
+ launchCalls = 0;
271
+ queryOwnedCalls = 0;
272
+ disconnectCalls = 0;
273
+ }
274
+ };
275
+ }
276
+ //# sourceMappingURL=fakeStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createListenerSet","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","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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,iBAAiB,QAAQ,wBAAwB;AAqF1D,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;AACA,OAAO,SAASC,YAAYA,CAACC,SAAo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BpE,mBAAmB,CAACoE,MAAM,GAAG,CAAC;MAC9BnE,mBAAmB,CAACkE,KAAK,CAAC,CAAC;MAC3BjE,iBAAiB,CAACiE,KAAK,CAAC,CAAC;MACzBhE,YAAY,GAAG,CAAC;MAChBC,WAAW,GAAG,CAAC;MACfC,eAAe,GAAG,CAAC;MACnBC,eAAe,GAAG,CAAC;IACpB;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * `@chipmobilesdk/rn-payment/testing` — test doubles.
5
+ *
6
+ * A separate entrypoint so the fake store cannot reach a production bundle
7
+ * (LIB-003). Nothing here is part of the package's public runtime contract.
8
+ */
9
+
10
+ export { createFakeStore, makePurchase } from "./fakeStore.js";
11
+ export { createMemorySnapshotStore } from "../persistence/mmkv-store.js";
12
+ export { CONFORMANCE_STORE, providerPortChecks, runProviderPortConformance } from "./conformance.js";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFakeStore","makePurchase","createMemorySnapshotStore","CONFORMANCE_STORE","providerPortChecks","runProviderPortConformance"],"sourceRoot":"../../../src","sources":["testing/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,EAAEC,YAAY,QAAQ,gBAAa;AAE3D,SAASC,yBAAyB,QAAQ,8BAA2B;AAErE,SAASC,iBAAiB,EAAEC,kBAAkB,EAAEC,0BAA0B,QAAQ,kBAAe","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Platform selection for the store adapter.
3
+ *
4
+ * This exists so the public surface never names a store. An app writes
5
+ * `createStoreProvider()`, not `createIapAdapter()` — the same call will pick the
6
+ * StoreKit adapter once iOS exists, and no consumer line changes (FR-002, FR-004,
7
+ * FR-007).
8
+ *
9
+ * On a platform with no adapter the result is a stub that reports
10
+ * `platform_unsupported` rather than throwing. That is what lets a host app start
11
+ * and run normally where selling is impossible, losing only the ability to sell
12
+ * (FR-021, FR-023).
13
+ */
14
+ import type { ProductType } from '../config/types';
15
+ import type { ProviderPort } from './port';
16
+ /**
17
+ * The no-adapter stub.
18
+ *
19
+ * Every operation fails safely and predictably. Notably `queryOwned` returns an
20
+ * empty list rather than throwing: the engine then computes `not_entitled` after a
21
+ * successful-but-empty sync, which is honest — on a platform with no store, the
22
+ * user genuinely holds nothing this package can verify.
23
+ */
24
+ declare function createUnsupportedProvider(): ProviderPort;
25
+ export interface StoreProviderOptions {
26
+ /**
27
+ * Force the unsupported stub regardless of platform.
28
+ *
29
+ * Useful for an app that wants to ship one build with selling switched off at
30
+ * the provider level rather than through the `enabled` flag.
31
+ */
32
+ forceUnsupported?: boolean;
33
+ }
34
+ /**
35
+ * The platform's store adapter.
36
+ *
37
+ * iOS deliberately returns the stub today rather than throwing: the contract is
38
+ * prepared for StoreKit, the implementation is not, and an app running on iOS
39
+ * should degrade to "cannot sell here" instead of crashing.
40
+ */
41
+ export declare function createStoreProvider(options?: StoreProviderOptions): ProviderPort;
42
+ /** Exported for a test or a screen that needs the stub explicitly. */
43
+ export { createUnsupportedProvider };
44
+ export type { ProductType };
45
+ //# sourceMappingURL=createStoreProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createStoreProvider.d.ts","sourceRoot":"","sources":["../../../../src/adapter/createStoreProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,iBAAiB,CAAC;AAEhE,OAAO,KAAK,EAGX,YAAY,EAKZ,MAAM,QAAQ,CAAC;AAahB;;;;;;;GAOG;AACH,iBAAS,yBAAyB,IAAI,YAAY,CAqCjD;AAED,MAAM,WAAW,oBAAoB;IACpC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,YAAY,CAQpF;AAED,sEAAsE;AACtE,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAErC,YAAY,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Android adapter over `react-native-iap` (Play Billing).
3
+ *
4
+ * **The only file in this package that touches the billing library.** Everything
5
+ * above it talks to `ProviderPort`, which is what keeps the binding replaceable
6
+ * and lets an iOS adapter be added without changing a consumer call (FR-002,
7
+ * FR-007). ESLint enforces that boundary.
8
+ *
9
+ * ## Verified against react-native-iap 16.7.3
10
+ *
11
+ * 0.3.0 was written before the binding was installed, from its documentation, and
12
+ * no purchase could complete on a device. Checked against the installed 16.7.3
13
+ * source for 0.3.1, two facts shape the purchase path:
14
+ *
15
+ * - The request is keyed by store: `google` / `apple`. 0.3.0 sent `android`, which
16
+ * the binding rejects (`empty-sku-list`) before Play opens. The request type is
17
+ * now the binding's own `RequestPurchaseProps`, so a renamed key fails to
18
+ * typecheck here instead of failing on a user's device.
19
+ * - On Android `requestPurchase` resolves with an **empty list** once the flow
20
+ * ends, whatever happened. The outcome (bought, pending, cancelled, failed)
21
+ * arrives only through `purchaseUpdatedListener` / `purchaseErrorListener`, so
22
+ * `launchPurchase` waits for those events.
23
+ *
24
+ * The module is still required lazily, and `IapModule` still names exactly the
25
+ * surface used. `__tests__/iap-adapter.test.ts` drives this file through a fake
26
+ * binding that behaves as 16.7.3 does; the rest of the suite uses the fake store.
27
+ *
28
+ * ## Known upstream defect this guards against
29
+ *
30
+ * openiap#408: the Android bridge did not clear its internal `isInitialized` flag
31
+ * on disconnect, so `connected` stayed true, later calls failed with
32
+ * `E_NOT_PREPARED`, and `reconnect()` reported success without rebuilding
33
+ * anything. This adapter therefore (a) tracks connection state itself rather than
34
+ * trusting the binding's flag, and (b) always performs a full
35
+ * `endConnection` + `initConnection` cycle instead of calling any reconnect
36
+ * shortcut.
37
+ */
38
+ import type { RequestPurchaseProps } from 'react-native-iap';
39
+ import { type RawProduct, type RawPurchase, type RawPurchaseError } from './iapShapes';
40
+ import type { ProviderPort, ProviderPurchaseRequest } from './port';
41
+ export { toProviderPurchaseState } from './iapShapes';
42
+ /**
43
+ * Exactly what this adapter needs from the binding.
44
+ *
45
+ * Declared narrowly on purpose: it documents the coupling, and it means a binding
46
+ * upgrade that changes one of these shapes fails to typecheck here instead of
47
+ * failing silently at runtime on a user's device.
48
+ */
49
+ interface IapModule {
50
+ initConnection(): Promise<boolean>;
51
+ endConnection(): Promise<void>;
52
+ fetchProducts(params: {
53
+ skus: string[];
54
+ type: 'in-app' | 'subs';
55
+ }): Promise<RawProduct[]>;
56
+ getAvailablePurchases(): Promise<RawPurchase[]>;
57
+ /** Typed by the binding itself, so a renamed request key fails to compile. */
58
+ requestPurchase(params: RequestPurchaseProps): Promise<unknown>;
59
+ finishTransaction(params: {
60
+ purchase: unknown;
61
+ isConsumable?: boolean;
62
+ }): Promise<unknown>;
63
+ purchaseUpdatedListener(listener: (purchase: RawPurchase) => void): {
64
+ remove(): void;
65
+ };
66
+ purchaseErrorListener(listener: (error: RawPurchaseError) => void): {
67
+ remove(): void;
68
+ };
69
+ deepLinkToSubscriptions?(params: {
70
+ skuAndroid?: string;
71
+ }): Promise<void>;
72
+ }
73
+ /** The request in the binding's 16.7 shape: keyed `google`, not `android`. */
74
+ export declare function toRequestProps(request: ProviderPurchaseRequest): RequestPurchaseProps;
75
+ export interface IapAdapterOptions {
76
+ /** Injected in tests that need to drive the mapping without the native module. */
77
+ module?: IapModule;
78
+ }
79
+ export declare function createIapAdapter(options?: IapAdapterOptions): ProviderPort;
80
+ //# sourceMappingURL=iap-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iap-adapter.d.ts","sourceRoot":"","sources":["../../../../src/adapter/iap-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAsC,MAAM,kBAAkB,CAAC;AAGjG,OAAO,EAIN,KAAK,UAAU,EACf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AAiB;IACjC,kFAAkF;IAClF,MAAM,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,YAAY,CAsO9E"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * The binding's shapes, and their translation into the port's vocabulary
3
+ * (PAY-12).
4
+ *
5
+ * The binding speaks Google Play: prices as micros in strings, offer tokens,
6
+ * numeric purchase states, store error codes. The port speaks this package's
7
+ * own. Keeping the translation here, with no I/O, no listeners and no module
8
+ * loading, is what makes it checkable against recorded payloads — and leaves
9
+ * the adapter next door about the calls it actually makes.
10
+ *
11
+ * The raw types are declared narrowly on purpose: they document the coupling,
12
+ * and a binding upgrade that changes one of these shapes fails to typecheck
13
+ * here rather than failing silently on a user's device.
14
+ */
15
+ import type { ProductType } from '../config/types';
16
+ import type { ProviderFailureReason, ProviderProduct, ProviderPurchase } from './port';
17
+ export interface RawProduct {
18
+ id?: string;
19
+ productId?: string;
20
+ title?: string;
21
+ name?: string;
22
+ description?: string;
23
+ displayPrice?: string;
24
+ localizedPrice?: string;
25
+ currency?: string;
26
+ currencyCode?: string;
27
+ price?: string | number;
28
+ oneTimePurchaseOfferDetails?: {
29
+ formattedPrice?: string;
30
+ priceAmountMicros?: string | number;
31
+ priceCurrencyCode?: string;
32
+ };
33
+ subscriptionOfferDetails?: RawSubscriptionOffer[];
34
+ }
35
+ export interface RawSubscriptionOffer {
36
+ offerToken?: string;
37
+ offerId?: string;
38
+ basePlanId?: string;
39
+ pricingPhases?: {
40
+ pricingPhaseList?: Array<{
41
+ formattedPrice?: string;
42
+ priceAmountMicros?: string | number;
43
+ priceCurrencyCode?: string;
44
+ billingPeriod?: string;
45
+ recurrenceMode?: number;
46
+ billingCycleCount?: number;
47
+ }>;
48
+ };
49
+ }
50
+ export interface RawPurchase {
51
+ id?: string;
52
+ transactionId?: string;
53
+ productId?: string;
54
+ ids?: string[];
55
+ purchaseToken?: string;
56
+ purchaseStateAndroid?: number | null;
57
+ /** A string in the 16.x binding: `'pending' | 'purchased' | 'unknown'`. */
58
+ purchaseState?: number | string;
59
+ transactionDate?: number;
60
+ isAcknowledgedAndroid?: boolean;
61
+ isAcknowledged?: boolean;
62
+ autoRenewingAndroid?: boolean;
63
+ isAutoRenewing?: boolean;
64
+ expirationDateAndroid?: number;
65
+ transactionReceipt?: string;
66
+ dataAndroid?: string;
67
+ }
68
+ /** What `purchaseErrorListener` delivers. */
69
+ export interface RawPurchaseError {
70
+ code?: string;
71
+ message?: string;
72
+ productId?: string | null;
73
+ }
74
+ export declare function toMicros(value: string | number | undefined): number;
75
+ export declare function normalizeProduct(raw: RawProduct, productType: ProductType): ProviderProduct;
76
+ export declare function normalizeOffer(offer: RawSubscriptionOffer, fallbackCurrency: string): ProviderProduct['offers'][number];
77
+ /**
78
+ * Reads the purchase state from whichever field the binding filled.
79
+ *
80
+ * Pending is preserved, never flattened to purchased: that distinction is what
81
+ * stops an entitlement being granted for money that has not arrived (FR-037).
82
+ * And an unrecognized or missing state is `unspecified`, never `purchased`.
83
+ *
84
+ * 0.1.0 read only Play's numeric state and treated anything else as purchased.
85
+ * The 16.x binding hands JavaScript the *string* state and does not carry the
86
+ * numeric one across, so on a device every pending purchase arrived as a string,
87
+ * fell through to the default, and was granted. Unit tests could not see it: they
88
+ * drive the fake store, which never passes through here.
89
+ */
90
+ export declare function toProviderPurchaseState(raw: Pick<RawPurchase, 'purchaseStateAndroid' | 'purchaseState'>): ProviderPurchase['state'];
91
+ export declare function normalizePurchase(raw: RawPurchase): ProviderPurchase;
92
+ /** Maps a binding error code onto the port's vocabulary, so no store code escapes. */
93
+ export declare function mapErrorCode(code: string | undefined): ProviderFailureReason;
94
+ //# sourceMappingURL=iapShapes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iapShapes.d.ts","sourceRoot":"","sources":["../../../../src/adapter/iapShapes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE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