@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,31 @@
1
+ import { PaymentsVerificationFailedError } from "../../error/errors.js";
2
+ import { StripeEvent, mapStripeEvent } from "./objects.js";
3
+ import { STRIPE_SIGNATURE_HEADER, verifyStripeSignature } from "./signature.js";
4
+ //#region src/rails/stripe/webhook.ts
5
+ /** Verify and normalize one Stripe webhook delivery. Throws when authenticity cannot be established. */
6
+ async function parseStripeNotification(delivery, options) {
7
+ await verifyStripeSignature(delivery.body, delivery.headers.get(STRIPE_SIGNATURE_HEADER), options.credentials.webhookSecret, {
8
+ now: options.now,
9
+ toleranceSeconds: options.toleranceSeconds
10
+ });
11
+ let raw;
12
+ try {
13
+ raw = JSON.parse(delivery.body);
14
+ } catch (cause) {
15
+ throw new PaymentsVerificationFailedError({ detail: "Stripe: the delivery verified but its body is not JSON." }, { cause });
16
+ }
17
+ const parsed = StripeEvent.safeParse(raw);
18
+ if (!parsed.success) throw new PaymentsVerificationFailedError({ detail: `Stripe: the delivery is not a Stripe event — ${parsed.error.issues.map((issue) => `${issue.path.join(".") || "<root>"}:${issue.code}`).join(", ")}.` });
19
+ const event = parsed.data;
20
+ const mapped = mapStripeEvent(event);
21
+ return {
22
+ providerEventId: event.id,
23
+ payload: event,
24
+ event: mapped.event,
25
+ providerAccountId: mapped.providerAccountId,
26
+ accountReference: mapped.accountReference,
27
+ note: mapped.note
28
+ };
29
+ }
30
+ //#endregion
31
+ export { parseStripeNotification };
@@ -0,0 +1,192 @@
1
+ import { z } from "zod";
2
+ import type { PaymentsRail } from "../data/rail";
3
+ /**
4
+ * The one secret payments reads, and the shape of it.
5
+ *
6
+ * **One entry, five optional rails.** Every rail's credentials live inside a single JSON secret rather than
7
+ * one secret per rail, and that is a storage decision worth stating: adding a rail then never reshapes
8
+ * storage, never adds a binding to a `wrangler.jsonc`, and never needs a migration of the secrets store. It
9
+ * is the arrangement `@pithy-sh/turnstile` uses for its per-mode widget keys, for the same reason — one
10
+ * secret serves one *or* both, so the second costs nothing.
11
+ *
12
+ * A rail's block is present or entirely absent. There is no partial credential: `strictObject` with every
13
+ * field required means an operator who supplies half of Stripe's pair gets a loud
14
+ * `secrets/invalid_value` at the read rather than a signature check that silently never passes.
15
+ *
16
+ * ## Reading it
17
+ *
18
+ * `await sharedSecretsStore(env, paymentsSecretsRegistry)` then `.get(PAYMENTS_PROVIDER_SECRET)`, at the
19
+ * point of need — never off a raw `env.X`, never through `CloudflareSecretsStoreManager`, never cached in a
20
+ * module variable, and never spread into a log or an audit payload. Grep `sharedSecretsStore(` to find every
21
+ * read site. `backend` is the single place the storage location is decided; moving this bundle to the
22
+ * Cloudflare Secrets Store would be a one-line edit here (plus a binding) and no change at any read site.
23
+ *
24
+ * `rotatable: true` because two of these genuinely rotate — Apple's App Store Connect key and Stripe's
25
+ * webhook signing secret — and a verifier that must span a rotation reads `getVersions` instead of `get`.
26
+ * Rotation changes nothing about how the value is stored, so declaring it now costs nothing and declaring it
27
+ * later would be a registry edit during an incident.
28
+ *
29
+ * ## What is not here
30
+ *
31
+ * Apple's **root certificates**, because they are public: they ship in `rails/apple/certs.ts` as pinned
32
+ * assets. Storing a public key as a secret would suggest the verification depends on its secrecy, and it does
33
+ * not — it depends on it being *ours*.
34
+ *
35
+ * The **bundle id** is here, in Apple's block, and it is not secret either. It sits with the credentials
36
+ * because it is part of the app's identity at Apple: it is what a notification is checked against, and it is
37
+ * the `bid` claim an App Store Server API token carries. Splitting it into config would put one half of one
38
+ * app's identity in git and the other in the secrets store.
39
+ */
40
+ /** The name the credential bundle is stored and resolved under. The join key across every registry. */
41
+ export declare const PAYMENTS_PROVIDER_SECRET = "payments-provider-credentials";
42
+ /**
43
+ * The console each rail's credentials are taken from, and taken from again ninety days later.
44
+ *
45
+ * **This is the honest answer, and it does not fit in `documentation`.** That field holds one required
46
+ * URL; this secret spans five issuers, and every one of them publishes its own page. There is no sixth
47
+ * page that names all five, because no company documents a competitor's console. A single string can
48
+ * therefore be true of at most one rail out of five, and the entry has to say something for all of them.
49
+ *
50
+ * So the entry points at ours, `PAYMENTS_CREDENTIALS_PAGE`, whose only job is to carry this table to an
51
+ * operator who arrived by clicking. The table is the destination; the page is the redirect. That is one
52
+ * hop more than the field promises — `SecretOrigin` restricting `documentation` to a single URL is the
53
+ * reason, and #332 is where the shape is argued.
54
+ *
55
+ * Not a rail's marketing page and not a "how to integrate" guide: the deep link to the settings screen
56
+ * that shows the key, so an operator lands on the thing they came to copy.
57
+ */
58
+ export declare const PAYMENTS_RAIL_CONSOLES: Readonly<Record<PaymentsRail, string>>;
59
+ /**
60
+ * Where a human goes for these credentials, and where the same human replaces them.
61
+ *
62
+ * **Five consoles, one `issuer` field.** Apple's `.p8`, Google's service-account key, Stripe's key pair,
63
+ * Lemon Squeezy's API key and Paddle's are each taken by hand from a different company's console, and they
64
+ * share one secret because they share one storage decision (see above) — not because they share an issuer.
65
+ * The axis holds a single name, so the honest one is `other`: *somebody issues this, and it is not one
66
+ * somebody.* Naming any single rail would be wrong for every deployment that does not sell through it.
67
+ *
68
+ * So the link is the one page that names all five rather than a rail's settings page. It has to *name*
69
+ * them: this constant pointed at the same document before #332 and the document listed no console at all,
70
+ * which cost the click and returned the reader to the search they started with. The section is fixed by
71
+ * name, and `registry.test.ts` reads the file off disk and fails if a rail's console is not in it.
72
+ *
73
+ * The day this bundle is split per rail — or `SecretOrigin` grows a destination per issuer — each half
74
+ * names its own console and this constant goes.
75
+ */
76
+ export declare const PAYMENTS_CREDENTIALS_PAGE = "https://github.com/pithy-sh/pithy/blob/main/docs/commands/payments.md#where-each-rails-credentials-come-from";
77
+ export declare const PaymentsAppleCredentials: z.ZodObject<{
78
+ bundleId: z.ZodString;
79
+ keyId: z.ZodString;
80
+ issuerId: z.ZodString;
81
+ privateKey: z.ZodString;
82
+ }, z.core.$strict>;
83
+ export type PaymentsAppleCredentials = z.infer<typeof PaymentsAppleCredentials>;
84
+ export declare const PaymentsGoogleCredentials: z.ZodObject<{
85
+ packageName: z.ZodString;
86
+ serviceAccountEmail: z.ZodString;
87
+ privateKey: z.ZodString;
88
+ pubsubAudience: z.ZodString;
89
+ }, z.core.$strict>;
90
+ export type PaymentsGoogleCredentials = z.infer<typeof PaymentsGoogleCredentials>;
91
+ export declare const PaymentsStripeCredentials: z.ZodObject<{
92
+ secretKey: z.ZodString;
93
+ webhookSecret: z.ZodString;
94
+ }, z.core.$strict>;
95
+ export type PaymentsStripeCredentials = z.infer<typeof PaymentsStripeCredentials>;
96
+ export declare const PaymentsLemonSqueezyCredentials: z.ZodObject<{
97
+ apiKey: z.ZodString;
98
+ webhookSecret: z.ZodString;
99
+ storeId: z.ZodString;
100
+ }, z.core.$strict>;
101
+ export type PaymentsLemonSqueezyCredentials = z.infer<typeof PaymentsLemonSqueezyCredentials>;
102
+ export declare const PaymentsPaddleCredentials: z.ZodObject<{
103
+ apiKey: z.ZodString;
104
+ webhookSecret: z.ZodString;
105
+ }, z.core.$strict>;
106
+ export type PaymentsPaddleCredentials = z.infer<typeof PaymentsPaddleCredentials>;
107
+ export declare const PaymentsProviderCredentials: z.ZodObject<{
108
+ apple: z.ZodOptional<z.ZodObject<{
109
+ bundleId: z.ZodString;
110
+ keyId: z.ZodString;
111
+ issuerId: z.ZodString;
112
+ privateKey: z.ZodString;
113
+ }, z.core.$strict>>;
114
+ google: z.ZodOptional<z.ZodObject<{
115
+ packageName: z.ZodString;
116
+ serviceAccountEmail: z.ZodString;
117
+ privateKey: z.ZodString;
118
+ pubsubAudience: z.ZodString;
119
+ }, z.core.$strict>>;
120
+ stripe: z.ZodOptional<z.ZodObject<{
121
+ secretKey: z.ZodString;
122
+ webhookSecret: z.ZodString;
123
+ }, z.core.$strict>>;
124
+ lemonSqueezy: z.ZodOptional<z.ZodObject<{
125
+ apiKey: z.ZodString;
126
+ webhookSecret: z.ZodString;
127
+ storeId: z.ZodString;
128
+ }, z.core.$strict>>;
129
+ paddle: z.ZodOptional<z.ZodObject<{
130
+ apiKey: z.ZodString;
131
+ webhookSecret: z.ZodString;
132
+ }, z.core.$strict>>;
133
+ }, z.core.$strict>;
134
+ export type PaymentsProviderCredentials = z.infer<typeof PaymentsProviderCredentials>;
135
+ /** Payments' secret-registry slice, aggregated into the shared accessor at worker startup. */
136
+ export declare const paymentsSecretsRegistry: {
137
+ readonly "payments-provider-credentials": {
138
+ readonly backend: "d1";
139
+ readonly scope: "environment";
140
+ readonly rotatable: true;
141
+ readonly valueType: "json";
142
+ readonly schema: z.ZodObject<{
143
+ apple: z.ZodOptional<z.ZodObject<{
144
+ bundleId: z.ZodString;
145
+ keyId: z.ZodString;
146
+ issuerId: z.ZodString;
147
+ privateKey: z.ZodString;
148
+ }, z.core.$strict>>;
149
+ google: z.ZodOptional<z.ZodObject<{
150
+ packageName: z.ZodString;
151
+ serviceAccountEmail: z.ZodString;
152
+ privateKey: z.ZodString;
153
+ pubsubAudience: z.ZodString;
154
+ }, z.core.$strict>>;
155
+ stripe: z.ZodOptional<z.ZodObject<{
156
+ secretKey: z.ZodString;
157
+ webhookSecret: z.ZodString;
158
+ }, z.core.$strict>>;
159
+ lemonSqueezy: z.ZodOptional<z.ZodObject<{
160
+ apiKey: z.ZodString;
161
+ webhookSecret: z.ZodString;
162
+ storeId: z.ZodString;
163
+ }, z.core.$strict>>;
164
+ paddle: z.ZodOptional<z.ZodObject<{
165
+ apiKey: z.ZodString;
166
+ webhookSecret: z.ZodString;
167
+ }, z.core.$strict>>;
168
+ }, z.core.$strict>;
169
+ readonly origin: {
170
+ readonly kind: "obtained";
171
+ readonly issuer: "other";
172
+ readonly documentation: "https://github.com/pithy-sh/pithy/blob/main/docs/commands/payments.md#where-each-rails-credentials-come-from";
173
+ };
174
+ readonly rotation: {
175
+ readonly kind: "manual";
176
+ readonly issuer: "other";
177
+ readonly documentation: "https://github.com/pithy-sh/pithy/blob/main/docs/commands/payments.md#where-each-rails-credentials-come-from";
178
+ };
179
+ };
180
+ };
181
+ /**
182
+ * The credentials for one rail, or a refusal.
183
+ *
184
+ * A rail enabled in `pithy.config.ts` whose credentials were never provisioned is a 404, not a 500: from the
185
+ * caller's side that payment method genuinely is not available here, and telling a client which of config or
186
+ * provisioning is missing tells it about our deployment. `detail` carries the distinction for the operator.
187
+ *
188
+ * `action` carries the console. Which rail is missing is known here, so the one page out of five that
189
+ * answers "where do I get one" is known here too — and this is the moment the question is being asked.
190
+ */
191
+ export declare function railCredentials<R extends PaymentsRail>(credentials: PaymentsProviderCredentials, rail: R): NonNullable<PaymentsProviderCredentials[R]>;
192
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/secret/registry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,uGAAuG;AACvG,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AAExE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAUzE,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,yBAAyB,iHAC0E,CAAC;AAEjH,eAAO,MAAM,wBAAwB;;;;;kBAuB6E,CAAC;AACnH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF,eAAO,MAAM,yBAAyB;;;;;kBA2BiF,CAAC;AACxH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAElF,eAAO,MAAM,yBAAyB;;;kBAe2E,CAAC;AAClH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAElF,eAAO,MAAM,+BAA+B;;;;kBAqBkE,CAAC;AAC/G,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAE9F,eAAO,MAAM,yBAAyB;;;kBAiBnC,CAAC;AACJ,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAElF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;kBAYrC,CAAC;AACJ,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEtF,8FAA8F;AAC9F,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmBlC,CAAC;AAEH;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,YAAY,EACpD,WAAW,EAAE,2BAA2B,EACxC,IAAI,EAAE,CAAC,GACN,WAAW,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC,CAS7C"}
@@ -0,0 +1,154 @@
1
+ import { PaymentsRailNotConfiguredError } from "../error/errors.js";
2
+ import { z } from "zod";
3
+ import { defineSecretRegistry } from "@pithy-sh/secrets/src/registry";
4
+ //#region src/secret/registry.ts
5
+ /**
6
+ * The one secret payments reads, and the shape of it.
7
+ *
8
+ * **One entry, five optional rails.** Every rail's credentials live inside a single JSON secret rather than
9
+ * one secret per rail, and that is a storage decision worth stating: adding a rail then never reshapes
10
+ * storage, never adds a binding to a `wrangler.jsonc`, and never needs a migration of the secrets store. It
11
+ * is the arrangement `@pithy-sh/turnstile` uses for its per-mode widget keys, for the same reason — one
12
+ * secret serves one *or* both, so the second costs nothing.
13
+ *
14
+ * A rail's block is present or entirely absent. There is no partial credential: `strictObject` with every
15
+ * field required means an operator who supplies half of Stripe's pair gets a loud
16
+ * `secrets/invalid_value` at the read rather than a signature check that silently never passes.
17
+ *
18
+ * ## Reading it
19
+ *
20
+ * `await sharedSecretsStore(env, paymentsSecretsRegistry)` then `.get(PAYMENTS_PROVIDER_SECRET)`, at the
21
+ * point of need — never off a raw `env.X`, never through `CloudflareSecretsStoreManager`, never cached in a
22
+ * module variable, and never spread into a log or an audit payload. Grep `sharedSecretsStore(` to find every
23
+ * read site. `backend` is the single place the storage location is decided; moving this bundle to the
24
+ * Cloudflare Secrets Store would be a one-line edit here (plus a binding) and no change at any read site.
25
+ *
26
+ * `rotatable: true` because two of these genuinely rotate — Apple's App Store Connect key and Stripe's
27
+ * webhook signing secret — and a verifier that must span a rotation reads `getVersions` instead of `get`.
28
+ * Rotation changes nothing about how the value is stored, so declaring it now costs nothing and declaring it
29
+ * later would be a registry edit during an incident.
30
+ *
31
+ * ## What is not here
32
+ *
33
+ * Apple's **root certificates**, because they are public: they ship in `rails/apple/certs.ts` as pinned
34
+ * assets. Storing a public key as a secret would suggest the verification depends on its secrecy, and it does
35
+ * not — it depends on it being *ours*.
36
+ *
37
+ * The **bundle id** is here, in Apple's block, and it is not secret either. It sits with the credentials
38
+ * because it is part of the app's identity at Apple: it is what a notification is checked against, and it is
39
+ * the `bid` claim an App Store Server API token carries. Splitting it into config would put one half of one
40
+ * app's identity in git and the other in the secrets store.
41
+ */
42
+ /** The name the credential bundle is stored and resolved under. The join key across every registry. */
43
+ const PAYMENTS_PROVIDER_SECRET = "payments-provider-credentials";
44
+ /**
45
+ * The console each rail's credentials are taken from, and taken from again ninety days later.
46
+ *
47
+ * **This is the honest answer, and it does not fit in `documentation`.** That field holds one required
48
+ * URL; this secret spans five issuers, and every one of them publishes its own page. There is no sixth
49
+ * page that names all five, because no company documents a competitor's console. A single string can
50
+ * therefore be true of at most one rail out of five, and the entry has to say something for all of them.
51
+ *
52
+ * So the entry points at ours, `PAYMENTS_CREDENTIALS_PAGE`, whose only job is to carry this table to an
53
+ * operator who arrived by clicking. The table is the destination; the page is the redirect. That is one
54
+ * hop more than the field promises — `SecretOrigin` restricting `documentation` to a single URL is the
55
+ * reason, and #332 is where the shape is argued.
56
+ *
57
+ * Not a rail's marketing page and not a "how to integrate" guide: the deep link to the settings screen
58
+ * that shows the key, so an operator lands on the thing they came to copy.
59
+ */
60
+ const PAYMENTS_RAIL_CONSOLES = {
61
+ apple: "https://appstoreconnect.apple.com/access/integrations/api",
62
+ google: "https://console.cloud.google.com/iam-admin/serviceaccounts",
63
+ stripe: "https://dashboard.stripe.com/apikeys",
64
+ lemonSqueezy: "https://app.lemonsqueezy.com/settings/api",
65
+ paddle: "https://vendors.paddle.com/authentication-v2"
66
+ };
67
+ /**
68
+ * Where a human goes for these credentials, and where the same human replaces them.
69
+ *
70
+ * **Five consoles, one `issuer` field.** Apple's `.p8`, Google's service-account key, Stripe's key pair,
71
+ * Lemon Squeezy's API key and Paddle's are each taken by hand from a different company's console, and they
72
+ * share one secret because they share one storage decision (see above) — not because they share an issuer.
73
+ * The axis holds a single name, so the honest one is `other`: *somebody issues this, and it is not one
74
+ * somebody.* Naming any single rail would be wrong for every deployment that does not sell through it.
75
+ *
76
+ * So the link is the one page that names all five rather than a rail's settings page. It has to *name*
77
+ * them: this constant pointed at the same document before #332 and the document listed no console at all,
78
+ * which cost the click and returned the reader to the search they started with. The section is fixed by
79
+ * name, and `registry.test.ts` reads the file off disk and fails if a rail's console is not in it.
80
+ *
81
+ * The day this bundle is split per rail — or `SecretOrigin` grows a destination per issuer — each half
82
+ * names its own console and this constant goes.
83
+ */
84
+ const PAYMENTS_CREDENTIALS_PAGE = "https://github.com/pithy-sh/pithy/blob/main/docs/commands/payments.md#where-each-rails-credentials-come-from";
85
+ const PaymentsAppleCredentials = z.strictObject({
86
+ bundleId: z.string().min(1).describe("The app's bundle id. Not a secret, but part of the app's identity at Apple: every notification and receipt is checked against it, because an Apple signature proves Apple signed the payload and never that it is about this app."),
87
+ keyId: z.string().min(1).describe("The App Store Connect API key id — the `kid` of the token that calls the App Store Server API."),
88
+ issuerId: z.string().min(1).describe("The App Store Connect issuer id, from the Keys page. The `iss` of that same token."),
89
+ privateKey: z.string().min(1).describe("The App Store Connect private key, the `.p8` file's contents including its PEM header and footer. Downloadable exactly once from App Store Connect, so it is supplied rather than minted.")
90
+ }).describe("Apple's credentials: the app's identity, and the App Store Connect key that signs server-API calls.");
91
+ const PaymentsGoogleCredentials = z.strictObject({
92
+ packageName: z.string().min(1).describe("The Android application id. What a Play purchase token is looked up against, and the equivalent of Apple's bundle id."),
93
+ serviceAccountEmail: z.string().min(1).describe("The Google Cloud service account that reads the Play Developer API and is the audience of the Pub/Sub push token."),
94
+ privateKey: z.string().min(1).describe("The service account's private key, as the downloaded JSON's `private_key` field. Supplied, never minted."),
95
+ pubsubAudience: z.string().min(1).describe("The audience the Pub/Sub push OIDC token must claim. Checked on every notification: a token with the right signature and the wrong audience is one issued for somebody else's endpoint.")
96
+ }).describe("Google's credentials: the app's identity, the Play Developer API service account, and the push audience.");
97
+ const PaymentsStripeCredentials = z.strictObject({
98
+ secretKey: z.string().min(1).describe("The Stripe secret API key — `sk_live_…` or `sk_test_…`. Creates Checkout and Billing Portal sessions."),
99
+ webhookSecret: z.string().min(1).describe("The webhook endpoint's signing secret — `whsec_…`. What the `Stripe-Signature` HMAC is checked against, and the one Stripe rotates.")
100
+ }).describe("Stripe's credentials: the secret key that creates hosted sessions, and the webhook signing secret.");
101
+ const PaymentsLemonSqueezyCredentials = z.strictObject({
102
+ apiKey: z.string().min(1).describe("The Lemon Squeezy API key. Creates hosted checkouts, reads orders and subscriptions, and mints customer-portal links. Account-wide: it returns test-mode objects to a production deployment too, which is why `test_mode` on the object — never the key — decides a purchase's environment."),
103
+ webhookSecret: z.string().min(1).describe("The webhook's signing secret, set when the webhook is created. What the `X-Signature` HMAC-SHA256 over the exact received body is checked against."),
104
+ storeId: z.string().min(1).describe("The Lemon Squeezy store id this deployment sells through. Account-level identity, the way Apple's `bundleId` is, which is why it sits with the credentials rather than in config.")
105
+ }).describe("Lemon Squeezy's credentials: the API key, the webhook signing secret, and the store's identity.");
106
+ const PaymentsPaddleCredentials = z.strictObject({
107
+ apiKey: z.string().min(1).describe("The Paddle API key — `pdl_live_apikey_…` or `pdl_sdbx_apikey_…`. Creates transactions and discounts, reads subscriptions and the event stream, and mints customer-portal sessions. It needs `customer_portal_session.write`, or Paddle returns a portal session with no authenticated URLs and the buyer lands on a sign-in page."),
108
+ webhookSecret: z.string().min(1).describe("The notification destination's signing secret — `pdl_ntfset_…`. What the `Paddle-Signature` HMAC-SHA256 over `ts:body` is checked against, and the key the checkout's ownership proof is domain-separated under.")
109
+ }).describe("Paddle's credentials: the API key, and the notification destination's signing secret. The client token is not here — it is publishable by design and lives in config, because putting it behind the secrets store would suggest verification depended on its secrecy.");
110
+ const PaymentsProviderCredentials = z.strictObject({
111
+ apple: PaymentsAppleCredentials.optional().describe("Apple's credentials, when the Apple rail is enabled."),
112
+ google: PaymentsGoogleCredentials.optional().describe("Google's credentials, when the Google rail is enabled."),
113
+ stripe: PaymentsStripeCredentials.optional().describe("Stripe's credentials, when the Stripe rail is enabled."),
114
+ lemonSqueezy: PaymentsLemonSqueezyCredentials.optional().describe("Lemon Squeezy's credentials, when that rail is enabled."),
115
+ paddle: PaymentsPaddleCredentials.optional().describe("Paddle's credentials, when the Paddle rail is enabled.")
116
+ }).describe("Every enabled rail's credentials, in one secret. A rail's block is present in full or absent entirely — adding a rail never reshapes storage.");
117
+ /** Payments' secret-registry slice, aggregated into the shared accessor at worker startup. */
118
+ const paymentsSecretsRegistry = defineSecretRegistry({ [PAYMENTS_PROVIDER_SECRET]: {
119
+ backend: "d1",
120
+ scope: "environment",
121
+ rotatable: true,
122
+ valueType: "json",
123
+ schema: PaymentsProviderCredentials,
124
+ origin: {
125
+ kind: "obtained",
126
+ issuer: "other",
127
+ documentation: PAYMENTS_CREDENTIALS_PAGE
128
+ },
129
+ rotation: {
130
+ kind: "manual",
131
+ issuer: "other",
132
+ documentation: PAYMENTS_CREDENTIALS_PAGE
133
+ }
134
+ } });
135
+ /**
136
+ * The credentials for one rail, or a refusal.
137
+ *
138
+ * A rail enabled in `pithy.config.ts` whose credentials were never provisioned is a 404, not a 500: from the
139
+ * caller's side that payment method genuinely is not available here, and telling a client which of config or
140
+ * provisioning is missing tells it about our deployment. `detail` carries the distinction for the operator.
141
+ *
142
+ * `action` carries the console. Which rail is missing is known here, so the one page out of five that
143
+ * answers "where do I get one" is known here too — and this is the moment the question is being asked.
144
+ */
145
+ function railCredentials(credentials, rail) {
146
+ const block = credentials[rail];
147
+ if (!block) throw new PaymentsRailNotConfiguredError({
148
+ detail: `The ${rail} rail has no credentials in "${PAYMENTS_PROVIDER_SECRET}" for this environment. Run \`pithy secrets set\` for it.`,
149
+ action: `Take the ${rail} credentials from ${PAYMENTS_RAIL_CONSOLES[rail]} and set them with \`pithy secrets set ${PAYMENTS_PROVIDER_SECRET}\`.`
150
+ });
151
+ return block;
152
+ }
153
+ //#endregion
154
+ export { PAYMENTS_CREDENTIALS_PAGE, PAYMENTS_PROVIDER_SECRET, PAYMENTS_RAIL_CONSOLES, PaymentsAppleCredentials, PaymentsGoogleCredentials, PaymentsLemonSqueezyCredentials, PaymentsPaddleCredentials, PaymentsProviderCredentials, PaymentsStripeCredentials, paymentsSecretsRegistry, railCredentials };
@@ -0,0 +1,3 @@
1
+ import { type SeedSet } from "@pithy-sh/core/src/seed/seed";
2
+ export declare const paymentsExampleSeed: SeedSet;
3
+ //# sourceMappingURL=example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../src/seeds/example.ts"],"names":[],"mappings":"AAIA,OAAO,EAA2B,KAAK,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAgErF,eAAO,MAAM,mBAAmB,EAAE,OAgHhC,CAAC"}
@@ -0,0 +1,171 @@
1
+ import { PaymentsEntitlement } from "../data/entitlement.js";
2
+ import { PaymentsPurchase } from "../data/purchase.js";
3
+ import { PAYMENTS_ENTITLEMENTS_TABLE, PAYMENTS_PURCHASES_TABLE } from "../data/tables.js";
4
+ import { EXAMPLE_ADA, EXAMPLE_ALAN, EXAMPLE_GRACE } from "@pithy-sh/core/src/seed/exampleIdentities";
5
+ import { d1SeedGroup, defineSeed } from "@pithy-sh/core/src/seed/seed";
6
+ //#region src/seeds/example.ts
7
+ /**
8
+ * Three purchases and the entitlements they derive, for the canonical example cast.
9
+ *
10
+ * The set is spread deliberately rather than repeated: **Ada** holds a live Apple subscription, **Grace**
11
+ * a Stripe non-consumable she owns forever, **Alan** a refunded Google consumable. That is one row per
12
+ * rail, one per product type, and the three purchase states anything reading this table has to handle —
13
+ * so a fresh `dev` backend can render a real subscription screen, a real receipt, and a real refund
14
+ * without anybody authoring a fixture first.
15
+ *
16
+ * The users are the shared cast from `@pithy-sh/core`, so these purchases belong to the same people
17
+ * `auth` seeds and `ledger` opens balances for. Order 250 puts them after auth's users (100), exactly the
18
+ * way the migration registry encodes a dependency.
19
+ *
20
+ * **Every row is a `user` subject, and a project on `billingSubject: "organization"` gets rows that
21
+ * resolve for nobody.** That is honest rather than a bug. The shared cast is three people; the kit has no
22
+ * example organization, and inventing one here would mint an id nothing else joins to — no `auth` row, no
23
+ * membership, nothing the adopter's own subject seam would ever return. So the fixture shows the shape of
24
+ * the tables and the states a reader must handle, and under organization billing the only real subjects
25
+ * are the adopter's own. Pinning it to `EXAMPLE_ADA/GRACE/ALAN` is what keeps the set idempotent and
26
+ * connected; a fabricated organization would be neither.
27
+ *
28
+ * **Everything is fixed — the ids and the clock.** `pithy seed` is `INSERT OR IGNORE`, so a generated
29
+ * UUID would give Ada a second subscription on every run. A fixed `CREATED_AT` does the same job for the
30
+ * timestamps.
31
+ *
32
+ * **No payloads worth the name.** The `payload` column really holds a verified provider response, and a
33
+ * real one is a bearer artifact. A committed fixture gets an identifier and nothing else.
34
+ *
35
+ * Composed in only when the project turns on `seed.includeExamples`, and only for `dev` and `staging` —
36
+ * an example fixture never targets production, whatever that setting says.
37
+ */
38
+ /** Where this set sorts in the whole project's seed registry. After auth (100), which owns these users. */
39
+ const PAYMENTS_EXAMPLE_SEED_ORDER = 250;
40
+ /** Fixed ids, so the fixture is idempotent and an entitlement's provenance cannot drift off its purchase. */
41
+ const PRO_PURCHASE_ID = "b4e1f2a0-6c3d-4f18-9a52-1d7e8c0b3f41";
42
+ const ADS_PURCHASE_ID = "c5f2a3b1-7d4e-4a29-8b63-2e8f9d1c4a52";
43
+ const COINS_PURCHASE_ID = "d6a3b4c2-8e5f-4b3a-9c74-3f9a0e2d5b63";
44
+ const PRO_ENTITLEMENT_ID = "e7b4c5d3-9f60-4c4b-8d85-4a0b1f3e6c74";
45
+ const ADS_ENTITLEMENT_ID = "f8c5d6e4-a071-4d5c-9e96-5b1c2a4f7d85";
46
+ /** One fixed moment every row was written at. The demo is about state, not about a calendar. */
47
+ const CREATED_AT = /* @__PURE__ */ new Date("2026-01-01T00:00:00.000Z");
48
+ /**
49
+ * When Ada's subscription runs to.
50
+ *
51
+ * Deliberately far out rather than `now + 30 days`. A computed date would make the fixture depend on when
52
+ * it ran, which breaks the one property that matters — that re-seeding writes identical rows — and the
53
+ * read path evaluates `expiresAt` on every request, so a date in the past would quietly turn the live
54
+ * subscription into a lapsed one the day after somebody seeded it.
55
+ */
56
+ const RENEWS_AT = /* @__PURE__ */ new Date("2099-01-01T00:00:00.000Z");
57
+ /** When Alan asked for his money back. */
58
+ const REFUNDED_AT = /* @__PURE__ */ new Date("2026-01-08T00:00:00.000Z");
59
+ const paymentsExampleSeed = defineSeed({
60
+ name: "example",
61
+ order: PAYMENTS_EXAMPLE_SEED_ORDER,
62
+ environments: ["dev", "staging"],
63
+ example: true,
64
+ d1: [d1SeedGroup("app", PAYMENTS_PURCHASES_TABLE, PaymentsPurchase, [
65
+ {
66
+ id: PRO_PURCHASE_ID,
67
+ subjectType: "user",
68
+ subjectId: EXAMPLE_ADA.id,
69
+ rail: "apple",
70
+ role: "charge",
71
+ providerTransactionId: "2000000512345678",
72
+ productId: "pro_monthly",
73
+ providerProductId: "com.example.pro.monthly",
74
+ type: "subscription",
75
+ status: "active",
76
+ environment: "sandbox",
77
+ purchasedAt: CREATED_AT,
78
+ expiresAt: RENEWS_AT,
79
+ revokedAt: null,
80
+ resumesAt: null,
81
+ originalTransactionId: "2000000512345678",
82
+ amountMinor: 999,
83
+ currency: "USD",
84
+ providerEventAt: CREATED_AT,
85
+ payload: {
86
+ transactionId: "2000000512345678",
87
+ type: "Auto-Renewable Subscription"
88
+ },
89
+ createdAt: CREATED_AT,
90
+ updatedAt: CREATED_AT
91
+ },
92
+ {
93
+ id: ADS_PURCHASE_ID,
94
+ subjectType: "user",
95
+ subjectId: EXAMPLE_GRACE.id,
96
+ rail: "stripe",
97
+ role: "charge",
98
+ providerTransactionId: "pi_3ExampleRemoveAds",
99
+ productId: "remove_ads",
100
+ providerProductId: "price_example_remove_ads",
101
+ type: "non_consumable",
102
+ status: "active",
103
+ environment: "sandbox",
104
+ purchasedAt: CREATED_AT,
105
+ expiresAt: null,
106
+ revokedAt: null,
107
+ resumesAt: null,
108
+ originalTransactionId: null,
109
+ amountMinor: 299,
110
+ currency: "USD",
111
+ providerEventAt: CREATED_AT,
112
+ payload: {
113
+ id: "pi_3ExampleRemoveAds",
114
+ object: "payment_intent"
115
+ },
116
+ createdAt: CREATED_AT,
117
+ updatedAt: CREATED_AT
118
+ },
119
+ {
120
+ id: COINS_PURCHASE_ID,
121
+ subjectType: "user",
122
+ subjectId: EXAMPLE_ALAN.id,
123
+ rail: "google",
124
+ role: "charge",
125
+ providerTransactionId: "GPA.3300-0000-0000-00000",
126
+ productId: "coins_100",
127
+ providerProductId: "coins_100",
128
+ type: "consumable",
129
+ status: "refunded",
130
+ environment: "sandbox",
131
+ purchasedAt: CREATED_AT,
132
+ expiresAt: null,
133
+ revokedAt: REFUNDED_AT,
134
+ resumesAt: null,
135
+ originalTransactionId: null,
136
+ amountMinor: 199,
137
+ currency: "USD",
138
+ providerEventAt: REFUNDED_AT,
139
+ payload: {
140
+ orderId: "GPA.3300-0000-0000-00000",
141
+ purchaseState: 0
142
+ },
143
+ createdAt: CREATED_AT,
144
+ updatedAt: REFUNDED_AT
145
+ }
146
+ ]), d1SeedGroup("app", PAYMENTS_ENTITLEMENTS_TABLE, PaymentsEntitlement, [{
147
+ id: PRO_ENTITLEMENT_ID,
148
+ subjectType: "user",
149
+ subjectId: EXAMPLE_ADA.id,
150
+ entitlement: "pro",
151
+ active: true,
152
+ expiresAt: RENEWS_AT,
153
+ sourcePurchaseId: PRO_PURCHASE_ID,
154
+ manual: false,
155
+ createdAt: CREATED_AT,
156
+ updatedAt: CREATED_AT
157
+ }, {
158
+ id: ADS_ENTITLEMENT_ID,
159
+ subjectType: "user",
160
+ subjectId: EXAMPLE_GRACE.id,
161
+ entitlement: "ads_removed",
162
+ active: true,
163
+ expiresAt: null,
164
+ sourcePurchaseId: ADS_PURCHASE_ID,
165
+ manual: false,
166
+ createdAt: CREATED_AT,
167
+ updatedAt: CREATED_AT
168
+ }])]
169
+ });
170
+ //#endregion
171
+ export { paymentsExampleSeed };
@@ -0,0 +1,5 @@
1
+ /** This package's npm name — the join key against a release feed. */
2
+ export declare const PACKAGE_NAME = "@pithy-sh/payments";
3
+ /** This package's version, stamped from its own package.json at generation time. */
4
+ export declare const PACKAGE_VERSION = "0.1.3";
5
+ //# sourceMappingURL=version.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.generated.d.ts","sourceRoot":"","sources":["../src/version.generated.ts"],"names":[],"mappings":"AAWA,qEAAqE;AACrE,eAAO,MAAM,YAAY,uBAAuB,CAAC;AAEjD,oFAAoF;AACpF,eAAO,MAAM,eAAe,UAAU,CAAC"}
@@ -0,0 +1,7 @@
1
+ //#region src/version.generated.ts
2
+ /** This package's npm name — the join key against a release feed. */
3
+ const PACKAGE_NAME = "@pithy-sh/payments";
4
+ /** This package's version, stamped from its own package.json at generation time. */
5
+ const PACKAGE_VERSION = "0.1.3";
6
+ //#endregion
7
+ export { PACKAGE_NAME, PACKAGE_VERSION };