@unchainedshop/plugins 4.0.0-rc.2 → 4.0.0-rc.21

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 (347) hide show
  1. package/lib/accounts/google-oauth.d.ts +4 -0
  2. package/lib/accounts/google-oauth.d.ts.map +1 -0
  3. package/lib/accounts/google-oauth.js +145 -0
  4. package/lib/accounts/google-oauth.js.map +1 -0
  5. package/lib/accounts/linkedin-oauth.d.ts +4 -0
  6. package/lib/accounts/linkedin-oauth.d.ts.map +1 -0
  7. package/lib/accounts/linkedin-oauth.js +82 -0
  8. package/lib/accounts/linkedin-oauth.js.map +1 -0
  9. package/lib/delivery/send-message.js.map +1 -1
  10. package/lib/enrollments/licensed.js +15 -2
  11. package/lib/enrollments/licensed.js.map +1 -1
  12. package/lib/files/gridfs/adapter.d.ts.map +1 -1
  13. package/lib/files/gridfs/adapter.js +19 -11
  14. package/lib/files/gridfs/adapter.js.map +1 -1
  15. package/lib/files/gridfs/gridfs-adapter.d.ts +3 -0
  16. package/lib/files/gridfs/gridfs-adapter.d.ts.map +1 -0
  17. package/lib/files/gridfs/gridfs-adapter.js +97 -0
  18. package/lib/files/gridfs/gridfs-adapter.js.map +1 -0
  19. package/lib/files/gridfs/gridfs-webhook.d.ts +11 -0
  20. package/lib/files/gridfs/gridfs-webhook.d.ts.map +1 -0
  21. package/lib/files/gridfs/gridfs-webhook.js +84 -0
  22. package/lib/files/gridfs/gridfs-webhook.js.map +1 -0
  23. package/lib/files/gridfs/handler-express.d.ts.map +1 -1
  24. package/lib/files/gridfs/handler-express.js +27 -24
  25. package/lib/files/gridfs/handler-express.js.map +1 -1
  26. package/lib/files/gridfs/handler-fastify.d.ts.map +1 -1
  27. package/lib/files/gridfs/handler-fastify.js +57 -14
  28. package/lib/files/gridfs/handler-fastify.js.map +1 -1
  29. package/lib/files/gridfs/module.d.ts +4 -4
  30. package/lib/files/gridfs/module.d.ts.map +1 -1
  31. package/lib/files/gridfs/module.js +2 -2
  32. package/lib/files/gridfs/module.js.map +1 -1
  33. package/lib/files/minio/handler-express.d.ts.map +1 -1
  34. package/lib/files/minio/handler-express.js +4 -7
  35. package/lib/files/minio/handler-express.js.map +1 -1
  36. package/lib/files/minio/handler-fastify.js +2 -2
  37. package/lib/files/minio/handler-fastify.js.map +1 -1
  38. package/lib/files/minio/index.d.ts +1 -1
  39. package/lib/files/minio/index.d.ts.map +1 -1
  40. package/lib/files/minio/index.js +7 -7
  41. package/lib/files/minio/index.js.map +1 -1
  42. package/lib/files/minio/minio-adapter.d.ts +6 -0
  43. package/lib/files/minio/minio-adapter.d.ts.map +1 -0
  44. package/lib/files/minio/minio-adapter.js +181 -0
  45. package/lib/files/minio/minio-adapter.js.map +1 -0
  46. package/lib/files/minio/minio-webhook.d.ts +2 -0
  47. package/lib/files/minio/minio-webhook.d.ts.map +1 -0
  48. package/lib/files/minio/minio-webhook.js +33 -0
  49. package/lib/files/minio/minio-webhook.js.map +1 -0
  50. package/lib/filters/local-search.js +1 -1
  51. package/lib/filters/local-search.js.map +1 -1
  52. package/lib/payment/apple-iap/adapter.js +12 -10
  53. package/lib/payment/apple-iap/adapter.js.map +1 -1
  54. package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts +1 -1
  55. package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts.map +1 -1
  56. package/lib/payment/apple-iap/handler-express.d.ts.map +1 -1
  57. package/lib/payment/apple-iap/handler-express.js +14 -10
  58. package/lib/payment/apple-iap/handler-express.js.map +1 -1
  59. package/lib/payment/apple-iap/handler-fastify.d.ts.map +1 -1
  60. package/lib/payment/apple-iap/handler-fastify.js +15 -8
  61. package/lib/payment/apple-iap/handler-fastify.js.map +1 -1
  62. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts +9 -0
  63. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts.map +1 -0
  64. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js +17 -0
  65. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js.map +1 -0
  66. package/lib/payment/apple-iap/module.d.ts +4 -4
  67. package/lib/payment/apple-iap/module.d.ts.map +1 -1
  68. package/lib/payment/apple-iap/module.js +4 -2
  69. package/lib/payment/apple-iap/module.js.map +1 -1
  70. package/lib/payment/braintree.js +3 -1
  71. package/lib/payment/braintree.js.map +1 -1
  72. package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts +1 -1
  73. package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts.map +1 -1
  74. package/lib/payment/cryptopay/derive-btc-address.d.ts.map +1 -1
  75. package/lib/payment/cryptopay/derive-btc-address.js +2 -3
  76. package/lib/payment/cryptopay/derive-btc-address.js.map +1 -1
  77. package/lib/payment/cryptopay/derive-eth-address.d.ts.map +1 -1
  78. package/lib/payment/cryptopay/derive-eth-address.js +5 -3
  79. package/lib/payment/cryptopay/derive-eth-address.js.map +1 -1
  80. package/lib/payment/cryptopay/handle-webhook.js +2 -2
  81. package/lib/payment/cryptopay/handle-webhook.js.map +1 -1
  82. package/lib/payment/cryptopay/handler-express.d.ts.map +1 -1
  83. package/lib/payment/cryptopay/handler-express.js +4 -7
  84. package/lib/payment/cryptopay/handler-express.js.map +1 -1
  85. package/lib/payment/cryptopay/handler-fastify.d.ts.map +1 -1
  86. package/lib/payment/cryptopay/handler-fastify.js +1 -1
  87. package/lib/payment/cryptopay/handler-fastify.js.map +1 -1
  88. package/lib/payment/cryptopay/middleware.d.ts +2 -0
  89. package/lib/payment/cryptopay/middleware.d.ts.map +1 -0
  90. package/lib/payment/cryptopay/middleware.js +75 -0
  91. package/lib/payment/cryptopay/middleware.js.map +1 -0
  92. package/lib/payment/cryptopay/module/configureCryptopayModule.d.ts +25 -0
  93. package/lib/payment/cryptopay/module/configureCryptopayModule.d.ts.map +1 -0
  94. package/lib/payment/cryptopay/module/configureCryptopayModule.js +75 -0
  95. package/lib/payment/cryptopay/module/configureCryptopayModule.js.map +1 -0
  96. package/lib/payment/cryptopay/module.d.ts +2 -2
  97. package/lib/payment/cryptopay/module.d.ts.map +1 -1
  98. package/lib/payment/cryptopay/module.js +4 -4
  99. package/lib/payment/cryptopay/module.js.map +1 -1
  100. package/lib/payment/cryptopay/plugin.d.ts.map +1 -1
  101. package/lib/payment/cryptopay/plugin.js +18 -4
  102. package/lib/payment/cryptopay/plugin.js.map +1 -1
  103. package/lib/payment/datatrans-v2/handler-express.d.ts.map +1 -1
  104. package/lib/payment/datatrans-v2/handler-express.js +13 -11
  105. package/lib/payment/datatrans-v2/handler-express.js.map +1 -1
  106. package/lib/payment/datatrans-v2/handler-fastify.d.ts.map +1 -1
  107. package/lib/payment/datatrans-v2/handler-fastify.js +11 -5
  108. package/lib/payment/datatrans-v2/handler-fastify.js.map +1 -1
  109. package/lib/payment/datatrans-v2/index.js +63 -37
  110. package/lib/payment/datatrans-v2/index.js.map +1 -1
  111. package/lib/payment/datatrans-v2/middleware.d.ts +2 -0
  112. package/lib/payment/datatrans-v2/middleware.d.ts.map +1 -0
  113. package/lib/payment/datatrans-v2/middleware.js +68 -0
  114. package/lib/payment/datatrans-v2/middleware.js.map +1 -0
  115. package/lib/payment/datatrans-v2/parseRegistrationData.d.ts +1 -1
  116. package/lib/payment/datatrans-v2/parseRegistrationData.d.ts.map +1 -1
  117. package/lib/payment/paypal-checkout.js +8 -8
  118. package/lib/payment/paypal-checkout.js.map +1 -1
  119. package/lib/payment/payrexx/api/index.d.ts +1 -1
  120. package/lib/payment/payrexx/api/index.d.ts.map +1 -1
  121. package/lib/payment/payrexx/api/makeFetcher.d.ts +1 -1
  122. package/lib/payment/payrexx/api/makeFetcher.d.ts.map +1 -1
  123. package/lib/payment/payrexx/api/makeFetcher.js +1 -1
  124. package/lib/payment/payrexx/api/makeFetcher.js.map +1 -1
  125. package/lib/payment/payrexx/handler-express.d.ts.map +1 -1
  126. package/lib/payment/payrexx/handler-express.js +15 -15
  127. package/lib/payment/payrexx/handler-express.js.map +1 -1
  128. package/lib/payment/payrexx/handler-fastify.js +23 -15
  129. package/lib/payment/payrexx/handler-fastify.js.map +1 -1
  130. package/lib/payment/payrexx/index.js +21 -15
  131. package/lib/payment/payrexx/index.js.map +1 -1
  132. package/lib/payment/payrexx/middleware.d.ts +2 -0
  133. package/lib/payment/payrexx/middleware.d.ts.map +1 -0
  134. package/lib/payment/payrexx/middleware.js +86 -0
  135. package/lib/payment/payrexx/middleware.js.map +1 -0
  136. package/lib/payment/postfinance-checkout/api-client.d.ts +16 -0
  137. package/lib/payment/postfinance-checkout/api-client.d.ts.map +1 -0
  138. package/lib/payment/postfinance-checkout/api-client.js +75 -0
  139. package/lib/payment/postfinance-checkout/api-client.js.map +1 -0
  140. package/lib/payment/postfinance-checkout/api-types.d.ts +98 -0
  141. package/lib/payment/postfinance-checkout/api-types.d.ts.map +1 -0
  142. package/lib/payment/postfinance-checkout/api-types.js +51 -0
  143. package/lib/payment/postfinance-checkout/api-types.js.map +1 -0
  144. package/lib/payment/postfinance-checkout/api.d.ts +5 -5
  145. package/lib/payment/postfinance-checkout/api.d.ts.map +1 -1
  146. package/lib/payment/postfinance-checkout/api.js +38 -62
  147. package/lib/payment/postfinance-checkout/api.js.map +1 -1
  148. package/lib/payment/postfinance-checkout/handler-express.d.ts.map +1 -1
  149. package/lib/payment/postfinance-checkout/handler-express.js +10 -11
  150. package/lib/payment/postfinance-checkout/handler-express.js.map +1 -1
  151. package/lib/payment/postfinance-checkout/handler-fastify.d.ts.map +1 -1
  152. package/lib/payment/postfinance-checkout/handler-fastify.js +10 -8
  153. package/lib/payment/postfinance-checkout/handler-fastify.js.map +1 -1
  154. package/lib/payment/postfinance-checkout/index.d.ts +2 -1
  155. package/lib/payment/postfinance-checkout/index.d.ts.map +1 -1
  156. package/lib/payment/postfinance-checkout/index.js +44 -32
  157. package/lib/payment/postfinance-checkout/index.js.map +1 -1
  158. package/lib/payment/postfinance-checkout/middleware.d.ts +2 -0
  159. package/lib/payment/postfinance-checkout/middleware.d.ts.map +1 -0
  160. package/lib/payment/postfinance-checkout/middleware.js +38 -0
  161. package/lib/payment/postfinance-checkout/middleware.js.map +1 -0
  162. package/lib/payment/postfinance-checkout/utils.d.ts +3 -3
  163. package/lib/payment/postfinance-checkout/utils.d.ts.map +1 -1
  164. package/lib/payment/postfinance-checkout/utils.js +3 -4
  165. package/lib/payment/postfinance-checkout/utils.js.map +1 -1
  166. package/lib/payment/saferpay/adapter.d.ts.map +1 -1
  167. package/lib/payment/saferpay/adapter.js +9 -0
  168. package/lib/payment/saferpay/adapter.js.map +1 -1
  169. package/lib/payment/saferpay/handler-express.d.ts.map +1 -1
  170. package/lib/payment/saferpay/handler-express.js +10 -8
  171. package/lib/payment/saferpay/handler-express.js.map +1 -1
  172. package/lib/payment/saferpay/handler-fastify.d.ts.map +1 -1
  173. package/lib/payment/saferpay/handler-fastify.js +11 -5
  174. package/lib/payment/saferpay/handler-fastify.js.map +1 -1
  175. package/lib/payment/saferpay/middleware.d.ts +2 -0
  176. package/lib/payment/saferpay/middleware.d.ts.map +1 -0
  177. package/lib/payment/saferpay/middleware.js +57 -0
  178. package/lib/payment/saferpay/middleware.js.map +1 -0
  179. package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.d.ts +10 -0
  180. package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.d.ts.map +1 -0
  181. package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.js +24 -0
  182. package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.js.map +1 -0
  183. package/lib/payment/saferpay/module.d.ts +2 -2
  184. package/lib/payment/stripe/handler-express.js +25 -17
  185. package/lib/payment/stripe/handler-express.js.map +1 -1
  186. package/lib/payment/stripe/handler-fastify.d.ts.map +1 -1
  187. package/lib/payment/stripe/handler-fastify.js +33 -12
  188. package/lib/payment/stripe/handler-fastify.js.map +1 -1
  189. package/lib/payment/stripe/index.js +19 -13
  190. package/lib/payment/stripe/index.js.map +1 -1
  191. package/lib/payment/stripe/middleware.d.ts +6 -0
  192. package/lib/payment/stripe/middleware.d.ts.map +1 -0
  193. package/lib/payment/stripe/middleware.js +114 -0
  194. package/lib/payment/stripe/middleware.js.map +1 -0
  195. package/lib/payment/stripe/stripe.d.ts +2 -2
  196. package/lib/payment/stripe/stripe.d.ts.map +1 -1
  197. package/lib/payment/stripe/stripe.js +14 -11
  198. package/lib/payment/stripe/stripe.js.map +1 -1
  199. package/lib/plugins-index.d.ts +48 -0
  200. package/lib/plugins-index.d.ts.map +1 -0
  201. package/lib/plugins-index.js +107 -0
  202. package/lib/plugins-index.js.map +1 -0
  203. package/lib/presets/all.d.ts +9 -7
  204. package/lib/presets/all.d.ts.map +1 -1
  205. package/lib/presets/all.js +3 -1
  206. package/lib/presets/all.js.map +1 -1
  207. package/lib/pricing/delivery-swiss-tax.d.ts.map +1 -1
  208. package/lib/pricing/delivery-swiss-tax.js +13 -20
  209. package/lib/pricing/delivery-swiss-tax.js.map +1 -1
  210. package/lib/pricing/order-discount.d.ts.map +1 -1
  211. package/lib/pricing/order-discount.js +5 -3
  212. package/lib/pricing/order-discount.js.map +1 -1
  213. package/lib/pricing/order-round.d.ts.map +1 -1
  214. package/lib/pricing/order-round.js +4 -3
  215. package/lib/pricing/order-round.js.map +1 -1
  216. package/lib/pricing/product-catalog-price.d.ts.map +1 -1
  217. package/lib/pricing/product-catalog-price.js +26 -2
  218. package/lib/pricing/product-catalog-price.js.map +1 -1
  219. package/lib/pricing/product-price-rateconversion.js +3 -3
  220. package/lib/pricing/product-price-rateconversion.js.map +1 -1
  221. package/lib/pricing/product-swiss-tax.d.ts +1 -5
  222. package/lib/pricing/product-swiss-tax.d.ts.map +1 -1
  223. package/lib/pricing/product-swiss-tax.js +26 -22
  224. package/lib/pricing/product-swiss-tax.js.map +1 -1
  225. package/lib/pricing/tax/ch.d.ts +7 -2
  226. package/lib/pricing/tax/ch.d.ts.map +1 -1
  227. package/lib/pricing/tax/ch.js +16 -1
  228. package/lib/pricing/tax/ch.js.map +1 -1
  229. package/lib/pricing/utils/isDeliveryAddressInCountry.d.ts +7 -0
  230. package/lib/pricing/utils/isDeliveryAddressInCountry.d.ts.map +1 -0
  231. package/lib/pricing/utils/isDeliveryAddressInCountry.js +13 -0
  232. package/lib/pricing/utils/isDeliveryAddressInCountry.js.map +1 -0
  233. package/lib/warehousing/eth-minter.js +23 -11
  234. package/lib/warehousing/eth-minter.js.map +1 -1
  235. package/lib/worker/budgetsms.d.ts +10 -0
  236. package/lib/worker/budgetsms.d.ts.map +1 -0
  237. package/lib/worker/budgetsms.js +217 -0
  238. package/lib/worker/budgetsms.js.map +1 -0
  239. package/lib/worker/bulk-import.d.ts +1 -1
  240. package/lib/worker/bulk-import.d.ts.map +1 -1
  241. package/lib/worker/bulk-import.js +11 -33
  242. package/lib/worker/bulk-import.js.map +1 -1
  243. package/lib/worker/bulkgate.d.ts +2 -0
  244. package/lib/worker/bulkgate.d.ts.map +1 -0
  245. package/lib/worker/bulkgate.js +104 -0
  246. package/lib/worker/bulkgate.js.map +1 -0
  247. package/lib/worker/email.d.ts.map +1 -1
  248. package/lib/worker/email.js +25 -7
  249. package/lib/worker/email.js.map +1 -1
  250. package/lib/worker/enrollment-order-generator.d.ts.map +1 -1
  251. package/lib/worker/enrollment-order-generator.js +7 -49
  252. package/lib/worker/enrollment-order-generator.js.map +1 -1
  253. package/lib/worker/error-notifications.js +1 -1
  254. package/lib/worker/error-notifications.js.map +1 -1
  255. package/lib/worker/export-token.d.ts.map +1 -1
  256. package/lib/worker/export-token.js +0 -1
  257. package/lib/worker/export-token.js.map +1 -1
  258. package/lib/worker/heartbeat.js +2 -8
  259. package/lib/worker/heartbeat.js.map +1 -1
  260. package/lib/worker/message.d.ts +1 -1
  261. package/lib/worker/message.d.ts.map +1 -1
  262. package/lib/worker/message.js +4 -2
  263. package/lib/worker/message.js.map +1 -1
  264. package/lib/worker/sms.js +16 -16
  265. package/lib/worker/sms.js.map +1 -1
  266. package/lib/worker/twilio.d.ts +2 -0
  267. package/lib/worker/twilio.d.ts.map +1 -0
  268. package/lib/worker/twilio.js +60 -0
  269. package/lib/worker/twilio.js.map +1 -0
  270. package/package.json +29 -45
  271. package/src/delivery/send-message.ts +1 -1
  272. package/src/enrollments/licensed.ts +15 -2
  273. package/src/files/gridfs/adapter.ts +24 -10
  274. package/src/files/gridfs/handler-express.ts +32 -24
  275. package/src/files/gridfs/handler-fastify.ts +63 -15
  276. package/src/files/gridfs/module.ts +7 -2
  277. package/src/files/minio/handler-express.ts +4 -7
  278. package/src/files/minio/handler-fastify.ts +2 -2
  279. package/src/files/minio/index.ts +16 -16
  280. package/src/filters/local-search.ts +1 -1
  281. package/src/payment/apple-iap/adapter.ts +12 -14
  282. package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +1 -1
  283. package/src/payment/apple-iap/handler-express.ts +17 -11
  284. package/src/payment/apple-iap/handler-fastify.ts +19 -9
  285. package/src/payment/apple-iap/module.ts +9 -4
  286. package/src/payment/braintree.ts +4 -1
  287. package/src/payment/cryptopay/db/CryptopayTransactions.ts +1 -1
  288. package/src/payment/cryptopay/derive-btc-address.ts +1 -3
  289. package/src/payment/cryptopay/derive-eth-address.ts +5 -3
  290. package/src/payment/cryptopay/handle-webhook.ts +6 -6
  291. package/src/payment/cryptopay/handler-express.ts +4 -7
  292. package/src/payment/cryptopay/handler-fastify.ts +2 -2
  293. package/src/payment/cryptopay/module.ts +8 -5
  294. package/src/payment/cryptopay/plugin.ts +21 -4
  295. package/src/payment/datatrans-v2/handler-express.ts +17 -12
  296. package/src/payment/datatrans-v2/handler-fastify.ts +15 -6
  297. package/src/payment/datatrans-v2/index.ts +82 -50
  298. package/src/payment/paypal-checkout.ts +8 -11
  299. package/src/payment/payrexx/api/index.ts +1 -1
  300. package/src/payment/payrexx/api/makeFetcher.ts +2 -2
  301. package/src/payment/payrexx/handler-express.ts +24 -32
  302. package/src/payment/payrexx/handler-fastify.ts +33 -33
  303. package/src/payment/payrexx/index.ts +26 -16
  304. package/src/payment/postfinance-checkout/api-client.ts +111 -0
  305. package/src/payment/postfinance-checkout/api-types.ts +111 -0
  306. package/src/payment/postfinance-checkout/api.ts +58 -85
  307. package/src/payment/postfinance-checkout/handler-express.ts +11 -13
  308. package/src/payment/postfinance-checkout/handler-fastify.ts +11 -10
  309. package/src/payment/postfinance-checkout/index.ts +60 -38
  310. package/src/payment/postfinance-checkout/utils.ts +5 -10
  311. package/src/payment/saferpay/adapter.ts +14 -2
  312. package/src/payment/saferpay/handler-express.ts +14 -13
  313. package/src/payment/saferpay/handler-fastify.ts +14 -9
  314. package/src/payment/stripe/handler-express.ts +33 -33
  315. package/src/payment/stripe/handler-fastify.ts +40 -27
  316. package/src/payment/stripe/index.ts +17 -13
  317. package/src/payment/stripe/stripe.ts +17 -12
  318. package/src/presets/all.ts +3 -1
  319. package/src/pricing/delivery-swiss-tax.ts +16 -31
  320. package/src/pricing/order-discount.ts +6 -4
  321. package/src/pricing/order-round.ts +5 -4
  322. package/src/pricing/product-catalog-price.ts +25 -2
  323. package/src/pricing/product-price-rateconversion.ts +3 -3
  324. package/src/pricing/product-swiss-tax.ts +39 -40
  325. package/src/pricing/tax/ch.ts +33 -7
  326. package/src/pricing/utils/isDeliveryAddressInCountry.test.ts +106 -0
  327. package/src/pricing/utils/isDeliveryAddressInCountry.ts +26 -0
  328. package/src/warehousing/eth-minter.ts +30 -11
  329. package/src/worker/budgetsms.ts +268 -0
  330. package/src/worker/bulk-import.ts +12 -53
  331. package/src/worker/bulkgate.ts +138 -0
  332. package/src/worker/email.ts +30 -8
  333. package/src/worker/enrollment-order-generator.ts +14 -72
  334. package/src/worker/error-notifications.ts +2 -2
  335. package/src/worker/export-token.ts +0 -1
  336. package/src/worker/heartbeat.ts +2 -9
  337. package/src/worker/message.ts +5 -3
  338. package/src/worker/{sms.ts → twilio.ts} +15 -26
  339. package/lib/payment/cryptopay/de.d.ts +0 -2
  340. package/lib/payment/cryptopay/de.d.ts.map +0 -1
  341. package/lib/payment/cryptopay/de.js +0 -10
  342. package/lib/payment/cryptopay/de.js.map +0 -1
  343. package/lib/payment/cryptopay/derive-btc-address.test copy.d.ts +0 -2
  344. package/lib/payment/cryptopay/derive-btc-address.test copy.d.ts.map +0 -1
  345. package/lib/payment/cryptopay/derive-btc-address.test copy.js +0 -10
  346. package/lib/payment/cryptopay/derive-btc-address.test copy.js.map +0 -1
  347. package/src/pricing/product-swiss-tax.test.ts +0 -139
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/plugins",
3
- "version": "4.0.0-rc.2",
3
+ "version": "4.0.0-rc.21",
4
4
  "main": "lib/plugins-index.js",
