@unchainedshop/plugins 4.6.1 → 4.7.2

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 (327) hide show
  1. package/README.md +0 -2
  2. package/lib/delivery/post/adapter.d.ts +2 -0
  3. package/lib/delivery/{post.js → post/adapter.js} +2 -3
  4. package/lib/delivery/post/index.d.ts +4 -0
  5. package/lib/delivery/post/index.js +10 -0
  6. package/lib/delivery/send-message/adapter.d.ts +2 -0
  7. package/lib/delivery/{send-message.js → send-message/adapter.js} +2 -3
  8. package/lib/delivery/send-message/index.d.ts +4 -0
  9. package/lib/delivery/send-message/index.js +10 -0
  10. package/lib/delivery/stores/adapter.d.ts +2 -0
  11. package/lib/delivery/{stores.js → stores/adapter.js} +2 -3
  12. package/lib/delivery/stores/index.d.ts +4 -0
  13. package/lib/delivery/stores/index.js +10 -0
  14. package/lib/enrollments/licensed/adapter.d.ts +6 -0
  15. package/lib/enrollments/{licensed.js → licensed/adapter.js} +2 -3
  16. package/lib/enrollments/licensed/index.d.ts +4 -0
  17. package/lib/enrollments/licensed/index.js +10 -0
  18. package/lib/events/node-event-emitter.d.ts +3 -1
  19. package/lib/events/node-event-emitter.js +3 -3
  20. package/lib/files/gridfs/adapter.d.ts +2 -2
  21. package/lib/files/gridfs/adapter.js +2 -5
  22. package/lib/files/gridfs/api.d.ts +7 -0
  23. package/lib/files/gridfs/api.js +163 -0
  24. package/lib/files/gridfs/index.d.ts +5 -4
  25. package/lib/files/gridfs/index.js +30 -3
  26. package/lib/files/minio/adapter.d.ts +4 -0
  27. package/lib/files/minio/adapter.js +160 -0
  28. package/lib/files/minio/api.d.ts +2 -0
  29. package/lib/files/minio/api.js +41 -0
  30. package/lib/files/minio/index.d.ts +4 -5
  31. package/lib/files/minio/index.js +18 -157
  32. package/lib/files/temp-upload/api.d.ts +6 -0
  33. package/lib/files/temp-upload/api.js +49 -0
  34. package/lib/files/temp-upload/index.d.ts +3 -0
  35. package/lib/files/temp-upload/index.js +15 -0
  36. package/lib/filters/local-search/adapter.d.ts +2 -0
  37. package/lib/filters/{local-search.js → local-search/adapter.js} +2 -12
  38. package/lib/filters/local-search/index.d.ts +4 -0
  39. package/lib/filters/local-search/index.js +16 -0
  40. package/lib/filters/strict-equal/adapter.d.ts +2 -0
  41. package/lib/filters/{strict-equal.js → strict-equal/adapter.js} +2 -3
  42. package/lib/filters/strict-equal/index.d.ts +4 -0
  43. package/lib/filters/strict-equal/index.js +10 -0
  44. package/lib/payment/apple-iap/adapter.d.ts +2 -1
  45. package/lib/payment/apple-iap/adapter.js +2 -3
  46. package/lib/payment/apple-iap/api.d.ts +2 -0
  47. package/lib/payment/apple-iap/{handler-fastify.js → api.js} +47 -30
  48. package/lib/payment/apple-iap/index.d.ts +6 -4
  49. package/lib/payment/apple-iap/index.js +28 -3
  50. package/lib/payment/cryptopay/adapter.d.ts +2 -0
  51. package/lib/payment/cryptopay/{plugin.js → adapter.js} +2 -4
  52. package/lib/payment/cryptopay/api.d.ts +2 -0
  53. package/lib/payment/cryptopay/api.js +23 -0
  54. package/lib/payment/cryptopay/index.d.ts +5 -4
  55. package/lib/payment/cryptopay/index.js +31 -3
  56. package/lib/payment/datatrans-v2/adapter.d.ts +2 -0
  57. package/lib/payment/datatrans-v2/adapter.js +406 -0
  58. package/lib/payment/datatrans-v2/api.d.ts +2 -0
  59. package/lib/payment/datatrans-v2/api.js +108 -0
  60. package/lib/payment/datatrans-v2/index.d.ts +4 -1
  61. package/lib/payment/datatrans-v2/index.js +17 -400
  62. package/lib/payment/invoice/adapter.d.ts +2 -0
  63. package/lib/payment/{invoice.js → invoice/adapter.js} +2 -3
  64. package/lib/payment/invoice/index.d.ts +4 -0
  65. package/lib/payment/invoice/index.js +10 -0
  66. package/lib/payment/invoice-prepaid/adapter.d.ts +2 -0
  67. package/lib/payment/{invoice-prepaid.js → invoice-prepaid/adapter.js} +2 -3
  68. package/lib/payment/invoice-prepaid/index.d.ts +4 -0
  69. package/lib/payment/invoice-prepaid/index.js +10 -0
  70. package/lib/payment/payrexx/adapter.d.ts +2 -0
  71. package/lib/payment/payrexx/adapter.js +161 -0
  72. package/lib/payment/payrexx/api.d.ts +2 -0
  73. package/lib/payment/payrexx/api.js +97 -0
  74. package/lib/payment/payrexx/index.d.ts +4 -1
  75. package/lib/payment/payrexx/index.js +19 -158
  76. package/lib/payment/postfinance-checkout/adapter.d.ts +2 -0
  77. package/lib/payment/postfinance-checkout/adapter.js +189 -0
  78. package/lib/payment/postfinance-checkout/index.d.ts +5 -0
  79. package/lib/payment/postfinance-checkout/index.js +25 -186
  80. package/lib/payment/postfinance-checkout/webhook.d.ts +2 -0
  81. package/lib/payment/postfinance-checkout/webhook.js +48 -0
  82. package/lib/payment/saferpay/adapter.js +1 -2
  83. package/lib/payment/saferpay/index.d.ts +5 -4
  84. package/lib/payment/saferpay/index.js +29 -3
  85. package/lib/payment/saferpay/webhook.d.ts +2 -0
  86. package/lib/payment/saferpay/webhook.js +64 -0
  87. package/lib/payment/stripe/adapter.d.ts +2 -0
  88. package/lib/payment/stripe/adapter.js +121 -0
  89. package/lib/payment/stripe/api.d.ts +6 -0
  90. package/lib/payment/stripe/api.js +165 -0
  91. package/lib/payment/stripe/index.d.ts +4 -1
  92. package/lib/payment/stripe/index.js +22 -116
  93. package/lib/payment/stripe/stripe.js +2 -5
  94. package/lib/presets/all.d.ts +1 -70
  95. package/lib/presets/all.js +41 -27
  96. package/lib/presets/base.d.ts +1 -25
  97. package/lib/presets/base.js +56 -25
  98. package/lib/presets/countries/ch.d.ts +1 -2
  99. package/lib/presets/countries/ch.js +7 -2
  100. package/lib/presets/crypto.d.ts +3 -7
  101. package/lib/presets/crypto.js +18 -7
  102. package/lib/pricing/{delivery-swiss-tax.d.ts → delivery-swiss-tax/adapter.d.ts} +1 -0
  103. package/lib/pricing/{delivery-swiss-tax.js → delivery-swiss-tax/adapter.js} +4 -4
  104. package/lib/pricing/delivery-swiss-tax/index.d.ts +4 -0
  105. package/lib/pricing/delivery-swiss-tax/index.js +10 -0
  106. package/lib/pricing/{discount-100-off.d.ts → discount-100-off/adapter.d.ts} +1 -0
  107. package/lib/pricing/{discount-100-off.js → discount-100-off/adapter.js} +2 -2
  108. package/lib/pricing/discount-100-off/index.d.ts +4 -0
  109. package/lib/pricing/discount-100-off/index.js +10 -0
  110. package/lib/pricing/{discount-half-price-manual.d.ts → discount-half-price-manual/adapter.d.ts} +1 -0
  111. package/lib/pricing/{discount-half-price-manual.js → discount-half-price-manual/adapter.js} +2 -2
  112. package/lib/pricing/discount-half-price-manual/index.d.ts +4 -0
  113. package/lib/pricing/discount-half-price-manual/index.js +10 -0
  114. package/lib/pricing/{free-delivery.d.ts → free-delivery/adapter.d.ts} +1 -0
  115. package/lib/pricing/{free-delivery.js → free-delivery/adapter.js} +2 -2
  116. package/lib/pricing/free-delivery/index.d.ts +4 -0
  117. package/lib/pricing/free-delivery/index.js +10 -0
  118. package/lib/pricing/{free-payment.d.ts → free-payment/adapter.d.ts} +1 -0
  119. package/lib/pricing/{free-payment.js → free-payment/adapter.js} +2 -2
  120. package/lib/pricing/free-payment/index.d.ts +4 -0
  121. package/lib/pricing/free-payment/index.js +10 -0
  122. package/lib/pricing/{order-delivery.d.ts → order-delivery/adapter.d.ts} +1 -0
  123. package/lib/pricing/{order-delivery.js → order-delivery/adapter.js} +2 -2
  124. package/lib/pricing/order-delivery/index.d.ts +4 -0
  125. package/lib/pricing/order-delivery/index.js +10 -0
  126. package/lib/pricing/{order-discount.d.ts → order-discount/adapter.d.ts} +1 -0
  127. package/lib/pricing/{order-discount.js → order-discount/adapter.js} +2 -2
  128. package/lib/pricing/order-discount/index.d.ts +4 -0
  129. package/lib/pricing/order-discount/index.js +10 -0
  130. package/lib/pricing/{order-items.d.ts → order-items/adapter.d.ts} +1 -0
  131. package/lib/pricing/{order-items.js → order-items/adapter.js} +2 -2
  132. package/lib/pricing/order-items/index.d.ts +4 -0
  133. package/lib/pricing/order-items/index.js +10 -0
  134. package/lib/pricing/{order-payment.d.ts → order-payment/adapter.d.ts} +1 -0
  135. package/lib/pricing/{order-payment.js → order-payment/adapter.js} +2 -2
  136. package/lib/pricing/order-payment/index.d.ts +4 -0
  137. package/lib/pricing/order-payment/index.js +10 -0
  138. package/lib/pricing/{product-catalog-price.d.ts → product-catalog-price/adapter.d.ts} +1 -0
  139. package/lib/pricing/{product-catalog-price.js → product-catalog-price/adapter.js} +2 -2
  140. package/lib/pricing/product-catalog-price/index.d.ts +4 -0
  141. package/lib/pricing/product-catalog-price/index.js +10 -0
  142. package/lib/pricing/{product-discount.d.ts → product-discount/adapter.d.ts} +1 -0
  143. package/lib/pricing/{product-discount.js → product-discount/adapter.js} +2 -2
  144. package/lib/pricing/product-discount/index.d.ts +4 -0
  145. package/lib/pricing/product-discount/index.js +10 -0
  146. package/lib/pricing/{product-price-rateconversion.d.ts → product-price-rateconversion/adapter.d.ts} +1 -0
  147. package/lib/pricing/{product-price-rateconversion.js → product-price-rateconversion/adapter.js} +2 -2
  148. package/lib/pricing/product-price-rateconversion/index.d.ts +4 -0
  149. package/lib/pricing/product-price-rateconversion/index.js +10 -0
  150. package/lib/pricing/{product-swiss-tax.d.ts → product-swiss-tax/adapter.d.ts} +1 -0
  151. package/lib/pricing/{product-swiss-tax.js → product-swiss-tax/adapter.js} +4 -4
  152. package/lib/pricing/product-swiss-tax/index.d.ts +4 -0
  153. package/lib/pricing/product-swiss-tax/index.js +10 -0
  154. package/lib/quotations/manual/adapter.d.ts +2 -0
  155. package/lib/quotations/{manual.js → manual/adapter.js} +2 -3
  156. package/lib/quotations/manual/index.d.ts +4 -0
  157. package/lib/quotations/manual/index.js +10 -0
  158. package/lib/warehousing/erc-metadata/api.d.ts +12 -0
  159. package/lib/warehousing/erc-metadata/api.js +43 -0
  160. package/lib/warehousing/erc-metadata/index.d.ts +3 -0
  161. package/lib/warehousing/erc-metadata/index.js +15 -0
  162. package/lib/warehousing/eth-minter/adapter.d.ts +2 -0
  163. package/lib/warehousing/{eth-minter.js → eth-minter/adapter.js} +3 -4
  164. package/lib/warehousing/eth-minter/index.d.ts +4 -0
  165. package/lib/warehousing/eth-minter/index.js +10 -0
  166. package/lib/warehousing/store/adapter.d.ts +2 -0
  167. package/lib/warehousing/{store.js → store/adapter.js} +2 -3
  168. package/lib/warehousing/store/index.d.ts +4 -0
  169. package/lib/warehousing/store/index.js +10 -0
  170. package/lib/worker/budgetsms/adapter.d.ts +22 -0
  171. package/lib/worker/{budgetsms.js → budgetsms/adapter.js} +3 -3
  172. package/lib/worker/budgetsms/index.d.ts +4 -0
  173. package/lib/worker/budgetsms/index.js +10 -0
  174. package/lib/worker/bulk-export/adapter.d.ts +3 -0
  175. package/lib/worker/{bulk-export.js → bulk-export/adapter.js} +3 -3
  176. package/lib/worker/bulk-export/index.d.ts +4 -0
  177. package/lib/worker/bulk-export/index.js +10 -0
  178. package/lib/worker/{bulk-import.d.ts → bulk-import/adapter.d.ts} +1 -0
  179. package/lib/worker/{bulk-import.js → bulk-import/adapter.js} +2 -2
  180. package/lib/worker/bulk-import/api.d.ts +7 -0
  181. package/lib/worker/bulk-import/api.js +53 -0
  182. package/lib/worker/bulk-import/index.d.ts +4 -0
  183. package/lib/worker/bulk-import/index.js +18 -0
  184. package/lib/worker/bulkgate/adapter.d.ts +12 -0
  185. package/lib/worker/{bulkgate.js → bulkgate/adapter.js} +3 -3
  186. package/lib/worker/bulkgate/index.d.ts +4 -0
  187. package/lib/worker/bulkgate/index.js +10 -0
  188. package/lib/worker/email/adapter.d.ts +9 -0
  189. package/lib/worker/{email.js → email/adapter.js} +27 -13
  190. package/lib/worker/email/index.d.ts +4 -0
  191. package/lib/worker/email/index.js +10 -0
  192. package/lib/worker/enrollment-order-generator/adapter.d.ts +4 -0
  193. package/lib/worker/{enrollment-order-generator.js → enrollment-order-generator/adapter.js} +2 -2
  194. package/lib/worker/enrollment-order-generator/index.d.ts +4 -0
  195. package/lib/worker/enrollment-order-generator/index.js +13 -0
  196. package/lib/worker/{error-notifications.d.ts → error-notifications/adapter.d.ts} +1 -0
  197. package/lib/worker/{error-notifications.js → error-notifications/adapter.js} +9 -8
  198. package/lib/worker/error-notifications/index.d.ts +4 -0
  199. package/lib/worker/error-notifications/index.js +13 -0
  200. package/lib/worker/{export-token.d.ts → export-token/adapter.d.ts} +1 -1
  201. package/lib/worker/{export-token.js → export-token/adapter.js} +2 -3
  202. package/lib/worker/export-token/index.d.ts +4 -0
  203. package/lib/worker/export-token/index.js +13 -0
  204. package/lib/worker/{external.d.ts → external/adapter.d.ts} +1 -0
  205. package/lib/worker/{external.js → external/adapter.js} +2 -2
  206. package/lib/worker/external/index.d.ts +4 -0
  207. package/lib/worker/external/index.js +10 -0
  208. package/lib/worker/heartbeat/adapter.d.ts +8 -0
  209. package/lib/worker/{heartbeat.js → heartbeat/adapter.js} +3 -3
  210. package/lib/worker/heartbeat/index.d.ts +4 -0
  211. package/lib/worker/heartbeat/index.js +10 -0
  212. package/lib/worker/{http-request.d.ts → http-request/adapter.d.ts} +1 -1
  213. package/lib/worker/{http-request.js → http-request/adapter.js} +2 -3
  214. package/lib/worker/http-request/index.d.ts +4 -0
  215. package/lib/worker/http-request/index.js +10 -0
  216. package/lib/worker/{message.d.ts → message/adapter.d.ts} +1 -0
  217. package/lib/worker/{message.js → message/adapter.js} +2 -2
  218. package/lib/worker/message/index.d.ts +4 -0
  219. package/lib/worker/message/index.js +10 -0
  220. package/lib/worker/push-notification/adapter.d.ts +9 -0
  221. package/lib/worker/{push-notification.js → push-notification/adapter.js} +3 -3
  222. package/lib/worker/push-notification/index.d.ts +4 -0
  223. package/lib/worker/push-notification/index.js +10 -0
  224. package/lib/worker/twilio/adapter.d.ts +8 -0
  225. package/lib/worker/{twilio.js → twilio/adapter.js} +3 -3
  226. package/lib/worker/twilio/index.d.ts +4 -0
  227. package/lib/worker/twilio/index.js +10 -0
  228. package/lib/worker/update-coinbase-rates/adapter.d.ts +4 -0
  229. package/lib/worker/{update-coinbase-rates.js → update-coinbase-rates/adapter.js} +8 -6
  230. package/lib/worker/update-coinbase-rates/index.d.ts +4 -0
  231. package/lib/worker/update-coinbase-rates/index.js +13 -0
  232. package/lib/worker/update-ecb-rates/adapter.d.ts +4 -0
  233. package/lib/worker/{update-ecb-rates.js → update-ecb-rates/adapter.js} +11 -9
  234. package/lib/worker/update-ecb-rates/index.d.ts +4 -0
  235. package/lib/worker/update-ecb-rates/index.js +13 -0
  236. package/lib/worker/{update-token-ownership.d.ts → update-token-ownership/adapter.d.ts} +2 -0
  237. package/lib/worker/{update-token-ownership.js → update-token-ownership/adapter.js} +8 -7
  238. package/lib/worker/update-token-ownership/index.d.ts +4 -0
  239. package/lib/worker/update-token-ownership/index.js +13 -0
  240. package/lib/worker/{zombie-killer.js → zombie-killer/adapter.js} +1 -2
  241. package/lib/worker/zombie-killer/index.d.ts +4 -0
  242. package/lib/worker/zombie-killer/index.js +10 -0
  243. package/package.json +15 -10
  244. package/lib/delivery/post.d.ts +0 -1
  245. package/lib/delivery/send-message.d.ts +0 -1
  246. package/lib/delivery/stores.d.ts +0 -1
  247. package/lib/enrollments/licensed.d.ts +0 -4
  248. package/lib/files/gridfs/handler-express.d.ts +0 -9
  249. package/lib/files/gridfs/handler-express.js +0 -110
  250. package/lib/files/gridfs/handler-fastify.d.ts +0 -3
  251. package/lib/files/gridfs/handler-fastify.js +0 -138
  252. package/lib/files/minio/handler-express.d.ts +0 -2
  253. package/lib/files/minio/handler-express.js +0 -36
  254. package/lib/files/minio/handler-fastify.d.ts +0 -3
  255. package/lib/files/minio/handler-fastify.js +0 -40
  256. package/lib/filters/local-search.d.ts +0 -3
  257. package/lib/filters/strict-equal.d.ts +0 -1
  258. package/lib/payment/apple-iap/handler-express.d.ts +0 -2
  259. package/lib/payment/apple-iap/handler-express.js +0 -103
  260. package/lib/payment/apple-iap/handler-fastify.d.ts +0 -3
  261. package/lib/payment/braintree.d.ts +0 -1
  262. package/lib/payment/braintree.js +0 -138
  263. package/lib/payment/cryptopay/handler-express.d.ts +0 -2
  264. package/lib/payment/cryptopay/handler-express.js +0 -19
  265. package/lib/payment/cryptopay/handler-fastify.d.ts +0 -3
  266. package/lib/payment/cryptopay/handler-fastify.js +0 -17
  267. package/lib/payment/cryptopay/plugin.d.ts +0 -3
  268. package/lib/payment/datatrans-v2/handler-express.d.ts +0 -1
  269. package/lib/payment/datatrans-v2/handler-express.js +0 -71
  270. package/lib/payment/datatrans-v2/handler-fastify.d.ts +0 -2
  271. package/lib/payment/datatrans-v2/handler-fastify.js +0 -71
  272. package/lib/payment/invoice-prepaid.d.ts +0 -1
  273. package/lib/payment/invoice.d.ts +0 -1
  274. package/lib/payment/paypal-checkout.d.ts +0 -1
  275. package/lib/payment/paypal-checkout.js +0 -87
  276. package/lib/payment/payrexx/handler-express.d.ts +0 -1
  277. package/lib/payment/payrexx/handler-express.js +0 -85
  278. package/lib/payment/payrexx/handler-fastify.d.ts +0 -2
  279. package/lib/payment/payrexx/handler-fastify.js +0 -91
  280. package/lib/payment/postfinance-checkout/handler-express.d.ts +0 -1
  281. package/lib/payment/postfinance-checkout/handler-express.js +0 -37
  282. package/lib/payment/postfinance-checkout/handler-fastify.d.ts +0 -2
  283. package/lib/payment/postfinance-checkout/handler-fastify.js +0 -40
  284. package/lib/payment/saferpay/handler-express.d.ts +0 -1
  285. package/lib/payment/saferpay/handler-express.js +0 -59
  286. package/lib/payment/saferpay/handler-fastify.d.ts +0 -2
  287. package/lib/payment/saferpay/handler-fastify.js +0 -62
  288. package/lib/payment/stripe/handler-express.d.ts +0 -5
  289. package/lib/payment/stripe/handler-express.js +0 -121
  290. package/lib/payment/stripe/handler-fastify.d.ts +0 -6
  291. package/lib/payment/stripe/handler-fastify.js +0 -131
  292. package/lib/presets/all-express.d.ts +0 -6
  293. package/lib/presets/all-express.js +0 -26
  294. package/lib/presets/all-fastify.d.ts +0 -6
  295. package/lib/presets/all-fastify.js +0 -49
  296. package/lib/presets/base-express.d.ts +0 -2
  297. package/lib/presets/base-express.js +0 -5
  298. package/lib/presets/base-fastify.d.ts +0 -3
  299. package/lib/presets/base-fastify.js +0 -16
  300. package/lib/presets/crypto-express.d.ts +0 -3
  301. package/lib/presets/crypto-express.js +0 -8
  302. package/lib/presets/crypto-fastify.d.ts +0 -3
  303. package/lib/presets/crypto-fastify.js +0 -11
  304. package/lib/pricing/discount-half-price.d.ts +0 -2
  305. package/lib/pricing/discount-half-price.js +0 -33
  306. package/lib/pricing/order-items-discount.d.ts +0 -2
  307. package/lib/pricing/order-items-discount.js +0 -50
  308. package/lib/pricing/order-round.d.ts +0 -10
  309. package/lib/pricing/order-round.js +0 -135
  310. package/lib/pricing/product-catalog-price-options.d.ts +0 -2
  311. package/lib/pricing/product-catalog-price-options.js +0 -51
  312. package/lib/pricing/product-round.d.ts +0 -10
  313. package/lib/pricing/product-round.js +0 -44
  314. package/lib/quotations/manual.d.ts +0 -1
  315. package/lib/warehousing/eth-minter.d.ts +0 -1
  316. package/lib/warehousing/store.d.ts +0 -1
  317. package/lib/worker/budgetsms.d.ts +0 -9
  318. package/lib/worker/bulk-export.d.ts +0 -2
  319. package/lib/worker/bulkgate.d.ts +0 -1
  320. package/lib/worker/email.d.ts +0 -1
  321. package/lib/worker/enrollment-order-generator.d.ts +0 -1
  322. package/lib/worker/heartbeat.d.ts +0 -1
  323. package/lib/worker/push-notification.d.ts +0 -1
  324. package/lib/worker/twilio.d.ts +0 -1
  325. package/lib/worker/update-coinbase-rates.d.ts +0 -1
  326. package/lib/worker/update-ecb-rates.d.ts +0 -1
  327. /package/lib/worker/{zombie-killer.d.ts → zombie-killer/adapter.d.ts} +0 -0
