@pithy-sh/payments 0.1.1 → 0.1.3

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 (402) hide show
  1. package/dist/admin/coverage.d.ts +35 -0
  2. package/dist/admin/coverage.d.ts.map +1 -0
  3. package/dist/admin/coverage.js +56 -0
  4. package/dist/admin/read.d.ts +222 -0
  5. package/dist/admin/read.d.ts.map +1 -0
  6. package/dist/admin/read.js +159 -0
  7. package/dist/audit/actions.d.ts +211 -0
  8. package/dist/audit/actions.d.ts.map +1 -0
  9. package/dist/audit/actions.js +211 -0
  10. package/dist/capability.d.ts +72 -0
  11. package/dist/capability.d.ts.map +1 -0
  12. package/dist/capability.js +228 -0
  13. package/dist/client/api.d.ts +435 -0
  14. package/dist/client/api.d.ts.map +1 -0
  15. package/dist/client/api.js +415 -0
  16. package/dist/client/checkout.d.ts +144 -0
  17. package/dist/client/checkout.d.ts.map +1 -0
  18. package/dist/client/checkout.js +173 -0
  19. package/dist/client/fixtures/price-preview-de.js +89 -0
  20. package/dist/client/fixtures/price-preview-gb.js +89 -0
  21. package/dist/client/fixtures/price-preview-jp-yen.js +89 -0
  22. package/dist/client/fixtures/price-preview-us-country-only.js +89 -0
  23. package/dist/client/fixtures/price-preview-us-new-york.js +89 -0
  24. package/dist/client/fixtures/pricePreview.d.ts +54 -0
  25. package/dist/client/fixtures/pricePreview.d.ts.map +1 -0
  26. package/dist/client/fixtures/pricePreview.js +61 -0
  27. package/dist/client/hooks.d.ts +235 -0
  28. package/dist/client/hooks.d.ts.map +1 -0
  29. package/dist/client/hooks.js +428 -0
  30. package/dist/client/paddle.d.ts +433 -0
  31. package/dist/client/paddle.d.ts.map +1 -0
  32. package/dist/client/paddle.js +391 -0
  33. package/dist/client/paddleCache.d.ts +123 -0
  34. package/dist/client/paddleCache.d.ts.map +1 -0
  35. package/dist/client/paddleCache.js +159 -0
  36. package/dist/client/paddlePrices.d.ts +94 -0
  37. package/dist/client/paddlePrices.d.ts.map +1 -0
  38. package/dist/client/paddlePrices.js +55 -0
  39. package/dist/client/paddlePricesTag.d.ts +127 -0
  40. package/dist/client/paddlePricesTag.d.ts.map +1 -0
  41. package/dist/client/paddlePricesTag.js +207 -0
  42. package/dist/client/projection.d.ts +128 -0
  43. package/dist/client/projection.d.ts.map +1 -0
  44. package/dist/client/projection.js +0 -0
  45. package/dist/client/test-utils/cacheStore.d.ts +18 -0
  46. package/dist/client/test-utils/cacheStore.d.ts.map +1 -0
  47. package/dist/client/test-utils/cacheStore.js +42 -0
  48. package/dist/client/wholeUnits.d.ts +18 -0
  49. package/dist/client/wholeUnits.d.ts.map +1 -0
  50. package/dist/client/wholeUnits.js +120 -0
  51. package/dist/config/config.d.ts +238 -0
  52. package/dist/config/config.d.ts.map +1 -0
  53. package/dist/config/config.js +249 -0
  54. package/dist/data/discount.d.ts +127 -0
  55. package/dist/data/discount.d.ts.map +1 -0
  56. package/dist/data/discount.js +91 -0
  57. package/dist/data/entitlement.d.ts +43 -0
  58. package/dist/data/entitlement.d.ts.map +1 -0
  59. package/dist/data/entitlement.js +43 -0
  60. package/dist/data/money.d.ts +15 -0
  61. package/dist/data/money.d.ts.map +1 -0
  62. package/dist/data/money.js +76 -0
  63. package/dist/data/pause.d.ts +133 -0
  64. package/dist/data/pause.d.ts.map +1 -0
  65. package/dist/data/pause.js +63 -0
  66. package/dist/data/providerAccount.d.ts +40 -0
  67. package/dist/data/providerAccount.d.ts.map +1 -0
  68. package/dist/data/providerAccount.js +34 -0
  69. package/dist/data/purchase.d.ts +107 -0
  70. package/dist/data/purchase.d.ts.map +1 -0
  71. package/dist/data/purchase.js +77 -0
  72. package/dist/data/rail.d.ts +74 -0
  73. package/dist/data/rail.d.ts.map +1 -0
  74. package/dist/data/rail.js +74 -0
  75. package/dist/data/reconcileRun.d.ts +120 -0
  76. package/dist/data/reconcileRun.d.ts.map +1 -0
  77. package/dist/data/reconcileRun.js +120 -0
  78. package/dist/data/renderMoney.d.ts +85 -0
  79. package/dist/data/renderMoney.d.ts.map +1 -0
  80. package/dist/data/renderMoney.js +146 -0
  81. package/dist/data/status.d.ts +58 -0
  82. package/dist/data/status.d.ts.map +1 -0
  83. package/dist/data/status.js +68 -0
  84. package/dist/data/subject.d.ts +111 -0
  85. package/dist/data/subject.d.ts.map +1 -0
  86. package/dist/data/subject.js +125 -0
  87. package/dist/data/subscription.d.ts +624 -0
  88. package/dist/data/subscription.d.ts.map +1 -0
  89. package/dist/data/subscription.js +497 -0
  90. package/dist/data/syncCursor.d.ts +33 -0
  91. package/dist/data/syncCursor.d.ts.map +1 -0
  92. package/dist/data/syncCursor.js +29 -0
  93. package/dist/data/tables.d.ts +37 -0
  94. package/dist/data/tables.d.ts.map +1 -0
  95. package/dist/data/tables.js +44 -0
  96. package/dist/data/webhookEvent.d.ts +134 -0
  97. package/dist/data/webhookEvent.d.ts.map +1 -0
  98. package/dist/data/webhookEvent.js +128 -0
  99. package/dist/entitlement/manual.d.ts +101 -0
  100. package/dist/entitlement/manual.d.ts.map +1 -0
  101. package/dist/entitlement/manual.js +84 -0
  102. package/dist/entitlement/resolver.d.ts +60 -0
  103. package/dist/entitlement/resolver.d.ts.map +1 -0
  104. package/dist/entitlement/resolver.js +101 -0
  105. package/dist/entitlement/subjectSeam.d.ts +102 -0
  106. package/dist/entitlement/subjectSeam.d.ts.map +1 -0
  107. package/dist/entitlement/subjectSeam.js +85 -0
  108. package/dist/error/errors.d.ts +247 -0
  109. package/dist/error/errors.d.ts.map +1 -0
  110. package/dist/error/errors.js +326 -0
  111. package/dist/grants/apply.d.ts +74 -0
  112. package/dist/grants/apply.d.ts.map +1 -0
  113. package/dist/grants/apply.js +148 -0
  114. package/dist/grants/clawback.d.ts +43 -0
  115. package/dist/grants/clawback.d.ts.map +1 -0
  116. package/dist/grants/clawback.js +71 -0
  117. package/dist/grants/ledgerSeam.d.ts +89 -0
  118. package/dist/grants/ledgerSeam.d.ts.map +1 -0
  119. package/dist/grants/ledgerSeam.js +66 -0
  120. package/dist/http/dispatch.d.ts +35 -0
  121. package/dist/http/dispatch.d.ts.map +1 -0
  122. package/dist/http/dispatch.js +40 -0
  123. package/dist/http/guards.d.ts +43 -0
  124. package/dist/http/guards.d.ts.map +1 -0
  125. package/dist/http/guards.js +52 -0
  126. package/dist/http/manifestConfig.d.ts +38 -0
  127. package/dist/http/manifestConfig.d.ts.map +1 -0
  128. package/dist/http/manifestConfig.js +49 -0
  129. package/dist/http/responses.d.ts +1455 -0
  130. package/dist/http/responses.d.ts.map +1 -0
  131. package/dist/http/responses.js +728 -0
  132. package/dist/http/routes.d.ts +315 -0
  133. package/dist/http/routes.d.ts.map +1 -0
  134. package/dist/http/routes.js +1966 -0
  135. package/dist/http/schemas.d.ts +404 -0
  136. package/dist/http/schemas.d.ts.map +1 -0
  137. package/dist/http/schemas.js +359 -0
  138. package/dist/http/scopes.d.ts +160 -0
  139. package/dist/http/scopes.d.ts.map +1 -0
  140. package/dist/http/scopes.js +240 -0
  141. package/dist/http/view.d.ts +96 -0
  142. package/dist/http/view.d.ts.map +1 -0
  143. package/dist/http/view.js +170 -0
  144. package/dist/http/webhookGuard.d.ts +109 -0
  145. package/dist/http/webhookGuard.d.ts.map +1 -0
  146. package/dist/http/webhookGuard.js +206 -0
  147. package/dist/index.d.ts +64 -0
  148. package/dist/index.d.ts.map +1 -0
  149. package/dist/index.js +43 -0
  150. package/dist/migrations/0001_purchases.d.ts +35 -0
  151. package/dist/migrations/0001_purchases.d.ts.map +1 -0
  152. package/dist/migrations/0001_purchases.js +80 -0
  153. package/dist/pricing/location.d.ts +138 -0
  154. package/dist/pricing/location.d.ts.map +1 -0
  155. package/dist/pricing/location.js +81 -0
  156. package/dist/pricing/visitor.d.ts +56 -0
  157. package/dist/pricing/visitor.d.ts.map +1 -0
  158. package/dist/pricing/visitor.js +35 -0
  159. package/dist/projection/event.d.ts +66 -0
  160. package/dist/projection/event.d.ts.map +1 -0
  161. package/dist/projection/event.js +45 -0
  162. package/dist/projection/orphans.d.ts +114 -0
  163. package/dist/projection/orphans.d.ts.map +1 -0
  164. package/dist/projection/orphans.js +162 -0
  165. package/dist/projection/owner.d.ts +121 -0
  166. package/dist/projection/owner.d.ts.map +1 -0
  167. package/dist/projection/owner.js +114 -0
  168. package/dist/projection/resolve.d.ts +30 -0
  169. package/dist/projection/resolve.d.ts.map +1 -0
  170. package/dist/projection/resolve.js +42 -0
  171. package/dist/projection/writer.d.ts +103 -0
  172. package/dist/projection/writer.d.ts.map +1 -0
  173. package/dist/projection/writer.js +280 -0
  174. package/dist/provision/resolvePaymentsConfig.d.ts +48 -0
  175. package/dist/provision/resolvePaymentsConfig.d.ts.map +1 -0
  176. package/dist/provision/resolvePaymentsConfig.js +41 -0
  177. package/dist/rails/apple/certs.d.ts +7 -0
  178. package/dist/rails/apple/certs.d.ts.map +1 -0
  179. package/dist/rails/apple/certs.js +8 -0
  180. package/dist/rails/apple/der.d.ts +107 -0
  181. package/dist/rails/apple/der.d.ts.map +1 -0
  182. package/dist/rails/apple/der.js +217 -0
  183. package/dist/rails/apple/fixtures/chain.d.ts +117 -0
  184. package/dist/rails/apple/fixtures/chain.d.ts.map +1 -0
  185. package/dist/rails/apple/fixtures/chain.js +289 -0
  186. package/dist/rails/apple/http.d.ts +74 -0
  187. package/dist/rails/apple/http.d.ts.map +1 -0
  188. package/dist/rails/apple/http.js +32 -0
  189. package/dist/rails/apple/jws.d.ts +17 -0
  190. package/dist/rails/apple/jws.d.ts.map +1 -0
  191. package/dist/rails/apple/jws.js +75 -0
  192. package/dist/rails/apple/notification.d.ts +116 -0
  193. package/dist/rails/apple/notification.d.ts.map +1 -0
  194. package/dist/rails/apple/notification.js +199 -0
  195. package/dist/rails/apple/rail.d.ts +25 -0
  196. package/dist/rails/apple/rail.d.ts.map +1 -0
  197. package/dist/rails/apple/rail.js +68 -0
  198. package/dist/rails/apple/serverApi.d.ts +120 -0
  199. package/dist/rails/apple/serverApi.d.ts.map +1 -0
  200. package/dist/rails/apple/serverApi.js +244 -0
  201. package/dist/rails/apple/verify.d.ts +36 -0
  202. package/dist/rails/apple/verify.d.ts.map +1 -0
  203. package/dist/rails/apple/verify.js +46 -0
  204. package/dist/rails/apple/x509.d.ts +85 -0
  205. package/dist/rails/apple/x509.d.ts.map +1 -0
  206. package/dist/rails/apple/x509.js +273 -0
  207. package/dist/rails/contract.d.ts +871 -0
  208. package/dist/rails/contract.d.ts.map +1 -0
  209. package/dist/rails/contract.js +60 -0
  210. package/dist/rails/google/fixtures/push.d.ts +71 -0
  211. package/dist/rails/google/fixtures/push.d.ts.map +1 -0
  212. package/dist/rails/google/fixtures/push.js +107 -0
  213. package/dist/rails/google/http.d.ts +77 -0
  214. package/dist/rails/google/http.d.ts.map +1 -0
  215. package/dist/rails/google/http.js +39 -0
  216. package/dist/rails/google/jwt.d.ts +53 -0
  217. package/dist/rails/google/jwt.d.ts.map +1 -0
  218. package/dist/rails/google/jwt.js +94 -0
  219. package/dist/rails/google/oidc.d.ts +112 -0
  220. package/dist/rails/google/oidc.d.ts.map +1 -0
  221. package/dist/rails/google/oidc.js +179 -0
  222. package/dist/rails/google/playApi.d.ts +188 -0
  223. package/dist/rails/google/playApi.d.ts.map +1 -0
  224. package/dist/rails/google/playApi.js +350 -0
  225. package/dist/rails/google/rail.d.ts +57 -0
  226. package/dist/rails/google/rail.d.ts.map +1 -0
  227. package/dist/rails/google/rail.js +70 -0
  228. package/dist/rails/google/rtdn.d.ts +105 -0
  229. package/dist/rails/google/rtdn.d.ts.map +1 -0
  230. package/dist/rails/google/rtdn.js +179 -0
  231. package/dist/rails/google/verify.d.ts +20 -0
  232. package/dist/rails/google/verify.d.ts.map +1 -0
  233. package/dist/rails/google/verify.js +76 -0
  234. package/dist/rails/lemonSqueezy/api.d.ts +92 -0
  235. package/dist/rails/lemonSqueezy/api.d.ts.map +1 -0
  236. package/dist/rails/lemonSqueezy/api.js +121 -0
  237. package/dist/rails/lemonSqueezy/checkout.d.ts +52 -0
  238. package/dist/rails/lemonSqueezy/checkout.d.ts.map +1 -0
  239. package/dist/rails/lemonSqueezy/checkout.js +84 -0
  240. package/dist/rails/lemonSqueezy/discounts.d.ts +50 -0
  241. package/dist/rails/lemonSqueezy/discounts.d.ts.map +1 -0
  242. package/dist/rails/lemonSqueezy/discounts.js +75 -0
  243. package/dist/rails/lemonSqueezy/fixtures/events.d.ts +56 -0
  244. package/dist/rails/lemonSqueezy/fixtures/events.d.ts.map +1 -0
  245. package/dist/rails/lemonSqueezy/fixtures/events.js +144 -0
  246. package/dist/rails/lemonSqueezy/objects.d.ts +229 -0
  247. package/dist/rails/lemonSqueezy/objects.d.ts.map +1 -0
  248. package/dist/rails/lemonSqueezy/objects.js +379 -0
  249. package/dist/rails/lemonSqueezy/portal.d.ts +35 -0
  250. package/dist/rails/lemonSqueezy/portal.d.ts.map +1 -0
  251. package/dist/rails/lemonSqueezy/portal.js +18 -0
  252. package/dist/rails/lemonSqueezy/pricing.d.ts +25 -0
  253. package/dist/rails/lemonSqueezy/pricing.d.ts.map +1 -0
  254. package/dist/rails/lemonSqueezy/pricing.js +54 -0
  255. package/dist/rails/lemonSqueezy/rail.d.ts +41 -0
  256. package/dist/rails/lemonSqueezy/rail.d.ts.map +1 -0
  257. package/dist/rails/lemonSqueezy/rail.js +67 -0
  258. package/dist/rails/lemonSqueezy/read.d.ts +28 -0
  259. package/dist/rails/lemonSqueezy/read.d.ts.map +1 -0
  260. package/dist/rails/lemonSqueezy/read.js +37 -0
  261. package/dist/rails/lemonSqueezy/refresh.d.ts +42 -0
  262. package/dist/rails/lemonSqueezy/refresh.d.ts.map +1 -0
  263. package/dist/rails/lemonSqueezy/refresh.js +40 -0
  264. package/dist/rails/lemonSqueezy/signature.d.ts +56 -0
  265. package/dist/rails/lemonSqueezy/signature.d.ts.map +1 -0
  266. package/dist/rails/lemonSqueezy/signature.js +92 -0
  267. package/dist/rails/lemonSqueezy/verify.d.ts +33 -0
  268. package/dist/rails/lemonSqueezy/verify.d.ts.map +1 -0
  269. package/dist/rails/lemonSqueezy/verify.js +41 -0
  270. package/dist/rails/lemonSqueezy/webhook.d.ts +53 -0
  271. package/dist/rails/lemonSqueezy/webhook.d.ts.map +1 -0
  272. package/dist/rails/lemonSqueezy/webhook.js +179 -0
  273. package/dist/rails/paddle/adjustments.d.ts +60 -0
  274. package/dist/rails/paddle/adjustments.d.ts.map +1 -0
  275. package/dist/rails/paddle/adjustments.js +66 -0
  276. package/dist/rails/paddle/api.d.ts +138 -0
  277. package/dist/rails/paddle/api.d.ts.map +1 -0
  278. package/dist/rails/paddle/api.js +152 -0
  279. package/dist/rails/paddle/checkout.d.ts +69 -0
  280. package/dist/rails/paddle/checkout.d.ts.map +1 -0
  281. package/dist/rails/paddle/checkout.js +100 -0
  282. package/dist/rails/paddle/discounts.d.ts +67 -0
  283. package/dist/rails/paddle/discounts.d.ts.map +1 -0
  284. package/dist/rails/paddle/discounts.js +73 -0
  285. package/dist/rails/paddle/events.d.ts +140 -0
  286. package/dist/rails/paddle/events.d.ts.map +1 -0
  287. package/dist/rails/paddle/events.js +183 -0
  288. package/dist/rails/paddle/fixtures/browserForged.d.ts +42 -0
  289. package/dist/rails/paddle/fixtures/browserForged.d.ts.map +1 -0
  290. package/dist/rails/paddle/fixtures/browserForged.js +52 -0
  291. package/dist/rails/paddle/fixtures/pausedSubscription.d.ts +78 -0
  292. package/dist/rails/paddle/fixtures/pausedSubscription.d.ts.map +1 -0
  293. package/dist/rails/paddle/fixtures/pausedSubscription.js +76 -0
  294. package/dist/rails/paddle/objects.d.ts +519 -0
  295. package/dist/rails/paddle/objects.d.ts.map +1 -0
  296. package/dist/rails/paddle/objects.js +588 -0
  297. package/dist/rails/paddle/portal.d.ts +45 -0
  298. package/dist/rails/paddle/portal.d.ts.map +1 -0
  299. package/dist/rails/paddle/portal.js +42 -0
  300. package/dist/rails/paddle/rail.d.ts +55 -0
  301. package/dist/rails/paddle/rail.d.ts.map +1 -0
  302. package/dist/rails/paddle/rail.js +117 -0
  303. package/dist/rails/paddle/read.d.ts +53 -0
  304. package/dist/rails/paddle/read.d.ts.map +1 -0
  305. package/dist/rails/paddle/read.js +66 -0
  306. package/dist/rails/paddle/recorded.d.ts +49 -0
  307. package/dist/rails/paddle/recorded.d.ts.map +1 -0
  308. package/dist/rails/paddle/recorded.js +79 -0
  309. package/dist/rails/paddle/refresh.d.ts +54 -0
  310. package/dist/rails/paddle/refresh.d.ts.map +1 -0
  311. package/dist/rails/paddle/refresh.js +94 -0
  312. package/dist/rails/paddle/refund.d.ts +82 -0
  313. package/dist/rails/paddle/refund.d.ts.map +1 -0
  314. package/dist/rails/paddle/refund.js +175 -0
  315. package/dist/rails/paddle/signature.d.ts +83 -0
  316. package/dist/rails/paddle/signature.d.ts.map +1 -0
  317. package/dist/rails/paddle/signature.js +163 -0
  318. package/dist/rails/paddle/subscription.d.ts +137 -0
  319. package/dist/rails/paddle/subscription.d.ts.map +1 -0
  320. package/dist/rails/paddle/subscription.js +538 -0
  321. package/dist/rails/paddle/verify.d.ts +46 -0
  322. package/dist/rails/paddle/verify.d.ts.map +1 -0
  323. package/dist/rails/paddle/verify.js +43 -0
  324. package/dist/rails/paddle/webhook.d.ts +98 -0
  325. package/dist/rails/paddle/webhook.d.ts.map +1 -0
  326. package/dist/rails/paddle/webhook.js +181 -0
  327. package/dist/rails/providers.d.ts +73 -0
  328. package/dist/rails/providers.d.ts.map +1 -0
  329. package/dist/rails/providers.js +62 -0
  330. package/dist/rails/stripe/api.d.ts +118 -0
  331. package/dist/rails/stripe/api.d.ts.map +1 -0
  332. package/dist/rails/stripe/api.js +153 -0
  333. package/dist/rails/stripe/checkout.d.ts +60 -0
  334. package/dist/rails/stripe/checkout.d.ts.map +1 -0
  335. package/dist/rails/stripe/checkout.js +86 -0
  336. package/dist/rails/stripe/discounts.d.ts +50 -0
  337. package/dist/rails/stripe/discounts.d.ts.map +1 -0
  338. package/dist/rails/stripe/discounts.js +87 -0
  339. package/dist/rails/stripe/fixtures/events.d.ts +64 -0
  340. package/dist/rails/stripe/fixtures/events.d.ts.map +1 -0
  341. package/dist/rails/stripe/fixtures/events.js +67 -0
  342. package/dist/rails/stripe/objects.d.ts +237 -0
  343. package/dist/rails/stripe/objects.d.ts.map +1 -0
  344. package/dist/rails/stripe/objects.js +389 -0
  345. package/dist/rails/stripe/portal.d.ts +29 -0
  346. package/dist/rails/stripe/portal.d.ts.map +1 -0
  347. package/dist/rails/stripe/portal.js +41 -0
  348. package/dist/rails/stripe/pricing.d.ts +25 -0
  349. package/dist/rails/stripe/pricing.d.ts.map +1 -0
  350. package/dist/rails/stripe/pricing.js +68 -0
  351. package/dist/rails/stripe/rail.d.ts +28 -0
  352. package/dist/rails/stripe/rail.d.ts.map +1 -0
  353. package/dist/rails/stripe/rail.js +81 -0
  354. package/dist/rails/stripe/refresh.d.ts +33 -0
  355. package/dist/rails/stripe/refresh.d.ts.map +1 -0
  356. package/dist/rails/stripe/refresh.js +21 -0
  357. package/dist/rails/stripe/signature.d.ts +71 -0
  358. package/dist/rails/stripe/signature.d.ts.map +1 -0
  359. package/dist/rails/stripe/signature.js +92 -0
  360. package/dist/rails/stripe/verify.d.ts +15 -0
  361. package/dist/rails/stripe/verify.d.ts.map +1 -0
  362. package/dist/rails/stripe/verify.js +63 -0
  363. package/dist/rails/stripe/webhook.d.ts +26 -0
  364. package/dist/rails/stripe/webhook.d.ts.map +1 -0
  365. package/dist/rails/stripe/webhook.js +31 -0
  366. package/dist/secret/registry.d.ts +192 -0
  367. package/dist/secret/registry.d.ts.map +1 -0
  368. package/dist/secret/registry.js +154 -0
  369. package/dist/seeds/example.d.ts +3 -0
  370. package/dist/seeds/example.d.ts.map +1 -0
  371. package/dist/seeds/example.js +171 -0
  372. package/dist/version.generated.d.ts +5 -0
  373. package/dist/version.generated.d.ts.map +1 -0
  374. package/dist/version.generated.js +7 -0
  375. package/dist/workflows/paddleSweep.d.ts +175 -0
  376. package/dist/workflows/paddleSweep.d.ts.map +1 -0
  377. package/dist/workflows/paddleSweep.js +433 -0
  378. package/dist/workflows/railAccess.d.ts +48 -0
  379. package/dist/workflows/railAccess.d.ts.map +1 -0
  380. package/dist/workflows/railAccess.js +36 -0
  381. package/dist/workflows/reconcile.d.ts +161 -0
  382. package/dist/workflows/reconcile.d.ts.map +1 -0
  383. package/dist/workflows/reconcile.js +352 -0
  384. package/dist/workflows/report.d.ts +28 -0
  385. package/dist/workflows/report.d.ts.map +1 -0
  386. package/dist/workflows/report.js +54 -0
  387. package/dist/workflows/retryPolicy.d.ts +29 -0
  388. package/dist/workflows/retryPolicy.d.ts.map +1 -0
  389. package/dist/workflows/retryPolicy.js +37 -0
  390. package/dist/workflows/specs.d.ts +102 -0
  391. package/dist/workflows/specs.d.ts.map +1 -0
  392. package/dist/workflows/specs.js +84 -0
  393. package/dist/workflows/worker.d.ts +62 -0
  394. package/dist/workflows/worker.d.ts.map +1 -0
  395. package/dist/workflows/worker.js +92 -0
  396. package/dist/workflows/workerConfig.d.ts +46 -0
  397. package/dist/workflows/workerConfig.d.ts.map +1 -0
  398. package/dist/workflows/workerConfig.js +38 -0
  399. package/package.json +22 -13
  400. package/pithy.manifest.json +19 -13
  401. package/src/version.generated.ts +1 -1
  402. package/src/client/paddlePrices.iife.ts +0 -43