5
5
  "types": "lib/plugins-index.d.ts",
6
6
  "exports": {
@@ -34,38 +34,34 @@
34
34
  },
35
35
  "homepage": "https://github.com/unchainedshop/unchained#readme",
36
36
  "dependencies": {
37
- "@unchainedshop/api": "^4.0.0-rc.2",
38
- "@unchainedshop/core-delivery": "^4.0.0-rc.2",
39
- "@unchainedshop/core-enrollments": "^4.0.0-rc.2",
40
- "@unchainedshop/core-orders": "^4.0.0-rc.2",
41
- "@unchainedshop/core-payment": "^4.0.0-rc.2",
42
- "@unchainedshop/core-products": "^4.0.0-rc.2",
43
- "@unchainedshop/core-warehousing": "^4.0.0-rc.2",
44
- "@unchainedshop/core-worker": "^4.0.0-rc.2",
45
- "@unchainedshop/events": "^4.0.0-rc.2",
46
- "@unchainedshop/file-upload": "^4.0.0-rc.2",
47
- "@unchainedshop/logger": "^4.0.0-rc.2",
48
- "@unchainedshop/utils": "^4.0.0-rc.2",
49
- "event-iterator": "^2.0.0",
50
- "JSONStream": "^1.3.5"
37
+ "@unchainedshop/api": "^4.0.0-rc.21",
38
+ "@unchainedshop/core-delivery": "^4.0.0-rc.21",
39
+ "@unchainedshop/core-enrollments": "^4.0.0-rc.21",
40
+ "@unchainedshop/core-orders": "^4.0.0-rc.21",
41
+ "@unchainedshop/core-payment": "^4.0.0-rc.21",
42
+ "@unchainedshop/core-products": "^4.0.0-rc.21",
43
+ "@unchainedshop/core-warehousing": "^4.0.0-rc.21",
44
+ "@unchainedshop/core-worker": "^4.0.0-rc.21",
45
+ "@unchainedshop/events": "^4.0.0-rc.21",
46
+ "@unchainedshop/file-upload": "^4.0.0-rc.21",
47
+ "@unchainedshop/logger": "^4.0.0-rc.21",
48
+ "@unchainedshop/utils": "^4.0.0-rc.21"
51
49
  },