@@ -1,138 +0,0 @@
1
- import { finished, pipeline } from 'node:stream/promises';
2
- import { PassThrough } from 'node:stream';
3
- import {} from 'fastify';
4
- import { buildHashedFilename } from '@unchainedshop/file-upload';
5
- import sign from "./sign.js";
6
- import {} from "./module.js";
7
- import {} from '@unchainedshop/api';
8
- import { createLogger } from '@unchainedshop/logger';
9
- import { getFileAdapter } from '@unchainedshop/core-files';
10
- import { timingSafeStringEqual } from '@unchainedshop/utils';
11
- const logger = createLogger('unchained:gridfs');
12
- const { GRIDFS_PUT_SERVER_PATH = '/gridfs' } = process.env;
13
- const gridfsHandler = async (req, reply) => {
14
- try {
15
- const { services, modules } = req.unchainedContext;
16
- const { directoryName, fileName } = req.params;
17
- reply.header('Access-Control-Allow-Methods', 'GET, PUT');
18
- reply.header('Access-Control-Allow-Headers', 'content-type');
19
- reply.header('Access-Control-Allow-Origin', '*');
20
- if (req.method === 'OPTIONS') {
21
- reply.status(200);
22
- return reply.send();
23
- }
24
- if (req.method === 'PUT') {
25
- const { s: signature, e: expiryTimestamp } = req.query;
26
- const expiryDate = new Date(parseInt(expiryTimestamp, 10));
27
- const fileId = await buildHashedFilename(directoryName, fileName, expiryDate);
28
- const expectedSignature = await sign(directoryName, fileId, expiryDate.getTime());
29
- if (await timingSafeStringEqual(expectedSignature, signature)) {
30
- const file = await modules.files.findFile({ fileId });
31
- if (!file) {
32
- reply.status(404);
33
- logger.error('File not found', { fileId });
34
- return reply.send({
35
- success: false,
36
- message: 'File not found',
37
- name: 'FILE_NOT_FOUND',
38
- });
39
- }
40
- if (file.expires === null) {
41
- reply.status(400);
42
- logger.error('File already linked', { fileId });
43
- return reply.send({
44
- success: false,
45
- message: 'File already linked',
46
- name: 'FILE_ALREADY_LINKED',
47
- });
48
- }
49
- const type = req.headers['content-type'] === 'application/octet-stream'
50
- ? file.type || req.headers['content-type']
51
- : req.headers['content-type'] || file.type;
52
- const writeStream = await modules.gridfsFileUploads.createWriteStream(directoryName, fileId, fileName, {
53
- chunkSizeBytes: 1024 * 1024,
54
- metadata: { 'content-type': type },
55
- });
56
- await pipeline(req.raw, new PassThrough({ highWaterMark: 1024 * 1024 * 4 }), writeStream);
57
- await finished(writeStream, { readable: false });
58
- const { length } = writeStream;
59
- await services.files.linkFile({ fileId, size: length, type });
60
- reply.status(200);
61
- return reply.send({
62
- success: true,
63
- fileId,
64
- size: length,
65
- type,
66
- });
67
- }
68
- logger.error('Invalid signature', { fileId, expiryDate });
69
- reply.status(403);
70
- return reply.send({
71
- success: false,
72
- message: 'Access restricted: Invalid signature.',
73
- name: 'INVALID_SIGNATURE',
74
- });
75
- }
76
- if (req.method === 'GET') {
77
- const { s: signature, e: expiryTimestamp } = req.query;
78
- const fileDocument = await modules.files.findFile({
79
- url: `${GRIDFS_PUT_SERVER_PATH}/${directoryName}/${fileName}`,
80
- });
81
- if (fileDocument?.meta?.isPrivate) {
82
- const expiry = parseInt(expiryTimestamp, 10);
83
- if (expiry <= Date.now()) {
84
- logger.error('URL Expired', { fileName, expiry });
85
- reply.status(403);
86
- return reply.send({
87
- success: false,
88
- message: 'Access restricted: URL expired.',
89
- name: 'URL_EXPIRED',
90
- });
91
- }
92
- const fileUploadAdapter = getFileAdapter();
93
- const signedUrl = await fileUploadAdapter.createDownloadURL(fileDocument, expiry);
94
- const expectedSignature = signedUrl ? new URL(signedUrl, 'file://').searchParams.get('s') : null;
95
- if (!signedUrl ||
96
- !expectedSignature ||
97
- !(await timingSafeStringEqual(expectedSignature, signature))) {
98
- reply.status(403);
99
- logger.error('Invalid signature', { fileName, expiry });
100
- return reply.send({
101
- success: false,
102
- message: 'Access restricted: Invalid signature.',
103
- name: 'INVALID_SIGNATURE',
104
- });
105
- }
106
- }
107
- else if (!fileDocument) {
108
- logger.error('File not found', { fileName });
109
- reply.status(404);
110
- return reply.send();
111
- }
112
- const file = await modules.gridfsFileUploads.getFileInfo(directoryName, fileDocument._id);
113
- if (file?.metadata?.['content-type']) {
114
- reply.header('content-type', file.metadata['content-type']);
115
- }
116
- if (file?.length) {
117
- reply.header('content-length', file?.length.toString());
118
- }
119
- const readStream = await modules.gridfsFileUploads.createReadStream(directoryName, fileDocument._id);
120
- reply.status(200);
121
- return reply.send(readStream);
122
- }
123
- reply.status(404);
124
- return reply.send();
125
- }
126
- catch (e) {
127
- logger.error(e);
128
- if (e.code === 'ENOENT') {
129
- reply.status(404);
130
- return reply.send();
131
- }
132
- else {
133
- reply.status(504);
134
- return reply.send({ success: false, name: e.name, code: e.code, message: e.message });
135
- }
136
- }
137
- };
138
- export default gridfsHandler;
@@ -1,2 +0,0 @@
1
- declare const minioHandler: (req: any, res: any) => Promise<void>;
2
- export default minioHandler;
@@ -1,36 +0,0 @@
1
- import { createLogger } from '@unchainedshop/logger';
2
- import { timingSafeStringEqual } from '@unchainedshop/utils';
3
- const logger = createLogger('unchained:minio');
4
- const { MINIO_WEBHOOK_AUTH_TOKEN } = process.env;
5
- const isAuthorized = async ({ authorization = '' }) => {
6
- if (!MINIO_WEBHOOK_AUTH_TOKEN)
7
- return false;
8
- const [type, token] = authorization.split(' ');
9
- if (type !== 'Bearer' || !token)
10
- return false;
11
- return timingSafeStringEqual(token, MINIO_WEBHOOK_AUTH_TOKEN);
12
- };
13
- const minioHandler = async (req, res) => {
14
- try {
15
- if (req.method === 'POST' && req.body) {
16
- const { headers } = req;
17
- const { Records = [], EventName } = req.body;
18
- if (EventName === 's3:ObjectCreated:Put' && (await isAuthorized(headers))) {
19
- const [{ s3 }] = Records;
20
- const { object } = s3;
21
- const { size, contentType: type } = object;
22
- const [fileId] = object.key.split('.');
23
- const { services } = req.unchainedContext;
24
- await services.files.linkFile({ fileId, type, size });
25
- res.status(200).end();
26
- return;
27
- }
28
- }
29
- res.status(404).end();
30
- }
31
- catch (e) {
32
- logger.error(e);
33
- res.status(503).send({ name: e.name, code: e.code, message: e.message });
34
- }
35
- };
36
- export default minioHandler;
@@ -1,3 +0,0 @@
1
- import { type RouteHandlerMethod } from 'fastify';
2
- declare const minioHandler: RouteHandlerMethod;
3
- export default minioHandler;
@@ -1,40 +0,0 @@
1
- import {} from '@unchainedshop/api';
2
- import { createLogger } from '@unchainedshop/logger';
3
- import {} from 'fastify';
4
- import { timingSafeStringEqual } from '@unchainedshop/utils';
5
- const logger = createLogger('unchained:minio');
6
- const { MINIO_WEBHOOK_AUTH_TOKEN } = process.env;
7
- const isAuthorized = async ({ authorization = '' }) => {
8
- if (!MINIO_WEBHOOK_AUTH_TOKEN)
9
- return false;
10
- const [type, token] = authorization.split(' ');
11
- if (type !== 'Bearer' || !token)
12
- return false;
13
- return timingSafeStringEqual(token, MINIO_WEBHOOK_AUTH_TOKEN);
14
- };
15
- const minioHandler = async (req, res) => {
16
- try {
17
- if (req.body) {
18
- const { headers } = req;
19
- const { Records = [], EventName } = req.body;
20
- if (EventName === 's3:ObjectCreated:Put' && (await isAuthorized(headers))) {
21
- const [{ s3 }] = Records;
22
- const { object } = s3;
23
- const { size, contentType: type } = object;
24
- const [fileId] = object.key.split('.');
25
- const { services } = req.unchainedContext;
26
- await services.files.linkFile({ fileId, type, size });
27
- res.status(200);
28
- return res.send();
29
- }
30
- }
31
- res.status(404);
32
- return res.send();
33
- }
34
- catch (e) {
35
- logger.error(e);
36
- res.status(503);
37
- return res.send({ name: e.name, code: e.code, message: e.message });
38
- }
39
- };
40
- export default minioHandler;
@@ -1,3 +0,0 @@
1
- import { type IFilterAdapter } from '@unchainedshop/core';
2
- declare const LocalSearch: IFilterAdapter;
3
- export default LocalSearch;
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- export declare const appleIAPHandler: (req: any, res: any) => Promise<void>;
2
- export default appleIAPHandler;
@@ -1,103 +0,0 @@
1
- import {} from '@unchainedshop/api';
2
- import { EnrollmentStatus } from '@unchainedshop/core-enrollments';
3
- import { createLogger } from '@unchainedshop/logger';
4
- import { fixPeriods } from "./fix-periods.js";
5
- const logger = createLogger('unchained:apple-iap:handler');
6
- const { APPLE_IAP_SHARED_SECRET } = process.env;
7
- const AppleNotificationTypes = {
8
- INITIAL_BUY: 'INITIAL_BUY',
9
- DID_RECOVER: 'DID_RECOVER',
10
- DID_CHANGE_RENEWAL_STATUS: 'DID_CHANGE_RENEWAL_STATUS',
11
- DID_FAIL_TO_RENEW: 'DID_FAIL_TO_RENEW',
12
- DID_CHANGE_RENEWAL_PREF: 'DID_CHANGE_RENEWAL_PREF',
13
- };
14
- export const appleIAPHandler = async (req, res) => {
15
- if (req.method === 'POST') {
16
- try {
17
- const resolvedContext = req.unchainedContext;
18
- const { modules, services } = resolvedContext;
19
- const responseBody = req.body || {};
20
- if (responseBody.password !== APPLE_IAP_SHARED_SECRET) {
21
- throw new Error('shared secret not valid');
22
- }
23
- const transactions = responseBody?.unified_receipt?.latest_receipt_info;
24
- const latestTransaction = transactions[0];
25
- if (responseBody.notification_type === AppleNotificationTypes.INITIAL_BUY) {
26
- const orderPayment = await modules.orders.payments.findOrderPaymentByTransactionId(latestTransaction.transaction_id);
27
- if (!orderPayment)
28
- throw new Error('Could not find any matching order payment');
29
- const order = await services.orders.checkoutOrder(orderPayment.orderId, {
30
- paymentContext: {
31
- receiptData: responseBody?.unified_receipt?.latest_receipt,
32
- },
33
- });
34
- if (!order)
35
- throw new Error(`Order with id ${orderPayment.orderId} not found`);
36
- const orderId = order._id;
37
- const enrollment = await modules.enrollments.findEnrollment({
38
- orderId,
39
- });
40
- if (!enrollment)
41
- throw new Error('Could not find any matching enrollment');
42
- await fixPeriods({
43
- transactionId: latestTransaction.original_transaction_id,
44
- transactions,
45
- enrollmentId: enrollment._id,
46
- orderId,
47
- }, resolvedContext);
48
- logger.info(`Apple IAP Webhook: Confirmed checkout for order ${order.orderNumber}`, {
49
- orderId: order._id,
50
- });
51
- }
52
- else {
53
- const originalOrderPayment = await modules.orders.payments.findOrderPaymentByTransactionId(latestTransaction.original_transaction_id);
54
- if (!originalOrderPayment)
55
- throw new Error('Could not find any matching order payment');
56
- const originalOrder = await modules.orders.findOrder({
57
- orderId: originalOrderPayment.orderId,
58
- });
59
- const enrollment = originalOrder &&
60
- (await modules.enrollments.findEnrollment({
61
- orderId: originalOrder._id,
62
- }));
63
- if (!enrollment?.payment)
64
- throw new Error('Could not find a valid enrollment payment method');
65
- await services.orders.registerPaymentCredentials(enrollment.payment.paymentProviderId, {
66
- transactionContext: {
67
- receiptData: responseBody?.unified_receipt?.latest_receipt,
68
- },
69
- userId: enrollment.userId,
70
- });
71
- await fixPeriods({
72
- transactionId: latestTransaction.original_transaction_id,
73
- transactions,
74
- enrollmentId: enrollment._id,
75
- orderId: originalOrder._id,
76
- }, resolvedContext);
77
- logger.info(`Apple IAP Webhook: Processed notification for ${latestTransaction.original_transaction_id} and type ${responseBody.notification_type}`);
78
- if (responseBody.notification_type === AppleNotificationTypes.DID_RECOVER) {
79
- if (enrollment.status !== EnrollmentStatus.TERMINATED &&
80
- responseBody.auto_renew_status === 'false') {
81
- await services.enrollments.terminateEnrollment(enrollment);
82
- }
83
- }
84
- if (responseBody.notification_type === AppleNotificationTypes.DID_CHANGE_RENEWAL_STATUS) {
85
- if (enrollment.status !== EnrollmentStatus.TERMINATED &&
86
- responseBody.auto_renew_status === 'false') {
87
- await services.enrollments.terminateEnrollment(enrollment);
88
- }
89
- }
90
- logger.info(`Apple IAP Webhook: Updated enrollment from Apple`);
91
- }
92
- res.status(200).end();
93
- return;
94
- }
95
- catch (e) {
96
- logger.warn(`Apple IAP Webhook: ${e.name} - ${e.message}`);
97
- res.status(503).send({ name: e.name, code: e.code, message: e.message });
98
- return;
99
- }
100
- }
101
- res.status(404).end();
102
- };
103
- export default appleIAPHandler;
@@ -1,3 +0,0 @@
1
- import { type RouteHandlerMethod } from 'fastify';
2
- export declare const appleIAPHandler: RouteHandlerMethod;
3
- export default appleIAPHandler;
@@ -1 +0,0 @@
1
- export {};
@@ -1,138 +0,0 @@
1
- import { createLogger } from '@unchainedshop/logger';
2
- import { PaymentAdapter, PaymentDirector, PaymentError, OrderPricingSheet, } from '@unchainedshop/core';
3
- const logger = createLogger('unchained:braintree');
4
- const { BRAINTREE_SANDBOX_TOKEN, BRAINTREE_PRIVATE_KEY } = process.env;
5
- let braintree;
6
- try {
7
- const braintreePackage = await import('braintree');
8
- braintree = braintreePackage.default;
9
- }
10
- catch {
11
- logger.warn("npm dependency 'braintree' is not installed, paypal adapter will not work");
12
- }
13
- const BraintreeDirect = {
14
- ...PaymentAdapter,
15
- key: 'shop.unchained.braintree-direct',
16
- label: 'Braintree Direct',
17
- version: '1.0.0',
18
- initialConfiguration: [
19
- {
20
- key: 'publicKey',
21
- value: null,
22
- },
23
- {
24
- key: 'merchantId',
25
- value: null,
26
- },
27
- ],
28
- typeSupported: (type) => {
29
- return type === 'GENERIC';
30
- },
31
- actions: (config, context) => {
32
- const getPublicKey = () => {
33
- return config.reduce((current, item) => {
34
- if (item.key === 'publicKey')
35
- return item.value;
36
- return current;
37
- }, null);
38
- };
39
- const getMerchantId = () => {
40
- return config.reduce((current, item) => {
41
- if (item.key === 'merchantId')
42
- return item.value;
43
- return current;
44
- }, null);
45
- };
46
- const getAccessToken = () => {
47
- return BRAINTREE_SANDBOX_TOKEN;
48
- };
49
- const getPrivateKey = () => {
50
- return BRAINTREE_PRIVATE_KEY;
51
- };
52
- const getGateway = (braintree) => {
53
- const accessToken = getAccessToken();
54
- if (accessToken) {
55
- return braintree.connect({
56
- accessToken,
57
- });
58
- }
59
- return braintree.connect({
60
- environment: braintree.Environment.Production,
61
- merchantId: getMerchantId(),
62
- publicKey: getPublicKey(),
63
- privateKey: getPrivateKey(),
64
- });
65
- };
66
- const adapter = {
67
- ...PaymentAdapter.actions(config, context),
68
- configurationError: () => {
69
- const publicCredentialsValid = getAccessToken() || (getMerchantId() && getPublicKey() && getPrivateKey());
70
- if (!publicCredentialsValid) {
71
- return PaymentError.WRONG_CREDENTIALS;
72
- }
73
- return null;
74
- },
75
- isActive: () => {
76
- if (adapter.configurationError() === null)
77
- return true;
78
- return false;
79
- },
80
- isPayLaterAllowed: () => {
81
- return false;
82
- },
83
- sign: async () => {
84
- const gateway = getGateway(braintree);
85
- const result = await gateway.clientToken.generate({});
86
- if (result.success) {
87
- return result.clientToken;
88
- }
89
- throw new Error('Could not retrieve the client token');
90
- },
91
- charge: async ({ paypalPaymentMethodNonce }) => {
92
- const { order } = context;
93
- if (!order)
94
- throw new Error('Order is missing in payment context');
95
- if (!paypalPaymentMethodNonce)
96
- throw new Error('You have to provide paypalPaymentMethodNonce in paymentContext');
97
- const gateway = getGateway(braintree);
98
- const address = order.billingAddress;
99
- const pricing = OrderPricingSheet({
100
- calculation: order.calculation,
101
- currencyCode: order.currencyCode,
102
- });
103
- const rounded = Math.round(pricing.total({ useNetPrice: false }).amount / 10 || 0) * 10;
104
- const saleRequest = {
105
- amount: rounded / 100,
106
- merchantAccountId: order.currencyCode,
107
- paymentMethodNonce: paypalPaymentMethodNonce,
108
- orderId: order.orderNumber || order._id,
109
- shipping: address
110
- ? {
111
- firstName: address.firstName,
112
- lastName: address.lastName,
113
- company: address.company,
114
- streetAddress: address.addressLine,
115
- extendedAddress: address.addressLine2,
116
- locality: address.city,
117
- region: address.regionCode,
118
- postalCode: address.postalCode,
119
- countryCodeAlpha2: address.countryCode,
120
- }
121
- : undefined,
122
- options: {
123
- submitForSettlement: true,
124
- },
125
- };
126
- const result = await gateway.transaction.sale(saleRequest);
127
- if (result.success) {
128
- logger.info(`Braintree Plugin: ${result.message}`, saleRequest);
129
- return result;
130
- }
131
- logger.warn(`Braintree Plugin: ${result.message}`, saleRequest);
132
- throw new Error(result.message);
133
- },
134
- };
135
- return adapter;
136
- },
137
- };
138
- PaymentDirector.registerAdapter(BraintreeDirect);
@@ -1,2 +0,0 @@
1
- declare const cryptopayHandler: (req: any, res: any) => Promise<void>;
2
- export default cryptopayHandler;
@@ -1,19 +0,0 @@
1
- import { createLogger } from '@unchainedshop/logger';
2
- import handleWebhook from "./handle-webhook.js";
3
- const logger = createLogger('unchained:cryptopay:handler');
4
- const cryptopayHandler = async (req, res) => {
5
- if (req.method === 'POST') {
6
- try {
7
- await handleWebhook(req.body, req.unchainedContext);
8
- res.status(200).send({ success: true });
9
- return;
10
- }
11
- catch (e) {
12
- logger.error(e);
13
- res.status(500).send({ success: false, error: e.message });
14
- return;
15
- }
16
- }
17
- res.status(404).send();
18
- };
19
- export default cryptopayHandler;
@@ -1,3 +0,0 @@
1
- import { type RouteHandlerMethod } from 'fastify';
2
- declare const cryptopayHandler: RouteHandlerMethod;
3
- export default cryptopayHandler;
@@ -1,17 +0,0 @@
1
- import { createLogger } from '@unchainedshop/logger';
2
- import handleWebhook from "./handle-webhook.js";
3
- import {} from 'fastify';
4
- const logger = createLogger('unchained:cryptopay:handler');
5
- const cryptopayHandler = async (req, reply) => {
6
- try {
7
- await handleWebhook(req.body, req.unchainedContext);
8
- reply.status(200);
9
- return reply.send({ success: true });
10
- }
11
- catch (e) {
12
- logger.error(e);
13
- reply.status(500);
14
- return reply.send({ success: false, error: e.message });
15
- }
16
- };
17
- export default cryptopayHandler;
@@ -1,3 +0,0 @@
1
- import { type IPaymentAdapter } from '@unchainedshop/core';
2
- declare const Cryptopay: IPaymentAdapter;
3
- export default Cryptopay;
@@ -1 +0,0 @@
1
- export declare const datatransHandler: (req: any, res: any) => Promise<void>;
@@ -1,71 +0,0 @@
1
- import { createLogger } from '@unchainedshop/logger';
2
- import generateSignature, { Security } from "./generateSignature.js";
3
- const { DATATRANS_SIGN_KEY, DATATRANS_SIGN2_KEY, DATATRANS_SECURITY = Security.DYNAMIC_SIGN, } = process.env;
4
- const logger = createLogger('unchained:datatrans:handler');
5
- export const datatransHandler = async (req, res) => {
6
- const resolvedContext = req.unchainedContext;
7
- const { modules, services } = resolvedContext;
8
- const signature = req.headers['datatrans-signature'];
9
- if (!DATATRANS_SIGN_KEY && !DATATRANS_SIGN2_KEY) {
10
- logger.warn('No sign key configured');
11
- res.status(404).end();
12
- return;
13
- }
14
- if (req.method === 'POST' && signature) {
15
- const [rawTimestamp, rawHash] = signature.split(',');
16
- const [, hash] = rawHash.split('=');
17
- const [, timestamp] = rawTimestamp.split('=');
18
- const comparableSignature = await generateSignature({
19
- security: DATATRANS_SECURITY,
20
- signKey: DATATRANS_SIGN2_KEY || DATATRANS_SIGN_KEY,
21
- })(timestamp, req.body);
22
- if (hash !== comparableSignature) {
23
- logger.error(`hash mismatch: ${signature} / ${comparableSignature}`);
24
- res.status(403).send('Hash mismatch');
25
- return;
26
- }
27
- const transaction = JSON.parse(req.body);
28
- logger.info(`received request`, {
29
- type: transaction.type,
30
- });
31
- if (transaction.status === 'authorized') {
32
- const userId = transaction.refno2;
33
- const referenceId = Buffer.from(transaction.refno, 'base64').toString('hex');
34
- try {
35
- if (transaction.type === 'card_check') {
36
- const paymentProviderId = referenceId;
37
- const paymentCredentials = await services.orders.registerPaymentCredentials(paymentProviderId, { userId, transactionContext: { transactionId: transaction.transactionId } });
38
- logger.info(`registered payment credentials for ${userId}`, {
39
- userId,
40
- });
41
- res.status(200).send(paymentCredentials);
42
- return;
43
- }
44
- if (transaction.type === 'payment') {
45
- const orderPaymentId = referenceId;
46
- const orderPayment = await modules.orders.payments.findOrderPayment({
47
- orderPaymentId,
48
- });
49
- if (!orderPayment)
50
- throw new Error(`Order Payment with id ${orderPaymentId} not found`);
51
- const order = await services.orders.checkoutOrder(orderPayment.orderId, {
52
- paymentContext: { userId, transactionId: transaction.transactionId },
53
- });
54
- if (!order)
55
- throw new Error(`Order with id ${orderPayment.orderId} not found`);
56
- logger.info(`confirmed checkout for order ${order.orderNumber}`, {
57
- orderId: order._id,
58
- });
59
- res.status(200).send(order);
60
- return;
61
- }
62
- }
63
- catch (e) {
64
- logger.error(`rejected to checkout: ${e.name} - ${e.message}`);
65
- res.status(500).send({ name: e.name, code: e.code, message: e.message });
66
- return;
67
- }
68
- }
69
- }
70
- res.status(404).end();
71
- };
@@ -1,2 +0,0 @@
1
- import type { RouteHandlerMethod } from 'fastify';
2
- export declare const datatransHandler: RouteHandlerMethod;