@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.
- package/lib/accounts/google-oauth.d.ts +4 -0
- package/lib/accounts/google-oauth.d.ts.map +1 -0
- package/lib/accounts/google-oauth.js +145 -0
- package/lib/accounts/google-oauth.js.map +1 -0
- package/lib/accounts/linkedin-oauth.d.ts +4 -0
- package/lib/accounts/linkedin-oauth.d.ts.map +1 -0
- package/lib/accounts/linkedin-oauth.js +82 -0
- package/lib/accounts/linkedin-oauth.js.map +1 -0
- package/lib/delivery/send-message.js.map +1 -1
- package/lib/enrollments/licensed.js +15 -2
- package/lib/enrollments/licensed.js.map +1 -1
- package/lib/files/gridfs/adapter.d.ts.map +1 -1
- package/lib/files/gridfs/adapter.js +19 -11
- package/lib/files/gridfs/adapter.js.map +1 -1
- package/lib/files/gridfs/gridfs-adapter.d.ts +3 -0
- package/lib/files/gridfs/gridfs-adapter.d.ts.map +1 -0
- package/lib/files/gridfs/gridfs-adapter.js +97 -0
- package/lib/files/gridfs/gridfs-adapter.js.map +1 -0
- package/lib/files/gridfs/gridfs-webhook.d.ts +11 -0
- package/lib/files/gridfs/gridfs-webhook.d.ts.map +1 -0
- package/lib/files/gridfs/gridfs-webhook.js +84 -0
- package/lib/files/gridfs/gridfs-webhook.js.map +1 -0
- package/lib/files/gridfs/handler-express.d.ts.map +1 -1
- package/lib/files/gridfs/handler-express.js +27 -24
- package/lib/files/gridfs/handler-express.js.map +1 -1
- package/lib/files/gridfs/handler-fastify.d.ts.map +1 -1
- package/lib/files/gridfs/handler-fastify.js +57 -14
- package/lib/files/gridfs/handler-fastify.js.map +1 -1
- package/lib/files/gridfs/module.d.ts +4 -4
- package/lib/files/gridfs/module.d.ts.map +1 -1
- package/lib/files/gridfs/module.js +2 -2
- package/lib/files/gridfs/module.js.map +1 -1
- package/lib/files/minio/handler-express.d.ts.map +1 -1
- package/lib/files/minio/handler-express.js +4 -7
- package/lib/files/minio/handler-express.js.map +1 -1
- package/lib/files/minio/handler-fastify.js +2 -2
- package/lib/files/minio/handler-fastify.js.map +1 -1
- package/lib/files/minio/index.d.ts +1 -1
- package/lib/files/minio/index.d.ts.map +1 -1
- package/lib/files/minio/index.js +7 -7
- package/lib/files/minio/index.js.map +1 -1
- package/lib/files/minio/minio-adapter.d.ts +6 -0
- package/lib/files/minio/minio-adapter.d.ts.map +1 -0
- package/lib/files/minio/minio-adapter.js +181 -0
- package/lib/files/minio/minio-adapter.js.map +1 -0
- package/lib/files/minio/minio-webhook.d.ts +2 -0
- package/lib/files/minio/minio-webhook.d.ts.map +1 -0
- package/lib/files/minio/minio-webhook.js +33 -0
- package/lib/files/minio/minio-webhook.js.map +1 -0
- package/lib/filters/local-search.js +1 -1
- package/lib/filters/local-search.js.map +1 -1
- package/lib/payment/apple-iap/adapter.js +12 -10
- package/lib/payment/apple-iap/adapter.js.map +1 -1
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts +1 -1
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts.map +1 -1
- package/lib/payment/apple-iap/handler-express.d.ts.map +1 -1
- package/lib/payment/apple-iap/handler-express.js +14 -10
- package/lib/payment/apple-iap/handler-express.js.map +1 -1
- package/lib/payment/apple-iap/handler-fastify.d.ts.map +1 -1
- package/lib/payment/apple-iap/handler-fastify.js +15 -8
- package/lib/payment/apple-iap/handler-fastify.js.map +1 -1
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts +9 -0
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts.map +1 -0
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js +17 -0
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js.map +1 -0
- package/lib/payment/apple-iap/module.d.ts +4 -4
- package/lib/payment/apple-iap/module.d.ts.map +1 -1
- package/lib/payment/apple-iap/module.js +4 -2
- package/lib/payment/apple-iap/module.js.map +1 -1
- package/lib/payment/braintree.js +3 -1
- package/lib/payment/braintree.js.map +1 -1
- package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts +1 -1
- package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts.map +1 -1
- package/lib/payment/cryptopay/derive-btc-address.d.ts.map +1 -1
- package/lib/payment/cryptopay/derive-btc-address.js +2 -3
- package/lib/payment/cryptopay/derive-btc-address.js.map +1 -1
- package/lib/payment/cryptopay/derive-eth-address.d.ts.map +1 -1
- package/lib/payment/cryptopay/derive-eth-address.js +5 -3
- package/lib/payment/cryptopay/derive-eth-address.js.map +1 -1
- package/lib/payment/cryptopay/handle-webhook.js +2 -2
- package/lib/payment/cryptopay/handle-webhook.js.map +1 -1
- package/lib/payment/cryptopay/handler-express.d.ts.map +1 -1
- package/lib/payment/cryptopay/handler-express.js +4 -7
- package/lib/payment/cryptopay/handler-express.js.map +1 -1
- package/lib/payment/cryptopay/handler-fastify.d.ts.map +1 -1
- package/lib/payment/cryptopay/handler-fastify.js +1 -1
- package/lib/payment/cryptopay/handler-fastify.js.map +1 -1
- package/lib/payment/cryptopay/middleware.d.ts +2 -0
- package/lib/payment/cryptopay/middleware.d.ts.map +1 -0
- package/lib/payment/cryptopay/middleware.js +75 -0
- package/lib/payment/cryptopay/middleware.js.map +1 -0
- package/lib/payment/cryptopay/module/configureCryptopayModule.d.ts +25 -0
- package/lib/payment/cryptopay/module/configureCryptopayModule.d.ts.map +1 -0
- package/lib/payment/cryptopay/module/configureCryptopayModule.js +75 -0
- package/lib/payment/cryptopay/module/configureCryptopayModule.js.map +1 -0
- package/lib/payment/cryptopay/module.d.ts +2 -2
- package/lib/payment/cryptopay/module.d.ts.map +1 -1
- package/lib/payment/cryptopay/module.js +4 -4
- package/lib/payment/cryptopay/module.js.map +1 -1
- package/lib/payment/cryptopay/plugin.d.ts.map +1 -1
- package/lib/payment/cryptopay/plugin.js +18 -4
- package/lib/payment/cryptopay/plugin.js.map +1 -1
- package/lib/payment/datatrans-v2/handler-express.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/handler-express.js +13 -11
- package/lib/payment/datatrans-v2/handler-express.js.map +1 -1
- package/lib/payment/datatrans-v2/handler-fastify.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/handler-fastify.js +11 -5
- package/lib/payment/datatrans-v2/handler-fastify.js.map +1 -1
- package/lib/payment/datatrans-v2/index.js +63 -37
- package/lib/payment/datatrans-v2/index.js.map +1 -1
- package/lib/payment/datatrans-v2/middleware.d.ts +2 -0
- package/lib/payment/datatrans-v2/middleware.d.ts.map +1 -0
- package/lib/payment/datatrans-v2/middleware.js +68 -0
- package/lib/payment/datatrans-v2/middleware.js.map +1 -0
- package/lib/payment/datatrans-v2/parseRegistrationData.d.ts +1 -1
- package/lib/payment/datatrans-v2/parseRegistrationData.d.ts.map +1 -1
- package/lib/payment/paypal-checkout.js +8 -8
- package/lib/payment/paypal-checkout.js.map +1 -1
- package/lib/payment/payrexx/api/index.d.ts +1 -1
- package/lib/payment/payrexx/api/index.d.ts.map +1 -1
- package/lib/payment/payrexx/api/makeFetcher.d.ts +1 -1
- package/lib/payment/payrexx/api/makeFetcher.d.ts.map +1 -1
- package/lib/payment/payrexx/api/makeFetcher.js +1 -1
- package/lib/payment/payrexx/api/makeFetcher.js.map +1 -1
- package/lib/payment/payrexx/handler-express.d.ts.map +1 -1
- package/lib/payment/payrexx/handler-express.js +15 -15
- package/lib/payment/payrexx/handler-express.js.map +1 -1
- package/lib/payment/payrexx/handler-fastify.js +23 -15
- package/lib/payment/payrexx/handler-fastify.js.map +1 -1
- package/lib/payment/payrexx/index.js +21 -15
- package/lib/payment/payrexx/index.js.map +1 -1
- package/lib/payment/payrexx/middleware.d.ts +2 -0
- package/lib/payment/payrexx/middleware.d.ts.map +1 -0
- package/lib/payment/payrexx/middleware.js +86 -0
- package/lib/payment/payrexx/middleware.js.map +1 -0
- package/lib/payment/postfinance-checkout/api-client.d.ts +16 -0
- package/lib/payment/postfinance-checkout/api-client.d.ts.map +1 -0
- package/lib/payment/postfinance-checkout/api-client.js +75 -0
- package/lib/payment/postfinance-checkout/api-client.js.map +1 -0
- package/lib/payment/postfinance-checkout/api-types.d.ts +98 -0
- package/lib/payment/postfinance-checkout/api-types.d.ts.map +1 -0
- package/lib/payment/postfinance-checkout/api-types.js +51 -0
- package/lib/payment/postfinance-checkout/api-types.js.map +1 -0
- package/lib/payment/postfinance-checkout/api.d.ts +5 -5
- package/lib/payment/postfinance-checkout/api.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/api.js +38 -62
- package/lib/payment/postfinance-checkout/api.js.map +1 -1
- package/lib/payment/postfinance-checkout/handler-express.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/handler-express.js +10 -11
- package/lib/payment/postfinance-checkout/handler-express.js.map +1 -1
- package/lib/payment/postfinance-checkout/handler-fastify.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/handler-fastify.js +10 -8
- package/lib/payment/postfinance-checkout/handler-fastify.js.map +1 -1
- package/lib/payment/postfinance-checkout/index.d.ts +2 -1
- package/lib/payment/postfinance-checkout/index.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/index.js +44 -32
- package/lib/payment/postfinance-checkout/index.js.map +1 -1
- package/lib/payment/postfinance-checkout/middleware.d.ts +2 -0
- package/lib/payment/postfinance-checkout/middleware.d.ts.map +1 -0
- package/lib/payment/postfinance-checkout/middleware.js +38 -0
- package/lib/payment/postfinance-checkout/middleware.js.map +1 -0
- package/lib/payment/postfinance-checkout/utils.d.ts +3 -3
- package/lib/payment/postfinance-checkout/utils.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/utils.js +3 -4
- package/lib/payment/postfinance-checkout/utils.js.map +1 -1
- package/lib/payment/saferpay/adapter.d.ts.map +1 -1
- package/lib/payment/saferpay/adapter.js +9 -0
- package/lib/payment/saferpay/adapter.js.map +1 -1
- package/lib/payment/saferpay/handler-express.d.ts.map +1 -1
- package/lib/payment/saferpay/handler-express.js +10 -8
- package/lib/payment/saferpay/handler-express.js.map +1 -1
- package/lib/payment/saferpay/handler-fastify.d.ts.map +1 -1
- package/lib/payment/saferpay/handler-fastify.js +11 -5
- package/lib/payment/saferpay/handler-fastify.js.map +1 -1
- package/lib/payment/saferpay/middleware.d.ts +2 -0
- package/lib/payment/saferpay/middleware.d.ts.map +1 -0
- package/lib/payment/saferpay/middleware.js +57 -0
- package/lib/payment/saferpay/middleware.js.map +1 -0
- package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.d.ts +10 -0
- package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.d.ts.map +1 -0
- package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.js +24 -0
- package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.js.map +1 -0
- package/lib/payment/saferpay/module.d.ts +2 -2
- package/lib/payment/stripe/handler-express.js +25 -17
- package/lib/payment/stripe/handler-express.js.map +1 -1
- package/lib/payment/stripe/handler-fastify.d.ts.map +1 -1
- package/lib/payment/stripe/handler-fastify.js +33 -12
- package/lib/payment/stripe/handler-fastify.js.map +1 -1
- package/lib/payment/stripe/index.js +19 -13
- package/lib/payment/stripe/index.js.map +1 -1
- package/lib/payment/stripe/middleware.d.ts +6 -0
- package/lib/payment/stripe/middleware.d.ts.map +1 -0
- package/lib/payment/stripe/middleware.js +114 -0
- package/lib/payment/stripe/middleware.js.map +1 -0
- package/lib/payment/stripe/stripe.d.ts +2 -2
- package/lib/payment/stripe/stripe.d.ts.map +1 -1
- package/lib/payment/stripe/stripe.js +14 -11
- package/lib/payment/stripe/stripe.js.map +1 -1
- package/lib/plugins-index.d.ts +48 -0
- package/lib/plugins-index.d.ts.map +1 -0
- package/lib/plugins-index.js +107 -0
- package/lib/plugins-index.js.map +1 -0
- package/lib/presets/all.d.ts +9 -7
- package/lib/presets/all.d.ts.map +1 -1
- package/lib/presets/all.js +3 -1
- package/lib/presets/all.js.map +1 -1
- package/lib/pricing/delivery-swiss-tax.d.ts.map +1 -1
- package/lib/pricing/delivery-swiss-tax.js +13 -20
- package/lib/pricing/delivery-swiss-tax.js.map +1 -1
- package/lib/pricing/order-discount.d.ts.map +1 -1
- package/lib/pricing/order-discount.js +5 -3
- package/lib/pricing/order-discount.js.map +1 -1
- package/lib/pricing/order-round.d.ts.map +1 -1
- package/lib/pricing/order-round.js +4 -3
- package/lib/pricing/order-round.js.map +1 -1
- package/lib/pricing/product-catalog-price.d.ts.map +1 -1
- package/lib/pricing/product-catalog-price.js +26 -2
- package/lib/pricing/product-catalog-price.js.map +1 -1
- package/lib/pricing/product-price-rateconversion.js +3 -3
- package/lib/pricing/product-price-rateconversion.js.map +1 -1
- package/lib/pricing/product-swiss-tax.d.ts +1 -5
- package/lib/pricing/product-swiss-tax.d.ts.map +1 -1
- package/lib/pricing/product-swiss-tax.js +26 -22
- package/lib/pricing/product-swiss-tax.js.map +1 -1
- package/lib/pricing/tax/ch.d.ts +7 -2
- package/lib/pricing/tax/ch.d.ts.map +1 -1
- package/lib/pricing/tax/ch.js +16 -1
- package/lib/pricing/tax/ch.js.map +1 -1
- package/lib/pricing/utils/isDeliveryAddressInCountry.d.ts +7 -0
- package/lib/pricing/utils/isDeliveryAddressInCountry.d.ts.map +1 -0
- package/lib/pricing/utils/isDeliveryAddressInCountry.js +13 -0
- package/lib/pricing/utils/isDeliveryAddressInCountry.js.map +1 -0
- package/lib/warehousing/eth-minter.js +23 -11
- package/lib/warehousing/eth-minter.js.map +1 -1
- package/lib/worker/budgetsms.d.ts +10 -0
- package/lib/worker/budgetsms.d.ts.map +1 -0
- package/lib/worker/budgetsms.js +217 -0
- package/lib/worker/budgetsms.js.map +1 -0
- package/lib/worker/bulk-import.d.ts +1 -1
- package/lib/worker/bulk-import.d.ts.map +1 -1
- package/lib/worker/bulk-import.js +11 -33
- package/lib/worker/bulk-import.js.map +1 -1
- package/lib/worker/bulkgate.d.ts +2 -0
- package/lib/worker/bulkgate.d.ts.map +1 -0
- package/lib/worker/bulkgate.js +104 -0
- package/lib/worker/bulkgate.js.map +1 -0
- package/lib/worker/email.d.ts.map +1 -1
- package/lib/worker/email.js +25 -7
- package/lib/worker/email.js.map +1 -1
- package/lib/worker/enrollment-order-generator.d.ts.map +1 -1
- package/lib/worker/enrollment-order-generator.js +7 -49
- package/lib/worker/enrollment-order-generator.js.map +1 -1
- package/lib/worker/error-notifications.js +1 -1
- package/lib/worker/error-notifications.js.map +1 -1
- package/lib/worker/export-token.d.ts.map +1 -1
- package/lib/worker/export-token.js +0 -1
- package/lib/worker/export-token.js.map +1 -1
- package/lib/worker/heartbeat.js +2 -8
- package/lib/worker/heartbeat.js.map +1 -1
- package/lib/worker/message.d.ts +1 -1
- package/lib/worker/message.d.ts.map +1 -1
- package/lib/worker/message.js +4 -2
- package/lib/worker/message.js.map +1 -1
- package/lib/worker/sms.js +16 -16
- package/lib/worker/sms.js.map +1 -1
- package/lib/worker/twilio.d.ts +2 -0
- package/lib/worker/twilio.d.ts.map +1 -0
- package/lib/worker/twilio.js +60 -0
- package/lib/worker/twilio.js.map +1 -0
- package/package.json +29 -45
- package/src/delivery/send-message.ts +1 -1
- package/src/enrollments/licensed.ts +15 -2
- package/src/files/gridfs/adapter.ts +24 -10
- package/src/files/gridfs/handler-express.ts +32 -24
- package/src/files/gridfs/handler-fastify.ts +63 -15
- package/src/files/gridfs/module.ts +7 -2
- package/src/files/minio/handler-express.ts +4 -7
- package/src/files/minio/handler-fastify.ts +2 -2
- package/src/files/minio/index.ts +16 -16
- package/src/filters/local-search.ts +1 -1
- package/src/payment/apple-iap/adapter.ts +12 -14
- package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +1 -1
- package/src/payment/apple-iap/handler-express.ts +17 -11
- package/src/payment/apple-iap/handler-fastify.ts +19 -9
- package/src/payment/apple-iap/module.ts +9 -4
- package/src/payment/braintree.ts +4 -1
- package/src/payment/cryptopay/db/CryptopayTransactions.ts +1 -1
- package/src/payment/cryptopay/derive-btc-address.ts +1 -3
- package/src/payment/cryptopay/derive-eth-address.ts +5 -3
- package/src/payment/cryptopay/handle-webhook.ts +6 -6
- package/src/payment/cryptopay/handler-express.ts +4 -7
- package/src/payment/cryptopay/handler-fastify.ts +2 -2
- package/src/payment/cryptopay/module.ts +8 -5
- package/src/payment/cryptopay/plugin.ts +21 -4
- package/src/payment/datatrans-v2/handler-express.ts +17 -12
- package/src/payment/datatrans-v2/handler-fastify.ts +15 -6
- package/src/payment/datatrans-v2/index.ts +82 -50
- package/src/payment/paypal-checkout.ts +8 -11
- package/src/payment/payrexx/api/index.ts +1 -1
- package/src/payment/payrexx/api/makeFetcher.ts +2 -2
- package/src/payment/payrexx/handler-express.ts +24 -32
- package/src/payment/payrexx/handler-fastify.ts +33 -33
- package/src/payment/payrexx/index.ts +26 -16
- package/src/payment/postfinance-checkout/api-client.ts +111 -0
- package/src/payment/postfinance-checkout/api-types.ts +111 -0
- package/src/payment/postfinance-checkout/api.ts +58 -85
- package/src/payment/postfinance-checkout/handler-express.ts +11 -13
- package/src/payment/postfinance-checkout/handler-fastify.ts +11 -10
- package/src/payment/postfinance-checkout/index.ts +60 -38
- package/src/payment/postfinance-checkout/utils.ts +5 -10
- package/src/payment/saferpay/adapter.ts +14 -2
- package/src/payment/saferpay/handler-express.ts +14 -13
- package/src/payment/saferpay/handler-fastify.ts +14 -9
- package/src/payment/stripe/handler-express.ts +33 -33
- package/src/payment/stripe/handler-fastify.ts +40 -27
- package/src/payment/stripe/index.ts +17 -13
- package/src/payment/stripe/stripe.ts +17 -12
- package/src/presets/all.ts +3 -1
- package/src/pricing/delivery-swiss-tax.ts +16 -31
- package/src/pricing/order-discount.ts +6 -4
- package/src/pricing/order-round.ts +5 -4
- package/src/pricing/product-catalog-price.ts +25 -2
- package/src/pricing/product-price-rateconversion.ts +3 -3
- package/src/pricing/product-swiss-tax.ts +39 -40
- package/src/pricing/tax/ch.ts +33 -7
- package/src/pricing/utils/isDeliveryAddressInCountry.test.ts +106 -0
- package/src/pricing/utils/isDeliveryAddressInCountry.ts +26 -0
- package/src/warehousing/eth-minter.ts +30 -11
- package/src/worker/budgetsms.ts +268 -0
- package/src/worker/bulk-import.ts +12 -53
- package/src/worker/bulkgate.ts +138 -0
- package/src/worker/email.ts +30 -8
- package/src/worker/enrollment-order-generator.ts +14 -72
- package/src/worker/error-notifications.ts +2 -2
- package/src/worker/export-token.ts +0 -1
- package/src/worker/heartbeat.ts +2 -9
- package/src/worker/message.ts +5 -3
- package/src/worker/{sms.ts → twilio.ts} +15 -26
- package/lib/payment/cryptopay/de.d.ts +0 -2
- package/lib/payment/cryptopay/de.d.ts.map +0 -1
- package/lib/payment/cryptopay/de.js +0 -10
- package/lib/payment/cryptopay/de.js.map +0 -1
- package/lib/payment/cryptopay/derive-btc-address.test copy.d.ts +0 -2
- package/lib/payment/cryptopay/derive-btc-address.test copy.d.ts.map +0 -1
- package/lib/payment/cryptopay/derive-btc-address.test copy.js +0 -10
- package/lib/payment/cryptopay/derive-btc-address.test copy.js.map +0 -1
- 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.
|
|
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.
|
|
38
|
-
"@unchainedshop/core-delivery": "^4.0.0-rc.
|
|
39
|
-
"@unchainedshop/core-enrollments": "^4.0.0-rc.
|
|
40
|
-
"@unchainedshop/core-orders": "^4.0.0-rc.
|
|
41
|
-
"@unchainedshop/core-payment": "^4.0.0-rc.
|
|
42
|
-
"@unchainedshop/core-products": "^4.0.0-rc.
|
|
43
|
-
"@unchainedshop/core-warehousing": "^4.0.0-rc.
|
|
44
|
-
"@unchainedshop/core-worker": "^4.0.0-rc.
|
|
45
|
-
"@unchainedshop/events": "^4.0.0-rc.
|
|
46
|
-
"@unchainedshop/file-upload": "^4.0.0-rc.
|
|
47
|
-
"@unchainedshop/logger": "^4.0.0-rc.
|
|
48
|
-
"@unchainedshop/utils": "^4.0.0-rc.
|
|
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": ">=
|
|
58
|
-
"@scure/btc-signer": ">=
|
|
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
|
-
"
|
|
66
|
-
"
|
|
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
|
|
132
|
-
"@scure/bip32": "^
|
|
133
|
-
"@scure/btc-signer": "^
|
|
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.
|
|
136
|
-
"@types/node": "^
|
|
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.
|
|
140
|
-
"mime-types": "^3.0.1",
|
|
126
|
+
"fastify": "^5.4.0",
|
|
141
127
|
"minio": "^8.0.5",
|
|
142
|
-
"nodemailer": "^7.0.
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
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"
|
|
@@ -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 =
|
|
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
|
|
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
|
|
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
|
|
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:
|
|
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 =
|
|
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
|
-
{
|
|
92
|
+
{
|
|
93
|
+
metadata: { 'content-type': type },
|
|
94
|
+
chunkSizeBytes: 1024 * 1024, // 1MB
|
|
95
|
+
...options,
|
|
96
|
+
},
|
|
93
97
|
);
|
|
94
|
-
|
|
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 =
|
|
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
|
-
{
|
|
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:
|
|
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.
|
|
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.
|
|
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
|
-
{
|
|
68
|
+
{
|
|
69
|
+
chunkSizeBytes: 1024 * 1024, // 1MB
|
|
70
|
+
metadata: { 'content-type': type },
|
|
71
|
+
},
|
|
65
72
|
);
|
|
66
|
-
await pipeline(
|
|
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.
|
|
72
|
-
res.end();
|
|
84
|
+
res.status(200).end();
|
|
73
85
|
return;
|
|
74
86
|
}
|
|
75
|
-
res.
|
|
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.
|
|
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.
|
|
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.
|
|
113
|
-
res.end();
|
|
124
|
+
res.status(200).end();
|
|
114
125
|
return;
|
|
115
126
|
}
|
|
116
|
-
res.
|
|
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.
|
|
122
|
-
res.end(e.message);
|
|
131
|
+
res.status(404).send();
|
|
123
132
|
} else {
|
|
124
133
|
logger.warn(e);
|
|
125
|
-
res.
|
|
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:
|
|
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
|
-
|
|
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
|
-
{
|
|
73
|
+
{
|
|
74
|
+
chunkSizeBytes: 1024 * 1024, // 1MB
|
|
75
|
+
metadata: { 'content-type': type },
|
|
76
|
+
},
|
|
58
77
|
);
|
|
59
78
|
|
|
60
|
-
await pipeline(
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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 (
|
|
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,
|
|
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:
|
|
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.
|
|
25
|
-
res.end();
|
|
24
|
+
res.status(200).end();
|
|
26
25
|
return;
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
|
-
res.
|
|
30
|
-
res.end();
|
|
28
|
+
res.status(404).end();
|
|
31
29
|
} catch (e) {
|
|
32
30
|
logger.error(e);
|
|
33
|
-
res.
|
|
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:
|
|
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(
|
|
40
|
+
return res.send({ name: e.name, code: e.code, message: e.message });
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
|