@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
@@ -0,0 +1,106 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
3
+ import isDeliveryAddressInCountry from './isDeliveryAddressInCountry.js';
4
+
5
+ describe('isDeliveryAddressInCountry', () => {
6
+ const context = {
7
+ modules: {
8
+ orders: {
9
+ deliveries: {
10
+ findDelivery: async ({ orderDeliveryId }: any) => {
11
+ if (orderDeliveryId === 'CH' || orderDeliveryId === 'LI')
12
+ return { context: { address: { countryCode: 'CH' } } };
13
+ if (orderDeliveryId === null) return { context: { address: null } };
14
+ return { context: { address: { countryCode: 'RT' } } };
15
+ },
16
+ },
17
+ },
18
+ },
19
+ order: {
20
+ deliveryId: 'CH',
21
+ billingAddress: { countryCode: 'LI' },
22
+ },
23
+ countryCode: 'CH',
24
+ };
25
+ it('Should return true when passed country code CH', async () => {
26
+ assert.strictEqual(
27
+ await isDeliveryAddressInCountry({ ...context, countryCode: 'ch', order: null } as any, [
28
+ 'CH',
29
+ 'LI',
30
+ ]),
31
+ true,
32
+ );
33
+ });
34
+
35
+ it('Should return true when passed country code LI', async () => {
36
+ assert.strictEqual(
37
+ await isDeliveryAddressInCountry({ ...context, countryCode: 'LI', order: null } as any, [
38
+ 'CH',
39
+ 'LI',
40
+ ]),
41
+ true,
42
+ );
43
+ });
44
+
45
+ it('Should return false when country is neither CH nor LI and order is null', async () => {
46
+ assert.strictEqual(
47
+ await isDeliveryAddressInCountry({ ...context, countryCode: 'ET', order: null } as any, [
48
+ 'CH',
49
+ 'LI',
50
+ ]),
51
+ false,
52
+ );
53
+ });
54
+
55
+ it('Order should take precedence over country parameter', async () => {
56
+ // not CH or LI order so returns false
57
+ assert.strictEqual(
58
+ await isDeliveryAddressInCountry(
59
+ {
60
+ ...context,
61
+ countryCode: 'CH',
62
+ order: {
63
+ deliveryId: 'ET',
64
+ billingAddress: { countryCode: 'ET' },
65
+ },
66
+ } as any,
67
+ ['CH', 'LI'],
68
+ ),
69
+ false,
70
+ );
71
+ });
72
+
73
+ it('If order is not from CH and LI but billingAddress is, it should take precedence over country ', async () => {
74
+ assert.strictEqual(
75
+ await isDeliveryAddressInCountry(
76
+ {
77
+ ...context,
78
+ countryCode: 'IT',
79
+ order: {
80
+ deliveryId: null,
81
+ billingAddress: { countryCode: 'CH' },
82
+ },
83
+ } as any,
84
+ ['CH', 'LI'],
85
+ ),
86
+ true,
87
+ );
88
+ });
89
+
90
+ it('Should return false if billingAddress is neither CH or LI and order does not have address', async () => {
91
+ assert.strictEqual(
92
+ await isDeliveryAddressInCountry(
93
+ {
94
+ ...context,
95
+ country: null,
96
+ order: {
97
+ deliveryId: null,
98
+ billingAddress: { countryCode: 'HH' },
99
+ },
100
+ } as any,
101
+ ['CH', 'LI'],
102
+ ),
103
+ false,
104
+ );
105
+ });
106
+ });
@@ -0,0 +1,26 @@
1
+ import { Order, OrderDelivery } from '@unchainedshop/core-orders';
2
+
3
+ export default function isDeliveryAddressInCountry(
4
+ {
5
+ orderDelivery,
6
+ order,
7
+ countryCode: forceCountryCode = null,
8
+ }: {
9
+ orderDelivery?: OrderDelivery | null;
10
+ order?: Order | null;
11
+ countryCode?: string | null;
12
+ },
13
+ allowedCountryCodes: string[],
14
+ ) {
15
+ let countryCode = forceCountryCode?.toUpperCase().trim() || order?.countryCode;
16
+
17
+ if (orderDelivery || order) {
18
+ const address = orderDelivery?.context?.address || order?.billingAddress;
19
+ if (address?.countryCode > '') {
20
+ countryCode = address.countryCode?.toUpperCase().trim();
21
+ }
22
+ }
23
+
24
+ if (!countryCode) return false;
25
+ return allowedCountryCodes.includes(countryCode);
26
+ }
@@ -11,9 +11,12 @@ import { ProductContractStandard, ProductTypes } from '@unchainedshop/core-produ
11
11
  import { systemLocale } from '@unchainedshop/utils';