52
50
  "peerDependencies": {
53
- "@breejs/later": "^4.2.0",
54
51
  "@aws-sdk/client-eventbridge": ">= 3.714 < 4",
52
+ "@breejs/later": "^4.2.0",
55
53
  "@paypal/checkout-server-sdk": "1.x",
56
54
  "@redis/client": ">= 1 < 6",
57
- "@scure/bip32": ">= 1.7 < 2",
58
- "@scure/btc-signer": ">= 1.8 < 2",
55
+ "@scure/bip32": ">= 2",
56
+ "@scure/btc-signer": ">= 2",
57
+ "mime": ">= 4 < 5",
59
58
  "expiry-map": "2.x",
60
59
  "express": ">= 5 < 6",
61
60
  "fastify": ">= 5.2 < 6",
62
- "mime-types": ">= 2 < 4",
63
61
  "minio": "8.x",
64
62
  "nodemailer": ">= 6.9 < 8",
65
- "open": "10.x",
66
- "p-memoize": "7.x",
67
- "postfinancecheckout": ">= 4.5.0",
68
- "stripe": ">= 17 < 19",
63
+ "p-memoize": "8.x",
64
+ "stripe": ">= 19 < 20",
69
65
  "web-push": ">= 3.6 <4",
70
66
  "xml-js": ">= 1.6 < 2"
71
67
  },