@@ -0,0 +1,273 @@
1
+ import { PaymentsInvalidReceiptError, PaymentsVerificationFailedError } from "../../error/errors.js";
2
+ import { asn1Children, bytesEqual, decodeBase64, derSignatureToRaw, readAsn1, readBits, readBoolean, readInteger, readOid } from "./der.js";
3
+ //#region src/rails/apple/x509.ts
4
+ /**
5
+ * X.509 certificates, and the chain check that makes an Apple signature mean something.
6
+ *
7
+ * A JWS signature only proves that whoever held a key signed the bytes. What makes it *Apple's* signature
8
+ * is that the key belongs to a certificate Apple issued, through an intermediate Apple issued, from a root
9
+ * we shipped. Skipping any link of that turns the webhook route into one that accepts a notification signed
10
+ * by anybody who can mint a certificate — which is anybody.
11
+ *
12
+ * So the chain is verified in full, and every rule below exists because omitting it is a known bypass:
13
+ *
14
+ * - **Each link's signature is checked against the next certificate's key.** Reading `x5c` and trusting the
15
+ * leaf is the classic mistake: the header is attacker-controlled, so an unchecked chain is decoration.
16
+ * - **The last certificate must be byte-identical to a pinned root.** Byte equality rather than
17
+ * re-verifying the root's self-signature, because a self-signature only proves a root vouches for itself,
18
+ * which every forged root also does.
19
+ * - **Issuer and subject names must match, link by link.** Cheap, and it refuses a chain assembled out of
20
+ * two unrelated ones before any crypto runs.
21
+ * - **Every certificate's validity window must contain the clock**, the root included. An expired
22
+ * intermediate is as much a refusal as an expired leaf, and the clock is injected so the check is a real
23
+ * comparison in tests rather than an accident of when the suite runs.
24
+ * - **Every certificate above the leaf must be a CA**, by `basicConstraints.cA`, with `keyCertSign` in
25
+ * `keyUsage` where that extension is present, and its `pathLenConstraint` respected. Without this the
26
+ * other rules are not enough, and the hole is not theoretical: a chain of
27
+ * `[forged, someAppleLeaf, intermediate, root]` links correctly, sits inside every validity window, and
28
+ * roots in the pinned certificate. Anyone holding **any** ECDSA leaf certificate issued under Apple Root
29
+ * CA - G3 — a paid developer's own certificate is one — could sign `forged` themselves and every check
30
+ * above would pass. `cA` is what says a certificate may issue others, so it is what closes it.
31
+ * - **The leaf and its issuer must carry Apple's marker extensions.** Apple publishes an OID it puts on the
32
+ * certificate that signs App Store data, and another on the WWDR intermediate that issues it. Requiring
33
+ * them means a chain must not merely root in Apple's CA but be *the* Apple chain for *this* purpose — so
34
+ * even a genuine Apple sub-CA issued for something else cannot sign a notification.
35
+ *
36
+ * Only ECDSA is accepted, on P-256 and P-384, with SHA-256 or SHA-384. Apple's chain is elliptic-curve end
37
+ * to end (see `certs.ts`), and an algorithm the boundary never meets is surface with no user.
38
+ *
39
+ * A structural problem throws `payments/invalid_receipt`; a chain that is well-formed but does not verify
40
+ * throws `payments/verification_failed`. The distinction is worth keeping: the first is a malformed
41
+ * request, the second is a rejected one.
42
+ */
43
+ /** ECDSA signature-algorithm OIDs → the digest each one names. */
44
+ const SIGNATURE_HASHES = {
45
+ "1.2.840.10045.4.3.2": "SHA-256",
46
+ "1.2.840.10045.4.3.3": "SHA-384"
47
+ };
48
+ /** Named-curve OIDs → the curve names WebCrypto knows them by. */
49
+ const CURVES = {
50
+ "1.2.840.10045.3.1.7": "P-256",
51
+ "1.3.132.0.34": "P-384"
52
+ };
53
+ /** The coordinate width of each curve, which is what an ECDSA signature's two halves are padded to. */
54
+ const COORDINATE_BYTES = {
55
+ "P-256": 32,
56
+ "P-384": 48
57
+ };
58
+ /** `basicConstraints` — whether a certificate may issue others, and how deep beneath it a path may run. */
59
+ const OID_BASIC_CONSTRAINTS = "2.5.29.19";
60
+ /** `keyUsage` — the bit field whose `keyCertSign` says the key may sign certificates. */
61
+ const OID_KEY_USAGE = "2.5.29.15";
62
+ /** `keyCertSign` is bit 5 of `keyUsage`, counting from the most significant bit of the first byte. */
63
+ const KEY_CERT_SIGN_BIT = 5;
64
+ /**
65
+ * Apple's marker on the certificate that signs App Store Server Notifications and transactions, and on the
66
+ * WWDR intermediate that issues it. Published by Apple and checked by Apple's own `app-store-server-library`,
67
+ * which is where these values come from; they are identifiers, not secrets.
68
+ *
69
+ * They are what make the chain check an identity check. Rooting in Apple Root CA - G3 proves Apple issued
70
+ * something in the path; these prove the path is Apple's App-Store-data-signing path specifically.
71
+ */
72
+ const APPLE_RECEIPT_SIGNER_OID = "1.2.840.113635.100.6.11.1";
73
+ const APPLE_WWDR_INTERMEDIATE_OID = "1.2.840.113635.100.6.2.1";
74
+ /**
75
+ * The most certificates a chain may carry. Apple sends three. The cap exists because every link costs a
76
+ * signature verification, and the chain arrives in an unauthenticated request — an attacker who can make us
77
+ * verify an unbounded chain has found a way to spend our CPU for the price of one POST.
78
+ */
79
+ const MAX_CHAIN_LENGTH = 10;
80
+ function malformed(detail) {
81
+ return new PaymentsInvalidReceiptError({ detail });
82
+ }
83
+ /** A well-formed chain that does not verify. The public message never says which link failed. */
84
+ function rejected(detail) {
85
+ return new PaymentsVerificationFailedError({
86
+ message: "That purchase could not be verified.",
87
+ action: "Retry. If it persists, the store's signing certificates may have changed — update the package.",
88
+ detail
89
+ });
90
+ }
91
+ /** An X.509 `Time`, which is a UTCTime before 2050 and a GeneralizedTime after it. */
92
+ function readTime(node) {
93
+ const text = new TextDecoder().decode(node.value);
94
+ if (node.tag === 23) {
95
+ if (!/^\d{12}Z$/.test(text)) throw malformed(`X.509: malformed UTCTime "${text}".`);
96
+ const twoDigitYear = Number(text.slice(0, 2));
97
+ const year = twoDigitYear >= 50 ? 1900 + twoDigitYear : 2e3 + twoDigitYear;
98
+ return /* @__PURE__ */ new Date(`${year}-${text.slice(2, 4)}-${text.slice(4, 6)}T${text.slice(6, 8)}:${text.slice(8, 10)}:${text.slice(10, 12)}Z`);
99
+ }
100
+ if (node.tag === 24) {
101
+ if (!/^\d{14}Z$/.test(text)) throw malformed(`X.509: malformed GeneralizedTime "${text}".`);
102
+ return /* @__PURE__ */ new Date(`${text.slice(0, 4)}-${text.slice(4, 6)}-${text.slice(6, 8)}T${text.slice(8, 10)}:${text.slice(10, 12)}:${text.slice(12, 14)}Z`);
103
+ }
104
+ throw malformed(`X.509: tag 0x${node.tag.toString(16)} is not a Time.`);
105
+ }
106
+ /** The curve named in a SubjectPublicKeyInfo's algorithm parameters. */
107
+ function readCurve(spki) {
108
+ const algorithm = asn1Children(spki)[0];
109
+ if (!algorithm) throw malformed("X.509: SubjectPublicKeyInfo has no algorithm.");
110
+ const parameters = asn1Children(algorithm)[1];
111
+ if (!parameters) throw malformed("X.509: the subject key names no curve — only ECDSA keys are accepted.");
112
+ const curve = CURVES[readOid(parameters)];
113
+ if (!curve) throw malformed(`X.509: curve ${readOid(parameters)} is not one this verifier accepts.`);
114
+ return curve;
115
+ }
116
+ /**
117
+ * The extensions of a tbsCertificate, by OID.
118
+ *
119
+ * `extensions` is `[3] EXPLICIT Extensions OPTIONAL`, the last field, and each `Extension` is
120
+ * `SEQUENCE { extnID OID, critical BOOLEAN DEFAULT FALSE, extnValue OCTET STRING }`. A repeated OID is
121
+ * refused: RFC 5280 forbids it, and a parser that kept the first while another kept the last would let one
122
+ * certificate mean two things.
123
+ */
124
+ function readExtensions(fields) {
125
+ const found = /* @__PURE__ */ new Map();
126
+ const container = fields.find((field) => field.tag === 163);
127
+ if (!container) return found;
128
+ const [list] = asn1Children(container);
129
+ if (!list || list.tag !== 48) throw malformed("X.509: extensions is not a SEQUENCE.");
130
+ for (const extension of asn1Children(list)) {
131
+ const parts = asn1Children(extension);
132
+ const [id] = parts;
133
+ if (!id) throw malformed("X.509: an extension has no OID.");
134
+ const oid = readOid(id);
135
+ const critical = parts[1]?.tag === 1 ? readBoolean(parts[1]) : false;
136
+ const value = parts.find((part, index) => index > 0 && part.tag === 4);
137
+ if (!value) throw malformed(`X.509: extension ${oid} has no value.`);
138
+ if (found.has(oid)) throw malformed(`X.509: extension ${oid} appears twice.`);
139
+ found.set(oid, {
140
+ critical,
141
+ value: value.value
142
+ });
143
+ }
144
+ return found;
145
+ }
146
+ /** `basicConstraints ::= SEQUENCE { cA BOOLEAN DEFAULT FALSE, pathLenConstraint INTEGER OPTIONAL }`. */
147
+ function readBasicConstraints(extension) {
148
+ const { node } = readAsn1(extension.value);
149
+ if (node.tag !== 48) throw malformed("X.509: basicConstraints is not a SEQUENCE.");
150
+ const parts = asn1Children(node);
151
+ const ca = parts[0]?.tag === 1 ? readBoolean(parts[0]) : false;
152
+ const lengthNode = parts.find((part) => part.tag === 2);
153
+ return lengthNode ? {
154
+ ca,
155
+ pathLen: readInteger(lengthNode)
156
+ } : { ca };
157
+ }
158
+ /** Whether `keyUsage` grants `keyCertSign`. A short BIT STRING simply does not reach the bit. */
159
+ function readKeyCertSign(extension) {
160
+ const { node } = readAsn1(extension.value);
161
+ return readBits(node)[KEY_CERT_SIGN_BIT] === true;
162
+ }
163
+ /**
164
+ * Parse one DER certificate.
165
+ *
166
+ * `Certificate ::= SEQUENCE { tbsCertificate, signatureAlgorithm, signatureValue }`, and inside the tbs,
167
+ * `SEQUENCE { [0] version, serialNumber, signature, issuer, validity, subject, subjectPublicKeyInfo, … }`.
168
+ * The version field is optional, so the fields after it are located by counting from the end of whichever
169
+ * prefix is present rather than by fixed index.
170
+ */
171
+ function parseCertificate(der) {
172
+ const { node: certificate } = readAsn1(der);
173
+ if (certificate.tag !== 48) throw malformed("X.509: a certificate must be a SEQUENCE.");
174
+ const [tbs, algorithm, signature] = asn1Children(certificate);
175
+ if (!tbs || !algorithm || !signature) throw malformed("X.509: a certificate has three members.");
176
+ const fields = asn1Children(tbs);
177
+ const offset = fields[0]?.tag === 160 ? 1 : 0;
178
+ const issuer = fields[offset + 2];
179
+ const validity = fields[offset + 3];
180
+ const subject = fields[offset + 4];
181
+ const spki = fields[offset + 5];
182
+ if (!issuer || !validity || !subject || !spki) throw malformed("X.509: tbsCertificate is missing fields.");
183
+ const [notBefore, notAfter] = asn1Children(validity);
184
+ if (!notBefore || !notAfter) throw malformed("X.509: validity needs both bounds.");
185
+ const extensions = readExtensions(fields);
186
+ const constraints = extensions.get(OID_BASIC_CONSTRAINTS);
187
+ const usage = extensions.get(OID_KEY_USAGE);
188
+ return {
189
+ der,
190
+ tbs: tbs.der,
191
+ issuer: issuer.der,
192
+ subject: subject.der,
193
+ notBefore: readTime(notBefore),
194
+ notAfter: readTime(notAfter),
195
+ spki: spki.der,
196
+ curve: readCurve(spki),
197
+ signatureAlgorithm: readOid(asn1Children(algorithm)[0] ?? algorithm),
198
+ signature: signature.value.subarray(1),
199
+ extensions,
200
+ basicConstraints: constraints ? readBasicConstraints(constraints) : void 0,
201
+ keyCertSign: usage ? readKeyCertSign(usage) : void 0
202
+ };
203
+ }
204
+ /** Import a certificate's public key for verification. */
205
+ async function importKey(certificate) {
206
+ try {
207
+ return await crypto.subtle.importKey("spki", certificate.spki, {
208
+ name: "ECDSA",
209
+ namedCurve: certificate.curve
210
+ }, false, ["verify"]);
211
+ } catch (cause) {
212
+ throw new PaymentsInvalidReceiptError({ detail: `X.509: the ${certificate.curve} public key could not be imported.` }, { cause });
213
+ }
214
+ }
215
+ /** Whether `issuer` signed `certificate`. */
216
+ async function signedBy(certificate, issuer) {
217
+ const hash = SIGNATURE_HASHES[certificate.signatureAlgorithm];
218
+ if (!hash) throw rejected(`X.509: signature algorithm ${certificate.signatureAlgorithm} is not accepted.`);
219
+ const raw = derSignatureToRaw(certificate.signature, COORDINATE_BYTES[issuer.curve]);
220
+ return crypto.subtle.verify({
221
+ name: "ECDSA",
222
+ hash
223
+ }, await importKey(issuer), raw, certificate.tbs);
224
+ }
225
+ /**
226
+ * Verify a certificate chain — leaf first, root last, the order `x5c` uses — and return the leaf's
227
+ * verifying key. Throws rather than returning a boolean: there is no caller that wants to carry on with an
228
+ * unverified chain, and a boolean invites one.
229
+ */
230
+ async function verifyCertificateChain(chain, options) {
231
+ if (chain.length < 2) throw rejected(`X.509: a chain of ${chain.length} cannot be verified; leaf and root at least.`);
232
+ if (chain.length > MAX_CHAIN_LENGTH) throw rejected(`X.509: a chain of ${chain.length} is longer than the ${MAX_CHAIN_LENGTH} accepted.`);
233
+ const certificates = chain.map((der) => parseCertificate(der));
234
+ const at = options.now.getTime();
235
+ for (const [index, certificate] of certificates.entries()) if (at < certificate.notBefore.getTime() || at > certificate.notAfter.getTime()) throw rejected(`X.509: certificate ${index} is valid ${certificate.notBefore.toISOString()}–${certificate.notAfter.toISOString()}.`);
236
+ const root = certificates[certificates.length - 1];
237
+ if (!options.roots.some((encoded) => bytesEqual(decodeBase64(encoded), root.der))) throw rejected("X.509: the chain's root is not one of the pinned roots.");
238
+ /**
239
+ * Every certificate above the leaf must be entitled to issue the one below it.
240
+ *
241
+ * This is the check whose absence makes the rest decorative. A chain of
242
+ * `[forged, someAppleLeaf, intermediate, root]` links, sits inside every window, and roots in the pinned
243
+ * certificate — so without `cA` anyone holding any ECDSA certificate issued under Apple's root could sign
244
+ * `forged` and be believed. `pathLenConstraint` is the same rule stated as a depth: a CA that says "no
245
+ * intermediates beneath me" must not have any.
246
+ */
247
+ for (let index = 1; index < certificates.length; index += 1) {
248
+ const authority = certificates[index];
249
+ if (authority.basicConstraints?.ca !== true) throw rejected(`X.509: certificate ${index} issued the one below it but is not a CA (basicConstraints).`);
250
+ if (authority.keyCertSign === false) throw rejected(`X.509: certificate ${index} issued the one below it but its keyUsage omits keyCertSign.`);
251
+ const intermediatesBelow = index - 1;
252
+ const { pathLen } = authority.basicConstraints;
253
+ if (pathLen !== void 0 && intermediatesBelow > pathLen) throw rejected(`X.509: certificate ${index} permits ${pathLen} intermediates beneath it, the chain has ${intermediatesBelow}.`);
254
+ }
255
+ for (let index = 0; index < certificates.length - 1; index += 1) {
256
+ const certificate = certificates[index];
257
+ const issuer = certificates[index + 1];
258
+ if (!bytesEqual(certificate.issuer, issuer.subject)) throw rejected(`X.509: certificate ${index}'s issuer name does not match certificate ${index + 1}'s subject.`);
259
+ if (!await signedBy(certificate, issuer)) throw rejected(`X.509: certificate ${index} was not signed by certificate ${index + 1}.`);
260
+ }
261
+ const leaf = certificates[0];
262
+ const leafExtension = options.requiredLeafExtension === void 0 ? APPLE_RECEIPT_SIGNER_OID : options.requiredLeafExtension;
263
+ if (leafExtension !== null && !leaf.extensions.has(leafExtension)) throw rejected(`X.509: the leaf does not carry ${leafExtension}, so it is not an App Store signing certificate.`);
264
+ const issuerExtension = options.requiredIssuerExtension === void 0 ? APPLE_WWDR_INTERMEDIATE_OID : options.requiredIssuerExtension;
265
+ const issuer = certificates[1];
266
+ if (issuerExtension !== null && !issuer.extensions.has(issuerExtension)) throw rejected(`X.509: the leaf's issuer does not carry ${issuerExtension}, so it is not the WWDR intermediate.`);
267
+ return {
268
+ key: await importKey(leaf),
269
+ curve: leaf.curve
270
+ };
271
+ }
272
+ //#endregion
273
+ export { APPLE_RECEIPT_SIGNER_OID, APPLE_WWDR_INTERMEDIATE_OID, parseCertificate, verifyCertificateChain };