@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
@@ -0,0 +1,10 @@
1
+ import {} from '@unchainedshop/core';
2
+ import { Heartbeat } from "./adapter.js";
3
+ export const HeartbeatPlugin = {
4
+ key: 'shop.unchained.worker-plugin.heartbeat',
5
+ label: 'Heartbeat Worker Plugin',
6
+ version: '1.0.0',
7
+ adapters: [Heartbeat],
8
+ };
9
+ export default HeartbeatPlugin;
10
+ export { Heartbeat } from "./adapter.js";
@@ -1,5 +1,5 @@
1
1
  import { type IWorkerAdapter } from '@unchainedshop/core';
2
- declare const HttpRequestWorkerPlugin: IWorkerAdapter<{
2
+ export declare const HttpRequestWorkerPlugin: IWorkerAdapter<{
3
3
  url?: string;
4
4
  data?: any;
5
5
  headers?: any;
@@ -1,4 +1,4 @@
1
- import { WorkerAdapter, WorkerDirector } from '@unchainedshop/core';
1
+ import { WorkerAdapter } from '@unchainedshop/core';
2
2
  const postFetch = async (url, { data, headers }) => {
3
3
  return fetch(url, {
4
4
  method: 'POST',
@@ -13,7 +13,7 @@ const nonPostFetch = async (url, { headers, method = 'GET' }) => {
13
13
  headers,
14
14
  });
15
15
  };
16
- const HttpRequestWorkerPlugin = {
16
+ export const HttpRequestWorkerPlugin = {
17
17
  ...WorkerAdapter,
18
18
  key: 'shop.unchained.worker-plugin.http-request',
19
19
  label: 'Request a resource via http request. 200 = success',
@@ -52,5 +52,4 @@ const HttpRequestWorkerPlugin = {
52
52
  }
53
53
  },
54
54
  };
55
- WorkerDirector.registerAdapter(HttpRequestWorkerPlugin);
56
55
  export default HttpRequestWorkerPlugin;
@@ -0,0 +1,4 @@
1
+ import { type IPlugin } from '@unchainedshop/core';
2
+ export declare const HttpRequestPlugin: IPlugin;
3
+ export default HttpRequestPlugin;
4
+ export { HttpRequestWorkerPlugin } from './adapter.ts';
@@ -0,0 +1,10 @@
1
+ import {} from '@unchainedshop/core';
2
+ import { HttpRequestWorkerPlugin as HttpRequestWorker } from "./adapter.js";
3
+ export const HttpRequestPlugin = {
4
+ key: 'shop.unchained.worker-plugin.http-request',
5
+ label: 'HTTP Request Worker Plugin',
6
+ version: '1.0.0',
7
+ adapters: [HttpRequestWorker],
8
+ };
9
+ export default HttpRequestPlugin;
10
+ export { HttpRequestWorkerPlugin } from "./adapter.js";
@@ -8,3 +8,4 @@ export declare const MessageWorker: IWorkerAdapter<{
8
8
  info?: string;
9
9
  forked?: Work[];
10
10
  }>;
11
+ export default MessageWorker;
@@ -1,4 +1,4 @@
1
- import { MessagingDirector, WorkerAdapter, WorkerDirector, } from '@unchainedshop/core';
1
+ import { MessagingDirector, WorkerAdapter } from '@unchainedshop/core';
2
2
  export const MessageWorker = {
3
3
  ...WorkerAdapter,
4
4
  key: 'shop.unchained.worker-plugin.message',
@@ -39,4 +39,4 @@ export const MessageWorker = {
39
39
  }
40
40
  },
41
41
  };
42
- WorkerDirector.registerAdapter(MessageWorker);
42
+ export default MessageWorker;
@@ -0,0 +1,4 @@
1
+ import { type IPlugin } from '@unchainedshop/core';
2
+ export declare const MessagePlugin: IPlugin;
3
+ export default MessagePlugin;
4
+ export * from './adapter.ts';
@@ -0,0 +1,10 @@
1
+ import {} from '@unchainedshop/core';
2
+ import { MessageWorker } from "./adapter.js";
3
+ export const MessagePlugin = {
4
+ key: 'shop.unchained.worker-plugin.message',
5
+ label: 'Message Worker Plugin',
6
+ version: '1.0.0',
7
+ adapters: [MessageWorker],
8
+ };
9
+ export default MessagePlugin;
10
+ export * from "./adapter.js";
@@ -0,0 +1,9 @@
1
+ import { type IWorkerAdapter } from '@unchainedshop/core';
2
+ export declare const PushNotificationWorkerPlugin: IWorkerAdapter<{
3
+ subscription: any;
4
+ payload: string;
5
+ subject: string;
6
+ urgency?: 'very-low' | 'low' | 'normal' | 'high';
7
+ topic?: string;
8
+ }, any>;
9
+ export default PushNotificationWorkerPlugin;
@@ -1,4 +1,4 @@
1
- import { WorkerAdapter, WorkerDirector } from '@unchainedshop/core';
1
+ import { WorkerAdapter } from '@unchainedshop/core';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
3
  const logger = createLogger('unchained:worker:push-notification');
4
4
  let webPush;
@@ -10,7 +10,7 @@ catch {
10
10
  logger.warn(`optional peer npm package 'web-push' not installed, push notifications will not work`);
11
11
  }
12
12
  const { PUSH_NOTIFICATION_PUBLIC_KEY, PUSH_NOTIFICATION_PRIVATE_KEY } = process.env;
13
- const PushNotificationWorkerPlugin = {
13
+ export const PushNotificationWorkerPlugin = {
14
14
  ...WorkerAdapter,
15
15
  key: 'shop.unchained.worker-plugin.push-notification',
16
16
  label: 'Push Notification',
@@ -84,4 +84,4 @@ const PushNotificationWorkerPlugin = {
84
84
  }
85
85
  },
86
86
  };
87
- WorkerDirector.registerAdapter(PushNotificationWorkerPlugin);
87
+ export default PushNotificationWorkerPlugin;
@@ -0,0 +1,4 @@
1
+ import { type IPlugin } from '@unchainedshop/core';
2
+ export declare const PushNotificationPlugin: IPlugin;
3
+ export default PushNotificationPlugin;
4
+ export { PushNotificationWorkerPlugin } from './adapter.ts';
@@ -0,0 +1,10 @@
1
+ import {} from '@unchainedshop/core';
2
+ import { PushNotificationWorkerPlugin as PushNotificationWorker } from "./adapter.js";
3
+ export const PushNotificationPlugin = {
4
+ key: 'shop.unchained.worker-plugin.push-notification',
5
+ label: 'Push Notification Worker Plugin',
6
+ version: '1.0.0',
7
+ adapters: [PushNotificationWorker],
8
+ };
9
+ export default PushNotificationPlugin;
10
+ export { PushNotificationWorkerPlugin } from "./adapter.js";
@@ -0,0 +1,8 @@
1
+ import { type IWorkerAdapter } from '@unchainedshop/core';
2
+ export declare const SmsWorkerPlugin: IWorkerAdapter<{
3
+ from?: string;
4
+ to: string;
5
+ text: string;
6
+ [key: string]: any;
7
+ }, any>;
8
+ export default SmsWorkerPlugin;
@@ -1,6 +1,6 @@
1
- import { WorkerAdapter, WorkerDirector } from '@unchainedshop/core';
1
+ import { WorkerAdapter } from '@unchainedshop/core';
2
2
  const { TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_SMS_FROM } = process.env;
3
- const SmsWorkerPlugin = {
3
+ export const SmsWorkerPlugin = {
4
4
  ...WorkerAdapter,
5
5
  key: 'shop.unchained.worker-plugin.twilio',
6
6
  label: 'Send Messages through Twilio',
@@ -56,4 +56,4 @@ const SmsWorkerPlugin = {
56
56
  }
57
57
  },
58
58
  };
59
- WorkerDirector.registerAdapter(SmsWorkerPlugin);
59
+ export default SmsWorkerPlugin;
@@ -0,0 +1,4 @@
1
+ import { type IPlugin } from '@unchainedshop/core';
2
+ export declare const TwilioPlugin: IPlugin;
3
+ export default TwilioPlugin;
4
+ export { SmsWorkerPlugin } from './adapter.ts';
@@ -0,0 +1,10 @@
1
+ import {} from '@unchainedshop/core';
2
+ import { SmsWorkerPlugin as TwilioWorker } from "./adapter.js";
3
+ export const TwilioPlugin = {
4
+ key: 'shop.unchained.worker-plugin.twilio',
5
+ label: 'Twilio SMS Worker Plugin',
6
+ version: '1.0.0',
7
+ adapters: [TwilioWorker],
8
+ };
9
+ export default TwilioPlugin;
10
+ export { SmsWorkerPlugin } from "./adapter.js";
@@ -0,0 +1,4 @@
1
+ import { type IWorkerAdapter } from '@unchainedshop/core';
2
+ export declare const UpdateCoinbaseRates: IWorkerAdapter<any, any>;
3
+ export default UpdateCoinbaseRates;
4
+ export declare const configureUpdateCoinbaseRatesAutoscheduling: () => void;
@@ -8,7 +8,7 @@ const getExchangeRates = async (base) => {
8
8
  .then((r) => r?.data);
9
9
  };
10
10
  const everyMinute = schedule.parse.cron('* * * * *');
11
- const UpdateCoinbaseRates = {
11
+ export const UpdateCoinbaseRates = {
12
12
  ...WorkerAdapter,
13
13
  key: 'shop.unchained.worker.update-coinbase-rates',
14
14
  label: 'Update Coinbase Rates',
@@ -52,8 +52,10 @@ const UpdateCoinbaseRates = {
52
52
  }
53
53
  },
54
54
  };
55
- WorkerDirector.registerAdapter(UpdateCoinbaseRates);
56
- WorkerDirector.configureAutoscheduling({
57
- type: UpdateCoinbaseRates.type,
58
- schedule: everyMinute,
59
- });
55
+ export default UpdateCoinbaseRates;
56
+ export const configureUpdateCoinbaseRatesAutoscheduling = () => {
57
+ WorkerDirector.configureAutoscheduling({
58
+ type: UpdateCoinbaseRates.type,
59
+ schedule: everyMinute,
60
+ });
61
+ };
@@ -0,0 +1,4 @@
1
+ import { type IPlugin } from '@unchainedshop/core';
2
+ export declare const UpdateCoinbaseRatesPlugin: IPlugin;
3
+ export default UpdateCoinbaseRatesPlugin;
4
+ export { UpdateCoinbaseRates, configureUpdateCoinbaseRatesAutoscheduling } from './adapter.ts';
@@ -0,0 +1,13 @@
1
+ import {} from '@unchainedshop/core';
2
+ import { UpdateCoinbaseRates, configureUpdateCoinbaseRatesAutoscheduling } from "./adapter.js";
3
+ export const UpdateCoinbaseRatesPlugin = {
4
+ key: 'shop.unchained.worker.update-coinbase-rates',
5
+ label: 'Update Coinbase Rates Worker Plugin',
6
+ version: '1.0.0',
7
+ adapters: [UpdateCoinbaseRates],
8
+ onRegister: () => {
9
+ configureUpdateCoinbaseRatesAutoscheduling();
10
+ },
11
+ };
12
+ export default UpdateCoinbaseRatesPlugin;
13
+ export { UpdateCoinbaseRates, configureUpdateCoinbaseRatesAutoscheduling } from "./adapter.js";
@@ -0,0 +1,4 @@
1
+ import { type IWorkerAdapter } from '@unchainedshop/core';
2
+ export declare const UpdateECBRates: IWorkerAdapter<any, any>;
3
+ export default UpdateECBRates;
4
+ export declare const configureUpdateECBRatesAutoscheduling: () => void;
@@ -21,7 +21,7 @@ const getExchangeRates = async () => {
21
21
  };
22
22
  const everyDayAtFour = schedule.parse.cron('0 15 * * *');
23
23
  const baseCurrency = 'EUR';
24
- const UpdateECBRates = {
24
+ export const UpdateECBRates = {
25
25
  ...WorkerAdapter,
26
26
  key: 'shop.unchained.worker.update-ecb-rates',
27
27
  label: 'Update ECB Rates',
@@ -82,11 +82,13 @@ const UpdateECBRates = {
82
82
  }
83
83
  },
84
84
  };
85
- WorkerDirector.registerAdapter(UpdateECBRates);
86
- if (xml2json) {
87
- WorkerDirector.configureAutoscheduling({
88
- type: UpdateECBRates.type,
89
- schedule: everyDayAtFour,
90
- retries: 5,
91
- });
92
- }
85
+ export default UpdateECBRates;
86
+ export const configureUpdateECBRatesAutoscheduling = () => {
87
+ if (xml2json) {
88
+ WorkerDirector.configureAutoscheduling({
89
+ type: UpdateECBRates.type,
90
+ schedule: everyDayAtFour,
91
+ retries: 5,
92
+ });
93
+ }
94
+ };
@@ -0,0 +1,4 @@
1
+ import { type IPlugin } from '@unchainedshop/core';
2
+ export declare const UpdateECBRatesPlugin: IPlugin;
3
+ export default UpdateECBRatesPlugin;
4
+ export { UpdateECBRates, configureUpdateECBRatesAutoscheduling } from './adapter.ts';
@@ -0,0 +1,13 @@
1
+ import {} from '@unchainedshop/core';
2
+ import { UpdateECBRates, configureUpdateECBRatesAutoscheduling } from "./adapter.js";
3
+ export const UpdateECBRatesPlugin = {
4
+ key: 'shop.unchained.worker.update-ecb-rates',
5
+ label: 'Update ECB Rates Worker Plugin',
6
+ version: '1.0.0',
7
+ adapters: [UpdateECBRates],
8
+ onRegister: () => {
9
+ configureUpdateECBRatesAutoscheduling();
10
+ },
11
+ };
12
+ export default UpdateECBRatesPlugin;
13
+ export { UpdateECBRates, configureUpdateECBRatesAutoscheduling } from "./adapter.js";
@@ -1,3 +1,5 @@
1
1
  import { type IWorkerAdapter } from '@unchainedshop/core';
2
2
  export declare const UpdateTokenOwnership: IWorkerAdapter<void, void>;
3
3
  export declare const RefreshTokens: IWorkerAdapter<void, any>;
4
+ export default UpdateTokenOwnership;
5
+ export declare const configureRefreshTokensAutoscheduling: () => void;
@@ -48,10 +48,11 @@ export const RefreshTokens = {
48
48
  return { success: true, result: { forked } };
49
49
  },
50
50
  };
51
- WorkerDirector.registerAdapter(RefreshTokens);
52
- WorkerDirector.registerAdapter(UpdateTokenOwnership);
53
- WorkerDirector.configureAutoscheduling({
54
- type: RefreshTokens.type,
55
- schedule: everyMinute,
56
- retries: 0,
57
- });
51
+ export default UpdateTokenOwnership;
52
+ export const configureRefreshTokensAutoscheduling = () => {
53
+ WorkerDirector.configureAutoscheduling({
54
+ type: RefreshTokens.type,
55
+ schedule: everyMinute,
56
+ retries: 0,
57
+ });
58
+ };
@@ -0,0 +1,4 @@
1
+ import { type IPlugin } from '@unchainedshop/core';
2
+ export declare const UpdateTokenOwnershipPlugin: IPlugin;
3
+ export default UpdateTokenOwnershipPlugin;
4
+ export { UpdateTokenOwnership, RefreshTokens, configureRefreshTokensAutoscheduling } from './adapter.ts';
@@ -0,0 +1,13 @@
1
+ import {} from '@unchainedshop/core';
2
+ import { UpdateTokenOwnership, RefreshTokens, configureRefreshTokensAutoscheduling } from "./adapter.js";
3
+ export const UpdateTokenOwnershipPlugin = {
4
+ key: 'shop.unchained.worker.update-token-ownership',
5
+ label: 'Update Token Ownership Worker Plugin',
6
+ version: '1.0.0',
7
+ adapters: [UpdateTokenOwnership, RefreshTokens],
8
+ onRegister: () => {
9
+ configureRefreshTokensAutoscheduling();
10
+ },
11
+ };
12
+ export default UpdateTokenOwnershipPlugin;
13
+ export { UpdateTokenOwnership, RefreshTokens, configureRefreshTokensAutoscheduling } from "./adapter.js";
@@ -1,4 +1,4 @@
1
- import { WorkerAdapter, WorkerDirector } from '@unchainedshop/core';
1
+ import { WorkerAdapter } from '@unchainedshop/core';
2
2
  export const ZombieKillerWorker = {
3
3
  ...WorkerAdapter,
4
4
  key: 'shop.unchained.worker-plugin.zombie-killer',
@@ -88,4 +88,3 @@ export const ZombieKillerWorker = {
88
88
  },
89
89
  };
90
90
  export default ZombieKillerWorker;
91
- WorkerDirector.registerAdapter(ZombieKillerWorker);
@@ -0,0 +1,4 @@
1
+ import { type IPlugin } from '@unchainedshop/core';
2
+ export declare const ZombieKillerPlugin: IPlugin;
3
+ export default ZombieKillerPlugin;
4
+ export { ZombieKillerWorker } from './adapter.ts';
@@ -0,0 +1,10 @@
1
+ import {} from '@unchainedshop/core';
2
+ import { ZombieKillerWorker } from "./adapter.js";
3
+ export const ZombieKillerPlugin = {
4
+ key: 'shop.unchained.worker-plugin.zombie-killer',
5
+ label: 'Zombie Killer Worker Plugin',
6
+ version: '1.0.0',
7
+ adapters: [ZombieKillerWorker],
8
+ };
9
+ export default ZombieKillerPlugin;
10
+ export { ZombieKillerWorker } from "./adapter.js";
package/package.json CHANGED
@@ -1,11 +1,22 @@
1
1
  {
2
2
  "name": "@unchainedshop/plugins",
3
3
  "description": "Official plugin collection for the Unchained Engine with payment, delivery, and pricing adapters",
4
- "version": "4.6.1",
4
+ "version": "4.7.2",
5
5
  "main": "lib/plugins-index.js",
6
6
  "types": "lib/plugins-index.d.ts",
7
7
  "exports": {
8
- "./*": "./lib/*"
8
+ "./presets/*": "./lib/presets/*.js",
9
+ "./presets/countries/*": "./lib/presets/countries/*.js",
10
+ "./events/*": "./lib/events/*.js",
11
+ "./enrollments/*": "./lib/enrollments/*/index.js",
12
+ "./quotations/*": "./lib/quotations/*/index.js",
13
+ "./filters/*": "./lib/filters/*/index.js",
14
+ "./delivery/*": "./lib/delivery/*/index.js",
15
+ "./warehousing/*": "./lib/warehousing/*/index.js",
16
+ "./payment/*": "./lib/payment/*/index.js",
17
+ "./files/*": "./lib/files/*/index.js",
18
+ "./pricing/*": "./lib/pricing/*/index.js",
19
+ "./worker/*": "./lib/worker/*/index.js"
9
20
  },
10
21
  "type": "module",
11
22
  "scripts": {
@@ -46,13 +57,11 @@
46
57
  "@unchainedshop/core-warehousing": "^4.6.0",
47
58
  "@unchainedshop/core-worker": "^4.6.0",
48
59
  "@unchainedshop/events": "^4.6.0",
49
- "@unchainedshop/file-upload": "^4.6.0",
50
60
  "@unchainedshop/logger": "^4.6.0",
51
61
  "@unchainedshop/utils": "^4.6.0"
52
62
  },
53
63
  "peerDependencies": {
54
64
  "@aws-sdk/client-eventbridge": ">= 3.714 < 4",
55
- "@paypal/checkout-server-sdk": "1.x",
56
65
  "@redis/client": ">= 1 < 6",
57
66
  "@scure/bip32": ">= 2",
58
67
  "@scure/btc-signer": ">= 2",
@@ -61,7 +70,7 @@
61
70
  "express": ">= 5 < 6",
62
71
  "fastify": ">= 5.2 < 6",
63
72
  "minio": "8.x",
64
- "nodemailer": ">= 6.9 < 8",
73
+ "nodemailer": ">= 6.9 < 9",
65
74
  "p-memoize": "8.x",
66
75
  "stripe": ">= 19 < 21",
67
76
  "web-push": ">= 3.6 <4",
@@ -71,9 +80,6 @@
71
80
  "@aws-sdk/client-eventbridge": {
72
81
  "optional": true
73
82
  },
74
- "@paypal/checkout-server-sdk": {
75
- "optional": true
76
- },
77
83
  "@redis/client": {
78
84
  "optional": true
79
85
  },
@@ -112,7 +118,6 @@
112
118
  }
113
119
  },
114
120
  "devDependencies": {
115
- "@paypal/checkout-server-sdk": "^1.0.3",
116
121
  "@redis/client": "^5.6.0",
117
122
  "@scure/bip32": "^2.0.0",
118
123
  "@scure/btc-signer": "^2.0.0",
@@ -122,7 +127,7 @@
122
127
  "express": "^5.1.0",
123
128
  "fastify": "^5.4.0",
124
129
  "minio": "^8.0.5",
125
- "nodemailer": "^7.0.5",
130
+ "nodemailer": "^8.0.1",
126
131
  "p-memoize": "^8.0.0",
127
132
  "stripe": "^20.0.0",
128
133
  "typescript": "^5.8.3",
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export declare const rangeMatcher: (date?: Date) => ({ start, end }: {
2
- start: any;
3
- end: any;
4
- }) => boolean;
@@ -1,9 +0,0 @@
1
- import express from 'express';
2
- import { type GridFSFileUploadsModule } from './module.ts';
3
- import { type Context } from '@unchainedshop/api';
4
- declare const gridfsHandler: (req: express.Request & {
5
- unchainedContext: Context & {
6
- modules: GridFSFileUploadsModule;
7
- };
8
- }, res: express.Response) => Promise<void>;
9
- export default gridfsHandler;
@@ -1,110 +0,0 @@
1
- import { pipeline, finished } from 'node:stream/promises';
2
- import { PassThrough } from 'node:stream';
3
- import { buildHashedFilename } from '@unchainedshop/file-upload';
4
- import express from 'express';
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 { ROOT_URL, GRIDFS_PUT_SERVER_PATH = '/gridfs' } = process.env;
12
- const logger = createLogger('unchained:gridfs');
13
- const gridfsHandler = async (req, res) => {
14
- try {
15
- const { services, modules } = req.unchainedContext;
16
- const url = new URL(req.url, ROOT_URL);
17
- const [, directoryNameRaw, fileNameRaw] = url.pathname.split('/');
18
- const directoryName = decodeURIComponent(directoryNameRaw);
19
- const fileName = decodeURIComponent(fileNameRaw);
20
- res.setHeader('Access-Control-Allow-Methods', 'GET, PUT');
21
- res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
22
- res.setHeader('Access-Control-Allow-Origin', '*');
23
- if (req.method === 'OPTIONS') {
24
- res.status(200).end();
25
- return;
26
- }
27
- if (req.method === 'PUT') {
28
- const { s: signature, e: expiryTimestamp } = req.query;
29
- const expiryDate = new Date(parseInt(expiryTimestamp, 10));
30
- const fileId = await buildHashedFilename(directoryName, fileName, expiryDate);
31
- const expectedSignature = await sign(directoryName, fileId, expiryDate.getTime());
32
- if (await timingSafeStringEqual(expectedSignature, signature)) {
33
- const file = await modules.files.findFile({ fileId });
34
- if (!file) {
35
- res.status(404).send('File not found');
36
- return;
37
- }
38
- if (file.expires === null) {
39
- res.status(400).send('File already linked');
40
- return;
41
- }
42
- const type = req.header('Content-Type') === 'application/octet-stream'
43
- ? file.type || req.header('Content-Type')
44
- : req.header('Content-Type') || file.type;
45
- const writeStream = await modules.gridfsFileUploads.createWriteStream(directoryName, fileId, fileName, {
46
- chunkSizeBytes: 1024 * 1024,
47
- metadata: { 'content-type': type },
48
- });
49
- await pipeline(req, new PassThrough({ highWaterMark: 1024 * 1024 * 4 }), writeStream);
50
- await finished(writeStream, { readable: false });
51
- const { length } = writeStream;
52
- await services.files.linkFile({ fileId, size: length, type });
53
- res.status(200).end();
54
- return;
55
- }
56
- res.status(403).end();
57
- return;
58
- }
59
- if (req.method === 'GET') {
60
- const { s: signature, e: expiryTimestamp } = req.query;
61
- const fileDocument = await modules.files.findFile({
62
- url: `${GRIDFS_PUT_SERVER_PATH}/${directoryName}/${fileName}`,
63
- });
64
- if (fileDocument?.meta?.isPrivate) {
65
- const expiry = parseInt(expiryTimestamp, 10);
66
- if (expiry <= Date.now()) {
67
- res.status(403).send('Access restricted: Expired.');
68
- return;
69
- }
70
- const fileUploadAdapter = getFileAdapter();
71
- const signedUrl = await fileUploadAdapter.createDownloadURL(fileDocument, expiry);
72
- const expectedSignature = signedUrl ? new URL(signedUrl, 'file://').searchParams.get('s') : null;
73
- if (!signedUrl ||
74
- !expectedSignature ||
75
- !(await timingSafeStringEqual(expectedSignature, signature))) {
76
- res.status(403).send('Access restricted: Invalid signature.');
77
- return;
78
- }
79
- }
80
- else if (!fileDocument) {
81
- res.status(404).end();
82
- return;
83
- }
84
- const file = await modules.gridfsFileUploads.getFileInfo(directoryName, fileDocument._id);
85
- if (file?.metadata?.['content-type']) {
86
- res.setHeader('Content-Type', file.metadata['content-type']);
87
- }
88
- if (file?.length) {
89
- res.setHeader('Content-Length', file?.length.toString());
90
- }
91
- const readStream = await modules.gridfsFileUploads.createReadStream(directoryName, fileDocument._id);
92
- readStream.pipe(res, { end: false });
93
- await finished(readStream);
94
- res.status(200).end();
95
- return;
96
- }
97
- res.status(404).end();
98
- }
99
- catch (e) {
100
- if (e.code === 'ENOENT') {
101
- logger.warn(e);
102
- res.status(404).send();
103
- }
104
- else {
105
- logger.warn(e);
106
- res.status(503).send({ name: e.name, code: e.code, message: e.message });
107
- }
108
- }
109
- };
110
- export default gridfsHandler;
@@ -1,3 +0,0 @@
1
- import { type RouteHandlerMethod } from 'fastify';
2
- declare const gridfsHandler: RouteHandlerMethod;
3
- export default gridfsHandler;