@@ -97,24 +93,15 @@
97
93
  "fastify": {
98
94
  "optional": true
99
95
  },
100
- "mime-types": {
101
- "optional": true
102
- },
103
96
  "minio": {
104
97
  "optional": true
105
98
  },
106
99
  "nodemailer": {
107
100
  "optional": true
108
101
  },
109
- "open": {
110
- "optional": true
111
- },
112
102
  "p-memoize": {
113
103
  "optional": true
114
104
  },
115
- "postfinancecheckout": {
116
- "optional": true
117
- },
118
105
  "stripe": {
119
106
  "optional": true
120
107
  },
@@ -128,23 +115,20 @@
128
115
  "devDependencies": {
129
116
  "@breejs/later": "^4.2.0",
130
117
  "@paypal/checkout-server-sdk": "^1.0.3",
131
- "@redis/client": "^5.0.1",
132
- "@scure/bip32": "^1.7.0",
133
- "@scure/btc-signer": "^1.8.0",
118
+ "@redis/client": "^5.6.0",
119
+ "@scure/bip32": "^2.0.0",
120
+ "@scure/btc-signer": "^2.0.0",
134
121
  "@types/breejs__later": "^4.1.5",
135
- "@types/express": "^5.0.1",
136
- "@types/node": "^22.15.3",
122
+ "@types/express": "^5.0.3",
123
+ "@types/node": "^24.0.13",
137
124
  "expiry-map": "^2.0.0",
138
125
  "express": "^5.1.0",
139
- "fastify": "^5.3.2",
140
- "mime-types": "^3.0.1",
126
+ "fastify": "^5.4.0",
141
127
  "minio": "^8.0.5",
142
- "nodemailer": "^7.0.2",
143
- "open": "^10.1.2",
144
- "p-memoize": "^7.1.1",
145
- "postfinancecheckout": "^4.7.0",
146
- "stripe": "^18.1.0",
147
- "tsx": "^4.19.4",
128
+ "nodemailer": "^7.0.5",
129
+ "p-memoize": "^8.0.0",
130
+ "stripe": "^19.1.0",
131
+ "tsx": "^4.20.3",
148
132
  "typescript": "^5.8.3",
149
133
  "web-push": "^3.6.7",
150
134
  "xml-js": "^1.6.11"
@@ -38,7 +38,7 @@ const SendMessage: IDeliveryAdapter = {
38
38
  retries: 0,
39
39
  input: {
40
40
  template: 'DELIVERY',
41
- orderId: order._id,
41
+ orderId: order!._id,
42
42
  config,
43
43
  },
44
44
  });