12
12
  import { generateDbObjectId } from '@unchainedshop/mongodb';
13
13
  import { getFileAdapter } from '@unchainedshop/core-files';
14
+ import { createLogger } from '@unchainedshop/logger';
14
15
 
15
16
  const { MINTER_TOKEN_OFFSET = '0', ROOT_URL = 'http://localhost:4010' } = process.env;
16
17
 
18
+ const logger = createLogger('unchained:eth-minter');
19
+
17
20
  const ETHMinter: IWarehousingAdapter = {
18
21
  ...WarehousingAdapter,
19
22
 
@@ -40,7 +43,7 @@ const ETHMinter: IWarehousingAdapter = {
40
43
  ? { contractAddress: contractStandard }
41
44
  : {
42
45
  contractAddress: contractStandard,
43
- chainTokenId: tokenId,
46
+ tokenSerialNumber: tokenId,
44
47
  },
45
48
  );
46
49
  const tokensCreated = existingTokens.reduce((acc, curToken) => {
@@ -57,7 +60,13 @@ const ETHMinter: IWarehousingAdapter = {
57
60
  },
58
61
 
59
62
  configurationError() {
60
- return null as any as WarehousingError;
63
+ if (contractStandard === 'ERC1155' && !tokenId) {
64
+ logger.error(
65
+ `Token ID is required for ERC1155 contract standard (productId: ${product!._id})`,
66
+ );
67
+ return WarehousingError.INCOMPLETE_CONFIGURATION;
68
+ }
69
+ return null;
61
70
  },
62
71
 
63
72
  stock: async () => {
@@ -74,11 +83,17 @@ const ETHMinter: IWarehousingAdapter = {
74
83
  const meta = { contractStandard };
75
84
  const tokensCreated = await getTokensCreated();
76
85
 
86
+ if (!orderPosition) {
87
+ throw new Error('Order position not found in context');
88
+ }
89
+
77
90
  if (contractStandard === 'ERC721') {
78
- // ERC721 is non-fungible, thus every chainTokenId unique!
79
- const items = new Array(orderPosition?.quantity).fill(null).map((_, i) => ({
91
+ // ERC721 is non-fungible, thus every tokenSerialNumber unique!
92
+ const items = new Array(orderPosition.quantity).fill(null).map((_, i) => ({
80
93
  _id: generateDbObjectId(),
81
- chainTokenId: Number(parseInt(MINTER_TOKEN_OFFSET, 10) + tokensCreated + (i + 1)).toString(),
94
+ tokenSerialNumber: Number(
95
+ parseInt(MINTER_TOKEN_OFFSET, 10) + tokensCreated + (i + 1),
96
+ ).toString(),
82
97
  contractAddress,
83
98
  quantity: 1,
84
99
  chainId,
@@ -90,20 +105,24 @@ const ETHMinter: IWarehousingAdapter = {
90
105
  return [
91
106
  {
92
107
  _id: generateDbObjectId(),
93
- chainTokenId: tokenId,
108
+ tokenSerialNumber: tokenId!,
94
109
  contractAddress,
95
- quantity: orderPosition?.quantity,
110
+ quantity: orderPosition.quantity,
96
111
  chainId,
97
112
  meta,
98
113
  },
99
114
  ];
100
115
  },
101
116
 
102
- tokenMetadata: async (chainTokenId) => {
117
+ tokenMetadata: async (tokenSerialNumber) => {
103
118
  // Metadata standards supported
104
119
  // https://eips.ethereum.org/EIPS/eip-1155 (backward compatible with 721)
105
120
  // https://eips.ethereum.org/EIPS/eip-721
106
121
 
122
+ if (!product) {
123
+ throw new Error('Product not found in context');
124
+ }
125
+
107
126
  const allLanguages = await modules.languages.findLanguages({
108
127
  includeInactive: false,
109
128
  });
@@ -114,15 +133,15 @@ const ETHMinter: IWarehousingAdapter = {
114
133
  });
115
134
  const file = firstMedia && (await modules.files.findFile({ fileId: firstMedia.mediaId }));
116
135
 
117
- const fileUploadAdapter = getFileAdapter();
118
- const signedUrl = await fileUploadAdapter.createDownloadURL(file);
136
+ const fileAdapter = file && getFileAdapter();
137
+ const signedUrl = await fileAdapter?.createDownloadURL(file!);
119
138
  const url = signedUrl && (await modules.files.normalizeUrl(signedUrl, {}));
120
139
  const text = await modules.products.texts.findLocalizedText({
121
140
  productId: product._id,
122
141
  locale: locale || systemLocale,
123
142
  });
124
143
 
125
- const name = `${text.title} #${chainTokenId}`;
144
+ const name = `${text.title} #${tokenSerialNumber}`;
126
145
 
127
146
  const isDefaultLanguageActive = locale ? locale.language === systemLocale.language : true;
128
147
  const localization = isDefaultLanguageActive
@@ -0,0 +1,268 @@
1
+ import { IWorkerAdapter, WorkerAdapter, WorkerDirector } from '@unchainedshop/core';
2
+
3
+ const { BUDGETSMS_USERNAME, BUDGETSMS_USERID, BUDGETSMS_HANDLE } = process.env;
4
+
5
+ // BudgetSMS Plugin - Verified against official API documentation
6
+ // Note: BudgetSMS API has a quirk where it returns error 1001 (authentication failed)
7
+ // when you have insufficient credit, instead of the correct error 1003.
8
+ const BudgetSMSWorker: IWorkerAdapter<
9
+ {
10
+ from?: string;
11
+ to: string;
12
+ text?: string;
13
+ test?: boolean; // If true, uses test endpoint (no credit deducted)
14
+ customid?: string;
15
+ price?: boolean; // Include price info in response
16
+ mccmnc?: boolean; // Include carrier info in response
17
+ credit?: boolean; // Include remaining credit in response
18
+ [key: string]: any;
19
+ },
20
+ any
21
+ > = {
22
+ ...WorkerAdapter,
23
+
24
+ key: 'shop.unchained.worker-plugin.budgetsms',
25
+ label: 'Send Messages through BudgetSMS',
26
+ version: '1.0.0',
27
+
28
+ type: 'BUDGETSMS',
29
+
30
+ doWork: async ({
31
+ from,
32
+ to,
33
+ text,
34
+ test = false,
35
+ customid,
36
+ price = false,
37
+ mccmnc = false,
38
+ credit = false,
39
+ ...params
40
+ }) => {
41
+ try {
42
+ // Validate credentials
43
+ if (!BUDGETSMS_USERNAME || !BUDGETSMS_USERID || !BUDGETSMS_HANDLE) {
44
+ throw new Error(
45
+ 'Missing BudgetSMS credentials. Please set BUDGETSMS_USERNAME, BUDGETSMS_USERID, and BUDGETSMS_HANDLE',
46
+ );
47
+ }
48
+
49
+ // Trim credentials to remove any whitespace
50
+ const username = BUDGETSMS_USERNAME.trim();
51
+ const userid = BUDGETSMS_USERID.trim();
52
+ const handle = BUDGETSMS_HANDLE.trim();
53
+
54
+ // Validate userid is numeric only
55
+ if (!/^\d+$/.test(userid)) {
56
+ throw new Error('BUDGETSMS_USERID must be numeric only. Found: ' + userid);
57
+ }
58
+
59
+ // Choose endpoint based on test mode
60
+ const url = test ? 'https://api.budgetsms.net/testsms/' : 'https://api.budgetsms.net/sendsms/';
61
+
62
+ // Format phone number according to E.164 (no + or 00, no spaces/dashes)
63
+ const formattedTo = to.replace(/^\+|^00/, '').replace(/[\s-]/g, '');
64
+
65
+ // Build query parameters
66
+ const queryParams = new URLSearchParams({
67
+ username: username,
68
+ userid: userid,
69
+ handle: handle,
70
+ msg: text || '', // Note: parameter is 'msg' not 'text'
71
+ from: from || '',
72
+ to: formattedTo,
73
+ ...(customid && { customid }),
74
+ ...(!test && price && { price: '1' }), // Price info only for real sends
75
+ ...(!test && mccmnc && { mccmnc: '1' }), // Carrier info only for real sends
76
+ ...(!test && credit && { credit: '1' }), // Credit info only for real sends
77
+ ...params,
78
+ });
79
+
80
+ // Make GET request
81
+ const fullUrl = `${url}?${queryParams.toString()}`;
82
+
83
+ const response = await fetch(fullUrl, {
84
+ method: 'GET',
85
+ headers: {
86
+ Accept: 'text/plain',
87
+ 'User-Agent': 'Unchained/BudgetSMS-Plugin',
88
+ },
89
+ });
90
+
91
+ const responseText = await response.text().then((text) => text.trim());
92
+
93
+ // Parse response: "OK <smsid> [price] [parts] [mccmnc] [credit]" or "ERR <errorcode>"
94
+ if (responseText.startsWith('OK')) {
95
+ const parts = responseText.split(' ');
96
+ const result: any = {
97
+ sms_id: parts[1] || null,
98
+ status: test ? 'test_successful' : 'sent',
99
+ test_mode: test,
100
+ };
101
+
102
+ if (test) {
103
+ result.message = 'Test SMS validated successfully (no credit deducted)';
104
+ } else {
105
+ // Parse additional info based on parameters used
106
+ let index = 2;
107
+ if (price && parts[index] && parts[index + 1]) {
108
+ result.price = parseFloat(parts[index]);
109
+ result.parts = parseInt(parts[index + 1]);
110
+ index += 2;
111
+ }
112
+ if (mccmnc && parts[index]) {
113
+ result.mccmnc = parts[index];
114
+ index += 1;
115
+ }
116
+ if (credit && parts[index]) {
117
+ result.remaining_credit = parseFloat(parts[index]);
118
+ }
119
+ }
120
+
121
+ return {
122
+ success: true,
123
+ result,
124
+ error: null,
125
+ };
126
+ }
127
+
128
+ if (responseText.startsWith('ERR')) {
129
+ const parts = responseText.split(' ');
130
+ const errorCode = parts[1] || 'UNKNOWN';
131
+
132
+ // Error code mappings from documentation
133
+ const errorMessages: Record<string, string> = {
134
+ '1001': 'Authentication failed OR insufficient credit (BudgetSMS returns 1001 for both)',
135
+ '1002': 'Account not active',
136
+ '1003': 'Insufficient credit',
137
+ '1004': 'No access to this API',
138
+ '1005': 'No handle provided',
139
+ '1006': 'No UserID provided',
140
+ '1007': 'No Username provided',
141
+ '2001': 'SMS message text is empty',
142
+ '2002': 'SMS numeric senderid can be max. 16 numbers',
143
+ '2003': 'SMS alphanumeric sender can be max. 11 characters',
144
+ '2004': 'SMS senderid is empty or invalid',
145
+ '2005': 'Destination number is too short',
146
+ '2006': 'Destination is not numeric',
147
+ '2007': 'Destination is empty',
148
+ '2008': 'SMS text is not OK (check encoding?)',
149
+ '2009': 'Parameter issue',
150
+ '2010': 'Destination number is invalidly formatted',
151
+ '2011': 'Destination is invalid',
152
+ '2012': 'SMS message text is too long',
153
+ '2013': 'SMS message is invalid',
154
+ '2014': 'SMS CustomID is used before',
155
+ '2015': 'Charset problem',
156
+ '2016': 'Invalid UTF-8 encoding',
157
+ '3001': 'No route to destination',
158
+ '3002': 'No routes are setup',
159
+ '3003': 'Invalid destination',
160
+ '4001': 'System error, related to customid',
161
+ '4002': 'System error, temporary issue',
162
+ };
163
+
164
+ // Special handling for 1001 error
165
+ let message = errorMessages[errorCode] || `Unknown error code: ${errorCode}`;
166
+ if (errorCode === '1001') {
167
+ message += '. Note: Check your account balance - BudgetSMS may return 1001 when credit is 0.';
168
+ }
169
+
170
+ return {
171
+ success: false,
172
+ error: {
173
+ name: 'BUDGETSMS_ERROR',
174
+ code: errorCode,
175
+ message,
176
+ },
177
+ };
178
+ }
179
+
180
+ // Unexpected response
181
+ return {
182
+ success: false,
183
+ error: {
184
+ name: 'BUDGETSMS_ERROR',
185
+ message: 'Unexpected response format from BudgetSMS API',
186
+ response: responseText,
187
+ },
188
+ };
189
+ } catch (err) {
190
+ return {
191
+ success: false,
192
+ error: {
193
+ name: err.name,
194
+ message: err.message,
195
+ stack: err.stack,
196
+ },
197
+ };
198
+ }
199
+ },
200
+ };
201
+
202
+ WorkerDirector.registerAdapter(BudgetSMSWorker);
203
+
204
+ // Environment variables needed:
205
+ // BUDGETSMS_USERNAME=your_username (alphanumeric)
206
+ // BUDGETSMS_USERID=your_userid (NUMERIC ONLY - found in BudgetSMS control panel)
207
+ // BUDGETSMS_HANDLE=your_api_handle (alphanumeric - found in BudgetSMS control panel)
208
+
209
+ // IMPORTANT: The userid MUST be numeric only. You can find it in the BudgetSMS control panel after login.
210
+ // Example: BUDGETSMS_USERID=12345 (NOT "user12345" or any non-numeric value)
211
+
212
+ // Usage examples:
213
+ //
214
+ // Send real SMS (requires credits):
215
+ // await WorkerDirector.doWork({
216
+ // type: 'BUDGETSMS',
217
+ // from: 'YourCompany',
218
+ // to: '+41791234567',
219
+ // text: 'Your message here',
220
+ // price: true, // Get price info
221
+ // credit: true, // Get remaining credit
222
+ // });
223
+ //
224
+ // Test SMS (no credit deducted):
225
+ // await WorkerDirector.doWork({
226
+ // type: 'BUDGETSMS',
227
+ // test: true,
228
+ // from: 'YourCompany',
229
+ // to: '+41791234567',
230
+ // text: 'Test message',
231
+ // });
232
+ //
233
+ // IMPORTANT: If you get error 1001, it could mean either:
234
+ // 1. Authentication failed (wrong credentials)
235
+ // 2. Insufficient credit (0 balance)
236
+ // Use the checkBudgetSmsCredentials() helper to verify which one it is.
237
+
238
+ // Helper function to check credentials and balance
239
+ export async function checkBudgetSmsCredentials() {
240
+ const url = 'https://api.budgetsms.net/checkcredit/';
241
+ const username = process.env.BUDGETSMS_USERNAME?.trim();
242
+ const userid = process.env.BUDGETSMS_USERID?.trim();
243
+ const handle = process.env.BUDGETSMS_HANDLE?.trim();
244
+
245
+ if (!username || !userid || !handle) {
246
+ return { error: 'Missing credentials' };
247
+ }
248
+
249
+ if (!/^\d+$/.test(userid)) {
250
+ return { error: 'UserID must be numeric only' };
251
+ }
252
+
253
+ const queryParams = new URLSearchParams({ username, userid, handle });
254
+
255
+ try {
256
+ const response = await fetch(`${url}?${queryParams.toString()}`, { method: 'GET' });
257
+ const text = await response.text();
258
+
259
+ if (text.startsWith('OK')) {
260
+ const credit = parseFloat(text.split(' ')[1]) || 0;
261
+ return { success: true, credit };
262
+ } else {
263
+ return { error: text };
264
+ }
265
+ } catch (err) {
266
+ return { error: err.message };
267
+ }
268
+ }
@@ -1,57 +1,9 @@
1
1
  import { WorkerDirector, WorkerAdapter, IWorkerAdapter } from '@unchainedshop/core';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
- import JSONStream from 'JSONStream';
4
- import { EventIterator } from 'event-iterator';
5
- import { UnchainedCore } from '@unchainedshop/core';
6
3
 
7
- const logger = createLogger('unchained:worker:bulk-import');
4
+ const logger = createLogger('unchained:bulk-import');
8
5
 
9
- const streamPayloadToBulkImporter = async (
10
- bulkImporter,
11
- payloadId,
12
- unchainedAPI: Pick<UnchainedCore, 'bulkImporter' | 'modules' | 'services'>,
13
- ) => {
14
- logger.trace(`parseAsync start`);
15
-
16
- const readStream = await unchainedAPI.services.files.createDownloadStream({ fileId: payloadId });
17
-
18
- if (!readStream) {
19
- throw new Error(
20
- 'The current file adapter does not support streams when downloading required for streamed events. Please use a different file adapter.',
21
- );
22
- }
23
-
24
- const eventIterator = new EventIterator(
25
- (queue) => {
26
- const jsonStream = JSONStream.parse('events.*'); // rows, ANYTHING, doc
27
- jsonStream.on('data', queue.push);
28
- jsonStream.on('close', queue.stop);
29
- jsonStream.on('error', queue.fail);
30
-
31
- queue.on('highWater', () => readStream.pause());
32
- queue.on('lowWater', () => readStream.resume());
33
-
34
- readStream.pipe(jsonStream);
35
- readStream.on('error', queue.fail);
36
-
37
- return () => {
38
- jsonStream.removeListener('data', queue.push);
39
- jsonStream.removeListener('close', queue.stop);
40
- jsonStream.removeListener('error', queue.fail);
41
- jsonStream.destroy();
42
- };
43
- },
44
- { highWaterMark: 100, lowWaterMark: 5 },
45
- );
46
-
47
- for await (const event of eventIterator) {
48
- await bulkImporter.prepare(event, unchainedAPI);
49
- }
50
-
51
- logger.trace(`parseAsync done`);
52
- };
53
-
54
- export const BulkImportWorker: IWorkerAdapter<any, Record<string, unknown>> = {
6
+ export const BulkImportWorker: IWorkerAdapter<any, Record<string, any>> = {
55
7
  ...WorkerAdapter,
56
8
 
57
9
  key: 'shop.unchained.worker-plugin.bulk-import',
@@ -76,13 +28,20 @@ export const BulkImportWorker: IWorkerAdapter<any, Record<string, unknown>> = {
76
28
 
77
29
  if (rawPayload.payloadId) {
78
30
  // stream payload from gridfs
79
- await streamPayloadToBulkImporter(bulkImporter, rawPayload.payloadId, unchainedAPI);
31
+ const readStream = await unchainedAPI.services.files.createDownloadStream({
32
+ fileId: rawPayload.payloadId,
33
+ });
34
+ if (!readStream) {
35
+ throw new Error('Could not create download stream from uploaded file');
36
+ }
37
+ await unchainedAPI.bulkImporter.pipeEventStream(readStream, bulkImporter, unchainedAPI);
80
38
  } else {
81
39
  const { events } = rawPayload;
82
40
  if (!events?.length) throw new Error('No events submitted');
83
41
 
84
42
  await events.reduce(async (currentEventPromise, nextEvent) => {
85
43
  await currentEventPromise;
44
+ await bulkImporter.validate(nextEvent);
86
45
  return bulkImporter.prepare(nextEvent, unchainedAPI);
87
46
  }, Promise.resolve());
88
47
  }
@@ -93,13 +52,13 @@ export const BulkImportWorker: IWorkerAdapter<any, Record<string, unknown>> = {
93
52
  if (error) {
94
53
  return {
95
54
  success: false,
96
- result,
55
+ result: result!,
97
56
  error,
98
57
  };
99
58
  }
100
59
  return {
101
60
  success: true,
102
- result,
61
+ result: result!,
103
62
  };
104
63
  } catch (err) {
105
64
  logger.error(err);