@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,184 @@
1
+ /**
2
+ * The provider port — **private**, never exported from `src/index.ts`.
3
+ *
4
+ * This is the boundary between the platform-neutral engine and a store-specific
5
+ * adapter. It exists to make three things true:
6
+ *
7
+ * 1. No store type reaches the public surface, because only the adapter ever
8
+ * sees one (FR-002).
9
+ * 2. An iOS adapter can be added by implementing this interface, changing no
10
+ * consumer call (FR-007).
11
+ * 3. The fake store is a drop-in replacement, so every outcome and ordering is
12
+ * testable with no device, network, or store account (NFR-007).
13
+ *
14
+ * `Provider*` types are the port's **own** normalized shapes, not the binding's.
15
+ * The adapter translates; nothing above it sees a `react-native-iap` value.
16
+ */
17
+ import type { ProductType, Unsubscribe } from '../config/types';
18
+ /** A store's own product identifier. Confined to configuration and this layer. */
19
+ export type StoreProductId = string;
20
+ /** Opaque handle the store uses to identify a transaction for finalization. */
21
+ export type ProviderToken = string;
22
+ export type ProviderPurchaseState = 'purchased' | 'pending' | 'unspecified';
23
+ export interface ProviderOffer {
24
+ offerKey: string;
25
+ billingPeriod: string;
26
+ formattedPrice: string;
27
+ priceAmountMicros: number;
28
+ currencyCode: string;
29
+ trialPeriod?: string;
30
+ introductoryPrice?: {
31
+ formattedPrice: string;
32
+ period: string;
33
+ cycles: number;
34
+ };
35
+ /** As the **store** determined it. Never computed locally (FR-026). */
36
+ isEligible: boolean;
37
+ }
38
+ export interface ProviderProduct {
39
+ storeProductId: StoreProductId;
40
+ productType: ProductType;
41
+ title: string;
42
+ description: string;
43
+ formattedPrice: string;
44
+ currencyCode: string;
45
+ priceAmountMicros: number;
46
+ offers: ProviderOffer[];
47
+ }
48
+ export interface ProviderPurchase {
49
+ storeProductId: StoreProductId;
50
+ transactionId: string;
51
+ token: ProviderToken;
52
+ state: ProviderPurchaseState;
53
+ purchasedAt: number;
54
+ isAcknowledged: boolean;
55
+ /** Subscription-only, and only where the platform supplies it. */
56
+ expiresAt?: number;
57
+ willAutoRenew?: boolean;
58
+ /**
59
+ * Opaque material for the app's backend. Passed to the validation hook and
60
+ * **never** logged or put in an event (FR-074).
61
+ */
62
+ verificationPayload?: string;
63
+ }
64
+ export type ProviderFailureReason = 'user_cancelled' | 'already_owned' | 'ineligible' | 'unknown_product' | 'product_unavailable_in_region' | 'not_ready' | 'network_error' | 'timeout' | 'store_error';
65
+ export type ProviderConnectOutcome = {
66
+ ok: true;
67
+ } | {
68
+ ok: false;
69
+ reason: 'no_billing_service' | 'billing_service_outdated' | 'platform_unsupported' | 'store_error';
70
+ retryable: boolean;
71
+ };
72
+ export type ProviderPurchaseOutcome = {
73
+ ok: true;
74
+ purchase: ProviderPurchase;
75
+ } | {
76
+ ok: false;
77
+ reason: ProviderFailureReason;
78
+ detail?: string;
79
+ };
80
+ export type ProviderPriceChangeOutcome = {
81
+ ok: true;
82
+ confirmed: boolean;
83
+ } | {
84
+ ok: false;
85
+ reason: ProviderFailureReason;
86
+ };
87
+ export interface ProviderPurchaseRequest {
88
+ storeProductId: StoreProductId;
89
+ productType: ProductType;
90
+ offerKey?: string;
91
+ /** App-supplied, passed straight through. Never generated or stored (FR-034). */
92
+ obfuscatedAccountId?: string;
93
+ /**
94
+ * Plan change: the token of the active subscription being replaced. The store
95
+ * migrates *that* purchase rather than creating a second one (FR-065).
96
+ */
97
+ replacePurchaseToken?: ProviderToken;
98
+ /** Plan change: the store product id of the subscription being replaced. */
99
+ replaceStoreProductId?: StoreProductId;
100
+ prorationMode?: string;
101
+ }
102
+ /**
103
+ * What the platform can actually do.
104
+ *
105
+ * This is how honest degradation is enforced rather than left to good intentions.
106
+ * `reportsGraceAndHoldDistinctly` is `false` on Android, because client-side Play
107
+ * Billing genuinely cannot separate the two: a grace-period subscription is still
108
+ * returned as active, and one in account hold stops being returned at all, making
109
+ * it indistinguishable from expired, cancelled, or refunded.
110
+ *
111
+ * The entitlement layer reads this flag and reports `indeterminate` instead of
112
+ * fabricating a distinction from `willAutoRenew` — which cannot separate grace
113
+ * from cancelled-but-valid either. Claiming otherwise would breach FR-058.
114
+ */
115
+ export interface ProviderCapabilities {
116
+ supportsSubscriptions: boolean;
117
+ supportsPlanChange: boolean;
118
+ supportsPriceChangeConfirmation: boolean;
119
+ reportsGraceAndHoldDistinctly: boolean;
120
+ /** Externally-initiated purchases: false on Android, true for a future iOS adapter. */
121
+ supportsExternalTransactions: boolean;
122
+ /**
123
+ * Whether this adapter can move real money.
124
+ *
125
+ * `true` for the store adapter, `false` for the fake store. This is what lets
126
+ * FR-014's block be precise: the engine refuses a purchase when the
127
+ * environment may not create a production transaction **and** the provider is
128
+ * one that actually would. Without it the guard would either block the test
129
+ * suite — which must be able to buy things — or wave real purchases through in
130
+ * a development build.
131
+ */
132
+ createsRealTransactions: boolean;
133
+ /**
134
+ * Whether `launchPurchase` settles only once the user has left the store's
135
+ * purchase surface.
136
+ *
137
+ * `true` for the Play adapter: the binding gives no "surface opened" signal and
138
+ * reports the outcome only when the flow ends, so the time the user spends in
139
+ * Play is inside the call. The engine then does not apply its launch timeout,
140
+ * which would otherwise cancel a user still choosing a payment method (FR-035).
141
+ * The binding always ends the flow with a result or an error, so the call
142
+ * cannot hang. `false` for the fake store, whose launch returns at once.
143
+ */
144
+ purchaseOutcomeIncludesStoreTime: boolean;
145
+ }
146
+ export interface ProviderPort {
147
+ connect(): Promise<ProviderConnectOutcome>;
148
+ disconnect(): Promise<void>;
149
+ /**
150
+ * Reports a **real** disconnect.
151
+ *
152
+ * The engine must never infer connectivity from an unrelated call failing.
153
+ * The upstream binding historically left its `connected` flag true after a
154
+ * disconnect and had a `reconnect()` that could report success without
155
+ * rebuilding anything (openiap#408), so detection belongs here, behind a
156
+ * contract test.
157
+ */
158
+ observeConnection(listener: (connected: boolean, reason?: string) => void): Unsubscribe;
159
+ queryProducts(storeProductIds: StoreProductId[], productType: ProductType): Promise<ProviderProduct[]>;
160
+ /** Owned and pending purchases. Pending ones are **flagged, never filtered** (FR-037). */
161
+ queryOwned(): Promise<ProviderPurchase[]>;
162
+ launchPurchase(request: ProviderPurchaseRequest): Promise<ProviderPurchaseOutcome>;
163
+ /** Store-initiated updates, including a pending purchase settling later (FR-039). */
164
+ observePurchases(listener: (purchase: ProviderPurchase) => void): Unsubscribe;
165
+ /**
166
+ * Why a pending purchase the store has stopped reporting ended, if the store
167
+ * says (FR-102). Optional, and synchronous because it is asked about a
168
+ * transaction the store already dropped, not fetched.
169
+ *
170
+ * Play gives no reason — a declined or abandoned pending purchase simply
171
+ * vanishes from `queryOwned` — so the Android adapter leaves this out and the
172
+ * engine reports `cancelled`. It is never inferred from age: guessing the
173
+ * store's pending window would be inventing a fact.
174
+ */
175
+ pendingEndReason?(transactionId: string): 'cancelled' | 'expired' | undefined;
176
+ /** Must be safe to call for an already-finalized transaction (FR-044). */
177
+ acknowledge(token: ProviderToken): Promise<void>;
178
+ /** Must be safe to call twice; the item is granted once (FR-044). */
179
+ consume(token: ProviderToken): Promise<void>;
180
+ openSubscriptionManagement(storeProductId?: StoreProductId): Promise<void>;
181
+ confirmPriceChange(storeProductId: StoreProductId): Promise<ProviderPriceChangeOutcome>;
182
+ capabilities(): ProviderCapabilities;
183
+ }
184
+ //# sourceMappingURL=port.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../../../../src/adapter/port.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,WAAW,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B,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAExF,YAAY,IAAI,oBAAoB,CAAC;CACrC"}
@@ -0,0 +1,326 @@
1
+ /**
2
+ * Public configuration and catalog types.
3
+ *
4
+ * Nothing here names Google Play Billing, `react-native-iap`, or any store
5
+ * concept (FR-002). Apps speak in **product keys** and **entitlement keys** they
6
+ * chose themselves; store product identifiers appear only inside catalog
7
+ * configuration, never in app logic (FR-003).
8
+ */
9
+ /** An app-chosen logical entitlement, e.g. `no_ads`. What business logic asks about. */
10
+ export type EntitlementKey = string;
11
+ /** An app-chosen logical product, e.g. `premium_yearly`. Never a store identifier. */
12
+ export type ProductKey = string;
13
+ /**
14
+ * How a product behaves once bought.
15
+ *
16
+ * `one_time_permanent` — bought once, kept forever.
17
+ * `one_time_consumable` — bought, used up by the app, buyable again (FR-043).
18
+ * `subscription` — recurring, with its own lifecycle (FR-048).
19
+ */
20
+ export type ProductType = 'one_time_permanent' | 'one_time_consumable' | 'subscription';
21
+ /** Store identifiers per platform. iOS is optional and additive (FR-007). */
22
+ export interface StoreProductIds {
23
+ android?: string;
24
+ ios?: string;
25
+ }
26
+ /** One product the app sells, and what it unlocks. */
27
+ export interface CatalogEntry {
28
+ productKey: ProductKey;
29
+ productType: ProductType;
30
+ storeProductIds: StoreProductIds;
31
+ /** Entitlement keys this product confers. Many-to-many is supported (FR-010). */
32
+ grants: EntitlementKey[];
33
+ }
34
+ /** Separately configurable, and the basis of the production-transaction guard. */
35
+ export type Environment = 'development' | 'test' | 'production';
36
+ /**
37
+ * Entitlement policy for a subscription whose renewal payment failed.
38
+ *
39
+ * Kept configurable because it is a business decision, not a technical constant
40
+ * (FR-049). See `entitlements/policy.ts` for the defaults and why.
41
+ */
42
+ export type LapsePolicy = 'grant' | 'withhold';
43
+ /** What to do when a configured validation hook cannot be reached (FR-072). */
44
+ export type ValidationUnavailablePolicy = 'grant_and_queue' | 'withhold';
45
+ /** Returned by every subscribe call. Idempotent and safe to call twice (FR-006). */
46
+ export type Unsubscribe = () => void;
47
+ export interface TimeoutConfig {
48
+ connectMs?: number;
49
+ productQueryMs?: number;
50
+ syncMs?: number;
51
+ /** Covers opening the store surface only. Time the user spends in it is not counted (FR-035). */
52
+ purchaseLaunchMs?: number;
53
+ /** Bounds each acknowledge or consume call; a timed-out attempt is retried. */
54
+ finalizeAttemptMs?: number;
55
+ /**
56
+ * Bounds the app's `validateTransaction` hook. A hook that does not answer in
57
+ * time is treated as unavailable, exactly like one that throws (FR-072b).
58
+ * Added in 0.3.2.
59
+ */
60
+ validateMs?: number;
61
+ }
62
+ export interface RetryConfig {
63
+ reconnect?: BackoffConfig;
64
+ finalize?: BackoffConfig;
65
+ }
66
+ export interface BackoffConfig {
67
+ initialDelayMs?: number;
68
+ maxDelayMs?: number;
69
+ factor?: number;
70
+ /** Attempts per session. Finalize is resumed next session rather than abandoned (FR-045). */
71
+ maxAttempts?: number;
72
+ jitter?: boolean;
73
+ }
74
+ /** What the app's backend is asked to decide about (FR-069). */
75
+ export interface ValidationCandidate {
76
+ productKey: ProductKey;
77
+ productType: ProductType;
78
+ /** Opaque verification material for the backend. Never logged (FR-074). */
79
+ verificationPayload: string;
80
+ /** Ties this decision to one purchase cycle in the event stream (FR-076). */
81
+ correlationId: string;
82
+ /**
83
+ * The store's identifier for this transaction (Play's order id). Not a secret,
84
+ * and the only handle a backend has on re-validation, where
85
+ * `verificationPayload` is empty because it is never persisted. Added in 0.3.2.
86
+ */
87
+ transactionId: string;
88
+ /** Which store issued the transaction, so a backend picks the right API. Added in 0.3.2. */
89
+ platform: 'android' | 'ios';
90
+ }
91
+ export interface ValidationDecision {
92
+ approved: boolean;
93
+ /** Optional app-supplied reason, surfaced as a distinguishable outcome (FR-071). */
94
+ reason?: string;
95
+ }
96
+ export type ValidationHook = (candidate: ValidationCandidate) => Promise<ValidationDecision>;
97
+ /** Diagnostics sink. Deliberately not tied to any analytics vendor (FR-080). */
98
+ export interface LoggerAdapter {
99
+ debug?(message: string, meta?: Record<string, unknown>): void;
100
+ warn?(message: string, meta?: Record<string, unknown>): void;
101
+ error?(message: string, meta?: Record<string, unknown>): void;
102
+ }
103
+ export interface PaymentConfig {
104
+ catalog: CatalogEntry[];
105
+ /** Entitlement keys the app intends to query. Used for orphan detection (FR-011). */
106
+ entitlements: EntitlementKey[];
107
+ environment: Environment;
108
+ /**
109
+ * Whether the running binary is a production build.
110
+ *
111
+ * Supplied by the app because only the app knows how it was built. Drives the
112
+ * fail-closed guard: a non-production build declaring `production` must not
113
+ * proceed (FR-015).
114
+ */
115
+ isProductionBuild: boolean;
116
+ /**
117
+ * Lets a non-production build complete purchases through the real store, so a
118
+ * Play license tester can buy on a debug build (PAY-16). Accepted only with
119
+ * `environment: 'test'`; any other environment rejects it at startup. License
120
+ * testers are not charged; any other account on the device would be, so keep
121
+ * it out of builds that reach real users.
122
+ */
123
+ allowStoreTestPurchases?: boolean;
124
+ /**
125
+ * Global sell switch. When false, purchases report `disabled` but entitlements
126
+ * already held stay readable — turning off selling is not the same as taking
127
+ * away what someone bought (FR-012).
128
+ */
129
+ enabled?: boolean;
130
+ gracePolicy?: LapsePolicy;
131
+ holdPolicy?: LapsePolicy;
132
+ staleAfterMs?: number;
133
+ productCacheTtlMs?: number;
134
+ foregroundSyncMinIntervalMs?: number;
135
+ timeouts?: TimeoutConfig;
136
+ retry?: RetryConfig;
137
+ /**
138
+ * Opaque cache-partition key (FR-057a).
139
+ *
140
+ * Not a user identifier: the package never interprets it, transmits it, or
141
+ * attaches it to a transaction. Changing it makes the previous snapshot
142
+ * unreadable, so a second app-account user cannot inherit the first one's
143
+ * entitlements even if the app forgets to call `clearLocalData`.
144
+ */
145
+ scopeToken?: string;
146
+ validateTransaction?: ValidationHook;
147
+ onValidationUnavailable?: ValidationUnavailablePolicy;
148
+ logger?: LoggerAdapter;
149
+ }
150
+ /** Opaque handle for a transaction. Exposes no raw store record (FR-051). */
151
+ export interface TransactionRef {
152
+ readonly transactionId: string;
153
+ readonly productKey: ProductKey;
154
+ }
155
+ export interface PurchaseOptions {
156
+ /**
157
+ * The app's obfuscated account identifier, passed straight through to the
158
+ * store for fraud prevention. Never generated, inferred, or persisted by the
159
+ * package (FR-034), and distinct from `scopeToken`.
160
+ */
161
+ obfuscatedAccountId?: string;
162
+ /** Which pricing option to buy, for a subscription with several offers. */
163
+ offerKey?: string;
164
+ }
165
+ /**
166
+ * Every way a purchase can end (FR-005).
167
+ *
168
+ * A discriminated union rather than a boolean plus an error, because the app has
169
+ * to tell these apart: `user_cancelled` is a normal outcome to stay quiet about,
170
+ * `pending` means wait, `already_owned` means re-sync, and `store_error` means
171
+ * show something. Collapsing them is how apps end up reporting a cancellation as
172
+ * a failure.
173
+ */
174
+ export type PurchaseResult = {
175
+ kind: 'success';
176
+ productKey: ProductKey;
177
+ transaction: TransactionRef;
178
+ }
179
+ /** Money has not arrived. No entitlement is granted (FR-037). */
180
+ | {
181
+ kind: 'pending';
182
+ productKey: ProductKey;
183
+ transaction: TransactionRef;
184
+ }
185
+ /** Normal, not an error. Must never be recorded as a technical failure (FR-032). */
186
+ | {
187
+ kind: 'user_cancelled';
188
+ productKey: ProductKey;
189
+ }
190
+ /** Triggers a re-sync: this is how a reinstall repairs itself (FR-033). */
191
+ | {
192
+ kind: 'already_owned';
193
+ productKey: ProductKey;
194
+ } | {
195
+ kind: 'ineligible';
196
+ productKey: ProductKey;
197
+ } | {
198
+ kind: 'unknown_product';
199
+ productKey: ProductKey;
200
+ } | {
201
+ kind: 'product_unavailable_in_region';
202
+ productKey: ProductKey;
203
+ }
204
+ /** Global sell switch is off (FR-012). */
205
+ | {
206
+ kind: 'disabled';
207
+ } | {
208
+ kind: 'not_ready';
209
+ status: PaymentStatusKind;
210
+ } | {
211
+ kind: 'unsupported';
212
+ }
213
+ /** A second purchase while one is open. Refused, never queued (FR-031). */
214
+ | {
215
+ kind: 'purchase_in_progress';
216
+ }
217
+ /** Refused because this build may not create a production transaction (FR-014). */
218
+ | {
219
+ kind: 'environment_blocked';
220
+ productKey: ProductKey;
221
+ environment: Environment;
222
+ }
223
+ /** The app's backend said no (FR-071). Distinguishable from a network failure. */
224
+ | {
225
+ kind: 'validation_rejected';
226
+ productKey: ProductKey;
227
+ reason?: string;
228
+ } | {
229
+ kind: 'timeout';
230
+ productKey: ProductKey;
231
+ } | {
232
+ kind: 'network_error';
233
+ productKey: ProductKey;
234
+ } | {
235
+ kind: 'store_error';
236
+ productKey: ProductKey;
237
+ code: string;
238
+ };
239
+ /**
240
+ * A purchase whose money has not arrived yet (FR-101), added in 0.2.0.
241
+ *
242
+ * One entry per product key, whatever number of pending transactions the store
243
+ * reports for it. Carries no transaction id, token, or store object (FR-051) —
244
+ * enough to render "payment pending" and to withhold Buy, nothing to act on.
245
+ */
246
+ export interface PendingPurchase {
247
+ readonly productKey: ProductKey;
248
+ /** When the store reports the purchase was made, in epoch milliseconds. Earliest if several. */
249
+ readonly since: number;
250
+ }
251
+ /**
252
+ * The pending set, with how far it can be trusted (FR-101, FR-103).
253
+ *
254
+ * Read `status` first. `unknown` follows the entitlement rule exactly: never
255
+ * synced, or synced longer ago than `staleAfterMs`. Under `unknown`, `purchases`
256
+ * still lists what the last good sync saw, but an empty list there does **not**
257
+ * mean "nothing is pending" — the same reason an `unknown` entitlement is not
258
+ * `not_entitled`.
259
+ */
260
+ export interface PendingPurchasesState {
261
+ readonly status: 'known' | 'unknown';
262
+ readonly purchases: readonly PendingPurchase[];
263
+ /** True once the snapshot is older than `staleAfterMs`; `status` is then `unknown`. */
264
+ readonly isStale: boolean;
265
+ }
266
+ /**
267
+ * How a pending purchase ended (FR-102).
268
+ *
269
+ * `settled` — the money arrived; an entitlement grant, if the product confers one,
270
+ * follows. `expired` — the store reported that the pending window ran out.
271
+ * `cancelled` — it ended without payment for any other reason, **including when
272
+ * the store gives none**: Play simply stops reporting a declined or abandoned
273
+ * pending purchase, so on Android every unpaid end is `cancelled`.
274
+ */
275
+ export type PendingResolution = 'settled' | 'cancelled' | 'expired';
276
+ /** Outcome of finalizing or consuming a transaction (FR-044). */
277
+ export type FinalizeResult = {
278
+ kind: 'finalized';
279
+ }
280
+ /** Already done. Idempotent by design, so this is a success, not an error. */
281
+ | {
282
+ kind: 'already_finalized';
283
+ } | {
284
+ kind: 'unknown_transaction';
285
+ }
286
+ /** Queued for bounded retry; the condition stays observable (FR-045). */
287
+ | {
288
+ kind: 'retry_scheduled';
289
+ attempts: number;
290
+ } | {
291
+ kind: 'failed';
292
+ code: string;
293
+ };
294
+ /** A paid transaction not yet settled with the store, surfaced so it is not swallowed. */
295
+ export interface UnfinalizedSummary {
296
+ productKey: ProductKey;
297
+ transactionId: string;
298
+ attempts: number;
299
+ purchasedAt: number;
300
+ }
301
+ /** Observable package status (FR-019). */
302
+ export type PaymentStatusKind = 'not_started' | 'connecting' | 'ready' | 'disabled' | 'unavailable' | 'failed';
303
+ /** Why selling is impossible here, kept distinguishable so apps can tell users why (FR-021). */
304
+ export type UnavailableReason = 'no_billing_service' | 'billing_service_outdated' | 'platform_unsupported';
305
+ /**
306
+ * A purchase the package refused because it could have been a real charge
307
+ * outside production (FR-014).
308
+ *
309
+ * Exposed in status rather than only logged so an automated test can assert the
310
+ * block happened, which is the difference between a guarantee and a hope.
311
+ */
312
+ export interface BlockedOperation {
313
+ productKey: ProductKey;
314
+ environment: Environment;
315
+ at: number;
316
+ }
317
+ export interface PaymentStatus {
318
+ kind: PaymentStatusKind;
319
+ unavailableReason?: UnavailableReason;
320
+ /** Whether retrying initialization could plausibly help (FR-024). */
321
+ retryable?: boolean;
322
+ /** Reconnect attempts made in this session, so a retry storm is visible (FR-020). */
323
+ reconnectAttempts?: number;
324
+ blockedOperations: BlockedOperation[];
325
+ }
326
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/config/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,wFAAwF;AACxF,MAAM,MAAM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tC,qEAAqE;IACrE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qFAAqF;IACrF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;CACtC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Catalog validation (FR-011).
3
+ *
4
+ * Runs at `configure`, before any connection is opened, so a bad catalog fails
5
+ * at configuration time rather than at the moment a user taps Buy. Every failure
6
+ * **names the offending entry** — "invalid catalog" alone is useless in an app
7
+ * with thirty products.
8
+ *
9
+ * All problems are collected rather than thrown one at a time, so a developer
10
+ * fixes the catalog in one pass instead of rerunning to find the next fault.
11
+ */
12
+ import { type ResolvedRetry, type ResolvedTimeouts } from '../core/timers';
13
+ import type { CatalogEntry, EntitlementKey, LapsePolicy, PaymentConfig, ProductKey, ValidationUnavailablePolicy } from './types';
14
+ /** The platform whose store identifiers a catalog must supply. */
15
+ export type TargetPlatform = 'android' | 'ios';
16
+ /**
17
+ * A validated, indexed catalog plus every resolved policy value.
18
+ *
19
+ * Produced once so the hot paths never re-derive it, and so `getEntitlement` can
20
+ * stay a synchronous in-memory read (PERF-001).
21
+ */
22
+ export interface ResolvedConfig {
23
+ readonly entries: ReadonlyMap<ProductKey, CatalogEntry>;
24
+ /** productKey → entitlement keys it grants. */
25
+ readonly grants: ReadonlyMap<ProductKey, readonly EntitlementKey[]>;
26
+ /** entitlementKey → product keys that can grant it (FR-051, FR-052). */
27
+ readonly sources: ReadonlyMap<EntitlementKey, readonly ProductKey[]>;
28
+ /** storeProductId → productKey, for translating store callbacks back (FR-003). */
29
+ readonly byStoreId: ReadonlyMap<string, ProductKey>;
30
+ readonly entitlementKeys: readonly EntitlementKey[];
31
+ readonly platform: TargetPlatform;
32
+ readonly enabled: boolean;
33
+ readonly gracePolicy: LapsePolicy;
34
+ readonly holdPolicy: LapsePolicy;
35
+ readonly staleAfterMs: number;
36
+ readonly productCacheTtlMs: number;
37
+ readonly foregroundSyncMinIntervalMs: number;
38
+ readonly timeouts: ResolvedTimeouts;
39
+ readonly retry: ResolvedRetry;
40
+ readonly onValidationUnavailable: ValidationUnavailablePolicy;
41
+ }
42
+ export declare function validateConfig(config: PaymentConfig, platform?: TargetPlatform): ResolvedConfig;
43
+ /**
44
+ * The fail-closed environment guard (FR-015).
45
+ *
46
+ * Separate from catalog validation because it is not about the catalog's shape
47
+ * but about whether this binary is allowed to move real money at all. Checked
48
+ * before connecting, and it refuses rather than warns: a non-production build
49
+ * that declares `production` is one tap away from charging a real card, and
50
+ * continuing silently is exactly the failure this package exists to prevent.
51
+ */
52
+ export declare function assertEnvironmentSafe(config: PaymentConfig): void;
53
+ /**
54
+ * Whether this configuration may hand a purchase to a real store (FR-014).
55
+ *
56
+ * True in a production build configured for production, and in a `test`
57
+ * environment that opted in with `allowStoreTestPurchases` (PAY-16). False
58
+ * everywhere else. The engine records each refusal in observable status so a
59
+ * test can assert the block happened — the difference between a guarantee and a
60
+ * hope.
61
+ */
62
+ export declare function mayCreateRealTransaction(config: PaymentConfig): boolean;
63
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/config/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAMN,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACX,YAAY,EACZ,cAAc,EACd,WAAW,EACX,aAAa,EACb,UAAU,EAEV,2BAA2B,EAC3B,MAAM,SAAS,CAAC;AAQjB,kEAAkE;AAClE,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,KAAK,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACxD,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,UAAU,EAAE,SAAS,cAAc,EAAE,CAAC,CAAC;IACpE,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,cAAc,EAAE,SAAS,UAAU,EAAE,CAAC,CAAC;IACrE,kFAAkF;IAClF,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACpD,QAAQ,CAAC,eAAe,EAAE,SAAS,cAAc,EAAE,CAAC;IACpD,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,2BAA2B,EAAE,MAAM,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,uBAAuB,EAAE,2BAA2B,CAAC;CAC9D;AAED,wBAAgB,cAAc,CAC7B,MAAM,EAAE,aAAa,EACrB,QAAQ,GAAE,cAA0B,GAClC,cAAc,CAsHhB;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAsBjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAKvE"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Concurrency primitives.
3
+ *
4
+ * These are what make three of the specification's guarantees structurally true
5
+ * rather than hoped for: concurrent initialization opens exactly one connection
6
+ * (FR-018), concurrent syncs make exactly one store request (FR-063), and a
7
+ * second purchase while one is open is refused rather than queued (FR-031).
8
+ *
9
+ * The distinction between the two primitives matters. `singleFlight` **joins**
10
+ * concurrent callers onto one operation — correct for init and sync, where every
11
+ * caller wants the same answer. `exclusive` **refuses** the second caller —
12
+ * correct for purchase, where joining would silently give two callers one
13
+ * transaction, and queueing would open a store surface the user no longer
14
+ * expects.
15
+ */
16
+ export { createExclusive, createRateLimiter, createSingleFlight, withTimeout, type ExclusiveOutcome, } from '@chipmobilesdk/rn-core';
17
+ //# sourceMappingURL=mutex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutex.d.ts","sourceRoot":"","sources":["../../../../src/core/mutex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EACN,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,KAAK,gBAAgB,GACrB,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Bounded backoff.
3
+ *
4
+ * "Bounded" is the whole point (FR-020, FR-045): an unbounded reconnect loop
5
+ * against a billing service that is down drains battery and hammers a system
6
+ * service, and an unbounded finalize loop hides a real failure behind noise.
7
+ *
8
+ * Delay computation is pure and separated from waiting so tests can assert the
9
+ * schedule without burning real time.
10
+ */
11
+ import type { BackoffConfig } from '../config/types';
12
+ /**
13
+ * Delay before `attempt` (1-based), capped and optionally jittered.
14
+ *
15
+ * Jitter is full jitter over [0, capped]: several devices that lost the billing
16
+ * connection at the same moment should not retry in lockstep.
17
+ */
18
+ export declare function backoffDelayMs(attempt: number, config: Required<BackoffConfig>, random?: () => number): number;
19
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../../../src/core/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC7B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,EAC/B,MAAM,GAAE,MAAM,MAAoB,GAChC,MAAM,CAER"}