@@ -21,11 +21,12 @@ const LicensedEnrollments: IEnrollmentAdapter = {
21
21
  },
22
22
 
23
23
  actions: (params) => {
24
+ const { enrollment } = params;
24
25
  return {
25
26
  ...EnrollmentAdapter.actions(params),
26
27
 
27
28
  isValidForActivation: async () => {
28
- const periods = params.enrollment?.periods || [];
29
+ const periods = enrollment?.periods || [];
29
30
  return periods.findIndex(rangeMatcher()) !== -1;
30
31
  },
31
32
 
@@ -36,8 +37,20 @@ const LicensedEnrollments: IEnrollmentAdapter = {
36
37
  configurationForOrder: async (context) => {
37
38
  const { period } = context;
38
39
  const beginningOfPeriod = period.start.getTime() <= new Date().getTime();
40
+
41
+ if (!enrollment) throw new Error('Enrollment missing in context');
39
42
  if (beginningOfPeriod) {
40
- return context;
43
+ return {
44
+ period,
45
+ orderContext: {},
46
+ orderPositionTemplates: [
47
+ {
48
+ quantity: 1,
49
+ productId: enrollment.productId,
50
+ originalProductId: enrollment.productId,
51
+ },
52
+ ],
53
+ };
41
54
  }
42
55
  return null;
43
56
  },
@@ -1,6 +1,6 @@
1
1
  import { Readable, PassThrough } from 'node:stream';
2
- import { pipeline } from 'node:stream/promises';
3
- import mimeType from 'mime-types';
2
+ import { finished, pipeline } from 'node:stream/promises';
3
+ import mime from 'mime/lite';
4
4
  import {
5
5
  FileAdapter,
6
6
  FileDirector,
@@ -36,7 +36,7 @@ export const GridFSAdapter: IFileAdapter<
36
36
  ...FileAdapter,
37
37
  async createDownloadURL(file, expiry) {
38
38
  // If public, just return the stored path from the db
39
- if (!file.meta?.isPrivate) return file?.url;
39
+ if (!file?.meta?.isPrivate) return file?.url || null;
40
40
 
41
41
  const expiryTimestamp =
42
42
  expiry ||
@@ -63,13 +63,13 @@ export const GridFSAdapter: IFileAdapter<
63
63
  directoryName,
64
64
  expiryDate,
65
65
  fileName,
66
- type: mimeType.lookup(fileName),
66
+ type: mime.getType(fileName),
67
67
  putURL,
68
68
  url,
69
69
  } as UploadFileData & { putURL: string };
70
70
  },
71
71
 
72
- async uploadFileFromStream(directoryName: string, rawFile: any, { modules }) {
72
+ async uploadFileFromStream(directoryName: string, rawFile: any, { modules }, options = {}) {
73
73
  let stream: Readable;
74
74
  let fileName;
75
75
  if (rawFile instanceof Promise) {
@@ -83,15 +83,27 @@ export const GridFSAdapter: IFileAdapter<
83
83
 
84
84
  const expiryDate = resolveExpirationDate();
85
85
  const hashedFilename = await buildHashedFilename(directoryName, fileName, expiryDate);
86
- const type = mimeType.lookup(fileName) || (await Promise.resolve(rawFile)).mimetype;
86
+ const type = mime.getType(fileName) || (await Promise.resolve(rawFile)).mimetype;
87
87
 
88
88
  const writeStream = await modules.gridfsFileUploads.createWriteStream(
89
89
  directoryName,
90
90
  hashedFilename,
91
91
  fileName,
92
- { 'content-type': type },
92
+ {
93
+ metadata: { 'content-type': type },
94
+ chunkSizeBytes: 1024 * 1024, // 1MB
95
+ ...options,
96
+ },
93
97
  );
94
- await pipeline(stream, new PassThrough({ allowHalfOpen: true }), writeStream);
98
+
99
+ await pipeline(
100
+ stream,
101
+ new PassThrough({ highWaterMark: 1024 * 1024 * 4 }), // 4MB Buffer
102
+ writeStream,
103
+ );
104
+
105
+ await finished(writeStream, { readable: false });
106
+
95
107
  const { length } = writeStream;
96
108
  const url = `/gridfs/${directoryName}/${encodeURIComponent(hashedFilename)}`;
97
109
 
@@ -119,13 +131,15 @@ export const GridFSAdapter: IFileAdapter<
119
131
 
120
132
  const response = await fetch(href, { headers });
121
133
  if (!response.ok) throw new Error(`Unexpected response for ${href}: ${response.statusText}`);
122
- const type = mimeType.lookup(fileName) || response.headers.get('content-type');
134
+ const type = mime.getType(fileName) || response.headers.get('content-type');
123
135
 
124
136
  const writeStream = await modules.gridfsFileUploads.createWriteStream(
125
137
  directoryName,
126
138
  hashedFilename,
127
139
  fileName,
128
- { 'content-type': type },
140
+ {
141
+ metadata: { 'content-type': type },
142
+ },
129
143
  );
130
144
  await pipeline(response.body as unknown as Readable, new PassThrough(), writeStream);
131
145
  const { length } = writeStream;
@@ -10,7 +10,7 @@ import { getFileAdapter } from '@unchainedshop/core-files';
10
10
 
11
11
  const { ROOT_URL } = process.env;
12
12
 
13
- const logger = createLogger('unchained:plugins:gridfs');
13
+ const logger = createLogger('unchained:gridfs');
14
14
 
15
15
  const gridfsHandler = async (
16
16
  req: express.Request & {
@@ -34,8 +34,7 @@ const gridfsHandler = async (
34
34
  res.setHeader('Access-Control-Allow-Origin', '*');
35
35
 
36
36
  if (req.method === 'OPTIONS') {
37
- res.statusCode = 200;
38
- res.end();
37
+ res.status(200).end();
39
38
  return;
40
39
  }
41
40
 
@@ -45,9 +44,14 @@ const gridfsHandler = async (
45
44
  const fileId = await buildHashedFilename(directoryName, fileName, expiryDate);
46
45
  if ((await sign(directoryName, fileId, expiryDate.getTime())) === signature) {
47
46
  const file = await modules.files.findFile({ fileId });
47
+
48
+ if (!file) {
49
+ res.status(404).send('File not found');
50
+ return;
51
+ }
52
+
48
53
  if (file.expires === null) {
49
- res.statusCode = 400;
50
- res.end('File already linked');
54
+ res.status(400).send('File already linked');
51
55
  return;
52
56
  }
53
57
  // If the type is octet-stream, prefer mimetype lookup from the filename
@@ -61,19 +65,26 @@ const gridfsHandler = async (
61
65
  directoryName,
62
66
  fileId,
63
67
  fileName,
64
- { 'content-type': type },
68
+ {
69
+ chunkSizeBytes: 1024 * 1024, // 1MB
70
+ metadata: { 'content-type': type },
71
+ },
65
72
  );
66
- await pipeline(req, new PassThrough(), writeStream);
73
+ await pipeline(
74
+ req,
75
+ new PassThrough({ highWaterMark: 1024 * 1024 * 4 }), // 4MB Buffer
76
+ writeStream,
77
+ );
78
+
79
+ await finished(writeStream, { readable: false });
67
80
 
68
81
  const { length } = writeStream;
69
82
  await services.files.linkFile({ fileId, size: length, type });
70
83
 
71
- res.statusCode = 200;
72
- res.end();
84
+ res.status(200).end();
73
85
  return;
74
86
  }
75
- res.statusCode = 403;
76
- res.end();
87
+ res.status(403).end();
77
88
  return;
78
89
  }
79
90
 
@@ -85,19 +96,20 @@ const gridfsHandler = async (
85
96
  if (fileDocument?.meta?.isPrivate) {
86
97
  const expiry = parseInt(expiryTimestamp as string, 10);
87
98
  if (expiry <= Date.now()) {
88
- res.statusCode = 403;
89
- res.end('Access restricted: Expired.');
99
+ res.status(403).send('Access restricted: Expired.');
90
100
  return;
91
101
  }
92
102
 
93
103
  const fileUploadAdapter = getFileAdapter();
94
104
  const signedUrl = await fileUploadAdapter.createDownloadURL(fileDocument, expiry);
95
105
 
96
- if (new URL(signedUrl, 'file://').searchParams.get('s') !== signature) {
97
- res.statusCode = 403;
98
- res.end('Access restricted: Invalid signature.');
106
+ if (!signedUrl || new URL(signedUrl, 'file://').searchParams.get('s') !== signature) {
107
+ res.status(403).send('Access restricted: Invalid signature.');
99
108
  return;
100
109
  }
110
+ } else if (!fileDocument) {
111
+ res.status(404).end();
112
+ return;
101
113
  }
102
114
  if (file?.metadata?.['content-type']) {
103
115
  res.setHeader('Content-Type', file.metadata['content-type']);
@@ -109,21 +121,17 @@ const gridfsHandler = async (
109
121
  const readStream = await modules.gridfsFileUploads.createReadStream(directoryName, fileId);
110
122
  readStream.pipe(res, { end: false });
111
123
  await finished(readStream);
112
- res.statusCode = 200;
113
- res.end();
124
+ res.status(200).end();
114
125
  return;
115
126
  }
116
- res.statusCode = 404;
117
- res.end();
127
+ res.status(404).end();
118
128
  } catch (e) {
119
129
  if (e.code === 'ENOENT') {
120
130
  logger.warn(e);
121
- res.statusCode = 404;
122
- res.end(e.message);
131
+ res.status(404).send();
123
132
  } else {
124
133
  logger.warn(e);
125
- res.statusCode = 503;
126
- res.end(JSON.stringify({ name: e.name, code: e.code, message: e.message }));
134
+ res.status(503).send({ name: e.name, code: e.code, message: e.message });
127
135
  }
128
136
  }
129
137
  };
@@ -1,4 +1,4 @@
1
- import { pipeline } from 'node:stream/promises';
1
+ import { finished, pipeline } from 'node:stream/promises';
2
2
  import { PassThrough } from 'node:stream';
3
3
  import { FastifyRequest, RouteHandlerMethod } from 'fastify';
4
4
  import { buildHashedFilename } from '@unchainedshop/file-upload';
@@ -8,7 +8,7 @@ import { Context } from '@unchainedshop/api';
8
8
  import { createLogger } from '@unchainedshop/logger';
9
9
  import { getFileAdapter } from '@unchainedshop/core-files';
10
10
 
11
- const logger = createLogger('unchained:plugins:gridfs');
11
+ const logger = createLogger('unchained:gridfs');
12
12
 
13
13
  const gridfsHandler: RouteHandlerMethod = async (
14
14
  req: FastifyRequest & {
@@ -39,9 +39,25 @@ const gridfsHandler: RouteHandlerMethod = async (
39
39
  const fileId = await buildHashedFilename(directoryName, fileName, expiryDate);
40
40
  if ((await sign(directoryName, fileId, expiryDate.getTime())) === signature) {
41
41
  const file = await modules.files.findFile({ fileId });
42
+
43
+ if (!file) {
44
+ reply.status(404);
45
+ logger.error('File not found', { fileId });
46
+ return reply.send({
47
+ success: false,
48
+ message: 'File not found',
49
+ name: 'FILE_NOT_FOUND',
50
+ });
51
+ }
52
+
42
53
  if (file.expires === null) {
43
54
  reply.status(400);
44
- return reply.send('File already linked');
55
+ logger.error('File already linked', { fileId });
56
+ return reply.send({
57
+ success: false,
58
+ message: 'File already linked',
59
+ name: 'FILE_ALREADY_LINKED',
60
+ });
45
61
  }
46
62
  // If the type is octet-stream, prefer mimetype lookup from the filename
47
63
  // Else prefer the content-type header
@@ -54,20 +70,38 @@ const gridfsHandler: RouteHandlerMethod = async (
54
70
  directoryName,
55
71
  fileId,
56
72
  fileName,
57
- { 'content-type': type },
73
+ {
74
+ chunkSizeBytes: 1024 * 1024, // 1MB
75
+ metadata: { 'content-type': type },
76
+ },
58
77
  );
59
78
 
60
- await pipeline(req.raw, new PassThrough(), writeStream);
79
+ await pipeline(
80
+ req.raw,
81
+ new PassThrough({ highWaterMark: 1024 * 1024 * 4 }), // 4MB Buffer
82
+ writeStream,
83
+ );
84
+
85
+ await finished(writeStream, { readable: false });
61
86
 
62
87
  const { length } = writeStream;
63
88
  await services.files.linkFile({ fileId, size: length, type });
64
89
 
65
90
  reply.status(200);
66
- return reply.send();
91
+ return reply.send({
92
+ success: true,
93
+ fileId,
94
+ size: length,
95
+ type,
96
+ });
67
97
  }
68
-
98
+ logger.error('Invalid signature', { fileId, expiryDate });
69
99
  reply.status(403);
70
- return reply.send();
100
+ return reply.send({
101
+ success: false,
102
+ message: 'Access restricted: Invalid signature.',
103
+ name: 'INVALID_SIGNATURE',
104
+ });
71
105
  }
72
106
 
73
107
  if (req.method === 'GET') {
@@ -78,17 +112,31 @@ const gridfsHandler: RouteHandlerMethod = async (
78
112
  if (fileDocument?.meta?.isPrivate) {
79
113
  const expiry = parseInt(expiryTimestamp as string, 10);
80
114
  if (expiry <= Date.now()) {
115
+ logger.error('URL Expired', { fileId, expiry });
81
116
  reply.status(403);
82
- return reply.send('Access restricted: Expired.');
117
+ return reply.send({
118
+ success: false,
119
+ message: 'Access restricted: URL expired.',
120
+ name: 'URL_EXPIRED',
121
+ });
83
122
  }
84
123
 
85
124
  const fileUploadAdapter = getFileAdapter();
86
125
  const signedUrl = await fileUploadAdapter.createDownloadURL(fileDocument, expiry);
87
126
 
88
- if (new URL(signedUrl, 'file://').searchParams.get('s') !== signature) {
127
+ if (!signedUrl || new URL(signedUrl, 'file://').searchParams.get('s') !== signature) {
89
128
  reply.status(403);
90
- return reply.send('Access restricted: Invalid signature.');
129
+ logger.error('Invalid signature', { fileId, expiry });
130
+ return reply.send({
131
+ success: false,
132
+ message: 'Access restricted: Invalid signature.',
133
+ name: 'INVALID_SIGNATURE',
134
+ });
91
135
  }
136
+ } else if (!fileDocument) {
137
+ logger.error('File not found', { fileId });
138
+ reply.status(404);
139
+ return reply.send();
92
140
  }
93
141
 
94
142
  if (file?.metadata?.['content-type']) {
@@ -107,14 +155,14 @@ const gridfsHandler: RouteHandlerMethod = async (
107
155
  reply.status(404);
108
156
  return reply.send();
109
157
  } catch (e) {
158
+ logger.error(e);
159
+
110
160
  if (e.code === 'ENOENT') {
111
- logger.warn(e);
112
161
  reply.status(404);
113
- return reply.send({ name: e.name, code: e.code, message: e.message });
162
+ return reply.send();
114
163
  } else {
115
- logger.warn(e);
116
164
  reply.status(504);
117
- return reply.send({ name: e.name, code: e.code, message: e.message });
165
+ return reply.send({ success: false, name: e.name, code: e.code, message: e.message });
118
166
  }
119
167
  }
120
168
  };
@@ -5,10 +5,15 @@ export const configureGridFSFileUploadModule = ({ db }) => {
5
5
  let { GridFSBucket } = mongodb;
6
6
 
7
7
  return {
8
- createWriteStream: async (directoryName, fileId, fileName, metadata) => {
8
+ createWriteStream: async (
9
+ directoryName,
10
+ fileId,
11
+ fileName,
12
+ uploadOptions: mongodb.GridFSBucketWriteStream['options'],
13
+ ) => {
9
14
  const options = { bucketName: `file_uploads_${directoryName}` };
10
15
  const bucket = new GridFSBucket(db, options);
11
- return bucket.openUploadStreamWithId(fileId, fileName, { metadata });
16
+ return bucket.openUploadStreamWithId(fileId, fileName, uploadOptions);
12
17
  },
13
18
  getFileInfo: async (directoryName, fileId) => {
14
19
  const options = { bucketName: `file_uploads_${directoryName}` };
@@ -1,6 +1,6 @@
1
1
  import { createLogger } from '@unchainedshop/logger';
2
2
 
3
- const logger = createLogger('unchained:plugins:minio');
3
+ const logger = createLogger('unchained:minio');
4
4
 
5
5
  const { MINIO_WEBHOOK_AUTH_TOKEN } = process.env;
6
6
 
@@ -21,17 +21,14 @@ const minioHandler = async (req, res) => {
21
21
  const [fileId] = object.key.split('.');
22
22
  const { services } = req.unchainedContext;
23
23
  await services.files.linkFile({ fileId, type, size });
24
- res.writeHead(200);
25
- res.end();
24
+ res.status(200).end();
26
25
  return;
27
26
  }
28
27
  }
29
- res.writeHead(404);
30
- res.end();
28
+ res.status(404).end();
31
29
  } catch (e) {
32
30
  logger.error(e);
33
- res.writeHead(503);
34
- res.end(JSON.stringify({ name: e.name, code: e.code, message: e.message }));
31
+ res.status(503).send({ name: e.name, code: e.code, message: e.message });
35
32
  }
36
33
  };
37
34
 
@@ -2,7 +2,7 @@ import { Context } from '@unchainedshop/api';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
3
  import { FastifyRequest, RouteHandlerMethod } from 'fastify';
4
4
 
5
- const logger = createLogger('unchained:plugins:minio');
5
+ const logger = createLogger('unchained:minio');
6
6
 
7
7
  const { MINIO_WEBHOOK_AUTH_TOKEN } = process.env;
8
8
 
@@ -37,7 +37,7 @@ const minioHandler: RouteHandlerMethod = async (
37
37
  } catch (e) {
38
38
  logger.error(e);
39
39
  res.status(503);
40
- return res.send(JSON.stringify({ name: e.name, code: e.code, message: e.message }));
40
+ return res.send({ name: e.name, code: e.code, message: e.message });
41
41
  }
42
42
  };
43
43