@unchainedshop/plugins 4.0.0-rc.8 → 4.0.0
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 +11 -8
- 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 +21 -25
- 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 +50 -13
- package/lib/files/gridfs/handler-fastify.js.map +1 -1
- package/lib/files/gridfs/module.d.ts +2 -2
- 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/filters/strict-equal.js +0 -18
- package/lib/filters/strict-equal.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.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 +4 -2
- 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.map +1 -1
- package/lib/payment/postfinance-checkout/api-client.js +7 -7
- package/lib/payment/postfinance-checkout/api-client.js.map +1 -1
- package/lib/payment/postfinance-checkout/handler-express.js +7 -8
- 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 +6 -4
- package/lib/payment/postfinance-checkout/handler-fastify.js.map +1 -1
- package/lib/payment/postfinance-checkout/index.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/index.js +20 -7
- 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/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 +21 -15
- 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 +8 -6
- 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-options.d.ts +2 -0
- package/lib/pricing/product-catalog-price-options.d.ts.map +1 -0
- package/lib/pricing/product-catalog-price-options.js +52 -0
- package/lib/pricing/product-catalog-price-options.js.map +1 -0
- 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/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 +17 -17
- 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 +22 -33
- package/src/delivery/send-message.ts +1 -1
- package/src/enrollments/licensed.ts +15 -2
- package/src/files/gridfs/adapter.ts +12 -7
- package/src/files/gridfs/handler-express.ts +23 -25
- package/src/files/gridfs/handler-fastify.ts +53 -14
- 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/filters/strict-equal.ts +0 -21
- 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 +1 -1
- 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 +4 -2
- 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 +13 -8
- package/src/payment/postfinance-checkout/handler-express.ts +8 -8
- package/src/payment/postfinance-checkout/handler-fastify.ts +7 -4
- package/src/payment/postfinance-checkout/index.ts +20 -8
- 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 +18 -16
- 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-options.ts +67 -0
- 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/message.ts +5 -3
- package/src/worker/{sms.ts → twilio.ts} +15 -26
- 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
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"main": "lib/plugins-index.js",
|
|
5
5
|
"types": "lib/plugins-index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -34,37 +34,34 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@unchainedshop/api": "^4.0.0
|
|
38
|
-
"@unchainedshop/core-delivery": "^4.0.0
|
|
39
|
-
"@unchainedshop/core-enrollments": "^4.0.0
|
|
40
|
-
"@unchainedshop/core-orders": "^4.0.0
|
|
41
|
-
"@unchainedshop/core-payment": "^4.0.0
|
|
42
|
-
"@unchainedshop/core-products": "^4.0.0
|
|
43
|
-
"@unchainedshop/core-warehousing": "^4.0.0
|
|
44
|
-
"@unchainedshop/core-worker": "^4.0.0
|
|
45
|
-
"@unchainedshop/events": "^4.0.0
|
|
46
|
-
"@unchainedshop/file-upload": "^4.0.0
|
|
47
|
-
"@unchainedshop/logger": "^4.0.0
|
|
48
|
-
"@unchainedshop/utils": "^4.0.0
|
|
49
|
-
"event-iterator": "^2.0.0",
|
|
50
|
-
"JSONStream": "^1.3.5"
|
|
37
|
+
"@unchainedshop/api": "^4.0.0",
|
|
38
|
+
"@unchainedshop/core-delivery": "^4.0.0",
|
|
39
|
+
"@unchainedshop/core-enrollments": "^4.0.0",
|
|
40
|
+
"@unchainedshop/core-orders": "^4.0.0",
|
|
41
|
+
"@unchainedshop/core-payment": "^4.0.0",
|
|
42
|
+
"@unchainedshop/core-products": "^4.0.0",
|
|
43
|
+
"@unchainedshop/core-warehousing": "^4.0.0",
|
|
44
|
+
"@unchainedshop/core-worker": "^4.0.0",
|
|
45
|
+
"@unchainedshop/events": "^4.0.0",
|
|
46
|
+
"@unchainedshop/file-upload": "^4.0.0",
|
|
47
|
+
"@unchainedshop/logger": "^4.0.0",
|
|
48
|
+
"@unchainedshop/utils": "^4.0.0"
|
|
51
49
|
},
|
|
52
50
|
"peerDependencies": {
|
|
53
51
|
"@aws-sdk/client-eventbridge": ">= 3.714 < 4",
|
|
54
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
|
-
"stripe": ">= 17 < 19",
|
|
63
|
+
"p-memoize": "8.x",
|
|
64
|
+
"stripe": ">= 19 < 20",
|
|
68
65
|
"web-push": ">= 3.6 <4",
|
|
69
66
|
"xml-js": ">= 1.6 < 2"
|
|
70
67
|
},
|
|
@@ -96,18 +93,12 @@
|
|
|
96
93
|
"fastify": {
|
|
97
94
|
"optional": true
|
|
98
95
|
},
|
|
99
|
-
"mime-types": {
|
|
100
|
-
"optional": true
|
|
101
|
-
},
|
|
102
96
|
"minio": {
|
|
103
97
|
"optional": true
|
|
104
98
|
},
|
|
105
99
|
"nodemailer": {
|
|
106
100
|
"optional": true
|
|
107
101
|
},
|
|
108
|
-
"open": {
|
|
109
|
-
"optional": true
|
|
110
|
-
},
|
|
111
102
|
"p-memoize": {
|
|
112
103
|
"optional": true
|
|
113
104
|
},
|
|
@@ -125,20 +116,18 @@
|
|
|
125
116
|
"@breejs/later": "^4.2.0",
|
|
126
117
|
"@paypal/checkout-server-sdk": "^1.0.3",
|
|
127
118
|
"@redis/client": "^5.6.0",
|
|
128
|
-
"@scure/bip32": "^
|
|
129
|
-
"@scure/btc-signer": "^
|
|
119
|
+
"@scure/bip32": "^2.0.0",
|
|
120
|
+
"@scure/btc-signer": "^2.0.0",
|
|
130
121
|
"@types/breejs__later": "^4.1.5",
|
|
131
122
|
"@types/express": "^5.0.3",
|
|
132
123
|
"@types/node": "^24.0.13",
|
|
133
124
|
"expiry-map": "^2.0.0",
|
|
134
125
|
"express": "^5.1.0",
|
|
135
126
|
"fastify": "^5.4.0",
|
|
136
|
-
"mime-types": "^3.0.1",
|
|
137
127
|
"minio": "^8.0.5",
|
|
138
128
|
"nodemailer": "^7.0.5",
|
|
139
|
-
"
|
|
140
|
-
"
|
|
141
|
-
"stripe": "^18.3.0",
|
|
129
|
+
"p-memoize": "^8.0.0",
|
|
130
|
+
"stripe": "^19.1.0",
|
|
142
131
|
"tsx": "^4.20.3",
|
|
143
132
|
"typescript": "^5.8.3",
|
|
144
133
|
"web-push": "^3.6.7",
|
|
@@ -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,7 +63,7 @@ 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 };
|
|
@@ -83,7 +83,7 @@ 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,
|
|
@@ -91,14 +91,19 @@ export const GridFSAdapter: IFileAdapter<
|
|
|
91
91
|
fileName,
|
|
92
92
|
{
|
|
93
93
|
metadata: { 'content-type': type },
|
|
94
|
+
chunkSizeBytes: 1024 * 1024, // 1MB
|
|
94
95
|
...options,
|
|
95
96
|
},
|
|
96
97
|
);
|
|
98
|
+
|
|
97
99
|
await pipeline(
|
|
98
100
|
stream,
|
|
99
|
-
new PassThrough({
|
|
101
|
+
new PassThrough({ highWaterMark: 1024 * 1024 * 4 }), // 4MB Buffer
|
|
100
102
|
writeStream,
|
|
101
103
|
);
|
|
104
|
+
|
|
105
|
+
await finished(writeStream, { readable: false });
|
|
106
|
+
|
|
102
107
|
const { length } = writeStream;
|
|
103
108
|
const url = `/gridfs/${directoryName}/${encodeURIComponent(hashedFilename)}`;
|
|
104
109
|
|
|
@@ -126,7 +131,7 @@ export const GridFSAdapter: IFileAdapter<
|
|
|
126
131
|
|
|
127
132
|
const response = await fetch(href, { headers });
|
|
128
133
|
if (!response.ok) throw new Error(`Unexpected response for ${href}: ${response.statusText}`);
|
|
129
|
-
const type =
|
|
134
|
+
const type = mime.getType(fileName) || response.headers.get('content-type');
|
|
130
135
|
|
|
131
136
|
const writeStream = await modules.gridfsFileUploads.createWriteStream(
|
|
132
137
|
directoryName,
|
|
@@ -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
|
|
@@ -62,24 +66,25 @@ const gridfsHandler = async (
|
|
|
62
66
|
fileId,
|
|
63
67
|
fileName,
|
|
64
68
|
{
|
|
69
|
+
chunkSizeBytes: 1024 * 1024, // 1MB
|
|
65
70
|
metadata: { 'content-type': type },
|
|
66
71
|
},
|
|
67
72
|
);
|
|
68
73
|
await pipeline(
|
|
69
74
|
req,
|
|
70
|
-
new PassThrough({
|
|
75
|
+
new PassThrough({ highWaterMark: 1024 * 1024 * 4 }), // 4MB Buffer
|
|
71
76
|
writeStream,
|
|
72
77
|
);
|
|
73
78
|
|
|
79
|
+
await finished(writeStream, { readable: false });
|
|
80
|
+
|
|
74
81
|
const { length } = writeStream;
|
|
75
82
|
await services.files.linkFile({ fileId, size: length, type });
|
|
76
83
|
|
|
77
|
-
res.
|
|
78
|
-
res.end();
|
|
84
|
+
res.status(200).end();
|
|
79
85
|
return;
|
|
80
86
|
}
|
|
81
|
-
res.
|
|
82
|
-
res.end();
|
|
87
|
+
res.status(403).end();
|
|
83
88
|
return;
|
|
84
89
|
}
|
|
85
90
|
|
|
@@ -91,22 +96,19 @@ const gridfsHandler = async (
|
|
|
91
96
|
if (fileDocument?.meta?.isPrivate) {
|
|
92
97
|
const expiry = parseInt(expiryTimestamp as string, 10);
|
|
93
98
|
if (expiry <= Date.now()) {
|
|
94
|
-
res.
|
|
95
|
-
res.end('Access restricted: Expired.');
|
|
99
|
+
res.status(403).send('Access restricted: Expired.');
|
|
96
100
|
return;
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
const fileUploadAdapter = getFileAdapter();
|
|
100
104
|
const signedUrl = await fileUploadAdapter.createDownloadURL(fileDocument, expiry);
|
|
101
105
|
|
|
102
|
-
if (new URL(signedUrl, 'file://').searchParams.get('s') !== signature) {
|
|
103
|
-
res.
|
|
104
|
-
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.');
|
|
105
108
|
return;
|
|
106
109
|
}
|
|
107
110
|
} else if (!fileDocument) {
|
|
108
|
-
res.
|
|
109
|
-
res.end();
|
|
111
|
+
res.status(404).end();
|
|
110
112
|
return;
|
|
111
113
|
}
|
|
112
114
|
if (file?.metadata?.['content-type']) {
|
|
@@ -119,21 +121,17 @@ const gridfsHandler = async (
|
|
|
119
121
|
const readStream = await modules.gridfsFileUploads.createReadStream(directoryName, fileId);
|
|
120
122
|
readStream.pipe(res, { end: false });
|
|
121
123
|
await finished(readStream);
|
|
122
|
-
res.
|
|
123
|
-
res.end();
|
|
124
|
+
res.status(200).end();
|
|
124
125
|
return;
|
|
125
126
|
}
|
|
126
|
-
res.
|
|
127
|
-
res.end();
|
|
127
|
+
res.status(404).end();
|
|
128
128
|
} catch (e) {
|
|
129
129
|
if (e.code === 'ENOENT') {
|
|
130
130
|
logger.warn(e);
|
|
131
|
-
res.
|
|
132
|
-
res.end(e.message);
|
|
131
|
+
res.status(404).send();
|
|
133
132
|
} else {
|
|
134
133
|
logger.warn(e);
|
|
135
|
-
res.
|
|
136
|
-
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 });
|
|
137
135
|
}
|
|
138
136
|
}
|
|
139
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
|
|
@@ -55,25 +71,37 @@ const gridfsHandler: RouteHandlerMethod = async (
|
|
|
55
71
|
fileId,
|
|
56
72
|
fileName,
|
|
57
73
|
{
|
|
74
|
+
chunkSizeBytes: 1024 * 1024, // 1MB
|
|
58
75
|
metadata: { 'content-type': type },
|
|
59
76
|
},
|
|
60
77
|
);
|
|
61
78
|
|
|
62
79
|
await pipeline(
|
|
63
80
|
req.raw,
|
|
64
|
-
new PassThrough({
|
|
81
|
+
new PassThrough({ highWaterMark: 1024 * 1024 * 4 }), // 4MB Buffer
|
|
65
82
|
writeStream,
|
|
66
83
|
);
|
|
67
84
|
|
|
85
|
+
await finished(writeStream, { readable: false });
|
|
86
|
+
|
|
68
87
|
const { length } = writeStream;
|
|
69
88
|
await services.files.linkFile({ fileId, size: length, type });
|
|
70
89
|
|
|
71
90
|
reply.status(200);
|
|
72
|
-
return reply.send(
|
|
91
|
+
return reply.send({
|
|
92
|
+
success: true,
|
|
93
|
+
fileId,
|
|
94
|
+
size: length,
|
|
95
|
+
type,
|
|
96
|
+
});
|
|
73
97
|
}
|
|
74
|
-
|
|
98
|
+
logger.error('Invalid signature', { fileId, expiryDate });
|
|
75
99
|
reply.status(403);
|
|
76
|
-
return reply.send(
|
|
100
|
+
return reply.send({
|
|
101
|
+
success: false,
|
|
102
|
+
message: 'Access restricted: Invalid signature.',
|
|
103
|
+
name: 'INVALID_SIGNATURE',
|
|
104
|
+
});
|
|
77
105
|
}
|
|
78
106
|
|
|
79
107
|
if (req.method === 'GET') {
|
|
@@ -84,18 +112,29 @@ const gridfsHandler: RouteHandlerMethod = async (
|
|
|
84
112
|
if (fileDocument?.meta?.isPrivate) {
|
|
85
113
|
const expiry = parseInt(expiryTimestamp as string, 10);
|
|
86
114
|
if (expiry <= Date.now()) {
|
|
115
|
+
logger.error('URL Expired', { fileId, expiry });
|
|
87
116
|
reply.status(403);
|
|
88
|
-
return reply.send(
|
|
117
|
+
return reply.send({
|
|
118
|
+
success: false,
|
|
119
|
+
message: 'Access restricted: URL expired.',
|
|
120
|
+
name: 'URL_EXPIRED',
|
|
121
|
+
});
|
|
89
122
|
}
|
|
90
123
|
|
|
91
124
|
const fileUploadAdapter = getFileAdapter();
|
|
92
125
|
const signedUrl = await fileUploadAdapter.createDownloadURL(fileDocument, expiry);
|
|
93
126
|
|
|
94
|
-
if (new URL(signedUrl, 'file://').searchParams.get('s') !== signature) {
|
|
127
|
+
if (!signedUrl || new URL(signedUrl, 'file://').searchParams.get('s') !== signature) {
|
|
95
128
|
reply.status(403);
|
|
96
|
-
|
|
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
|
+
});
|
|
97
135
|
}
|
|
98
136
|
} else if (!fileDocument) {
|
|
137
|
+
logger.error('File not found', { fileId });
|
|
99
138
|
reply.status(404);
|
|
100
139
|
return reply.send();
|
|
101
140
|
}
|
|
@@ -116,14 +155,14 @@ const gridfsHandler: RouteHandlerMethod = async (
|
|
|
116
155
|
reply.status(404);
|
|
117
156
|
return reply.send();
|
|
118
157
|
} catch (e) {
|
|
158
|
+
logger.error(e);
|
|
159
|
+
|
|
119
160
|
if (e.code === 'ENOENT') {
|
|
120
|
-
logger.warn(e);
|
|
121
161
|
reply.status(404);
|
|
122
|
-
return reply.send(
|
|
162
|
+
return reply.send();
|
|
123
163
|
} else {
|
|
124
|
-
logger.warn(e);
|
|
125
164
|
reply.status(504);
|
|
126
|
-
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 });
|
|
127
166
|
}
|
|
128
167
|
}
|
|
129
168
|
};
|
|
@@ -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
|
|
package/src/files/minio/index.ts
CHANGED
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
resolveExpirationDate,
|
|
9
9
|
IFileAdapter,
|
|
10
10
|
} from '@unchainedshop/file-upload';
|
|
11
|
-
import
|
|
11
|
+
import mime from 'mime/lite';
|
|
12
12
|
import { Client } from 'minio';
|
|
13
13
|
import { AssumeRoleProvider } from 'minio/dist/esm/AssumeRoleProvider.mjs';
|
|
14
14
|
import { expiryOffsetInMs } from '@unchainedshop/file-upload/lib/put-expiration.js';
|
|
15
15
|
import { createLogger } from '@unchainedshop/logger';
|
|
16
16
|
|
|
17
|
-
const logger = createLogger('unchained:
|
|
17
|
+
const logger = createLogger('unchained:minio');
|
|
18
18
|
|
|
19
19
|
const {
|
|
20
20
|
MINIO_ACCESS_KEY,
|
|
@@ -28,7 +28,7 @@ const {
|
|
|
28
28
|
AMAZON_S3_SESSION_TOKEN,
|
|
29
29
|
} = process.env;
|
|
30
30
|
|
|
31
|
-
let client: Client;
|
|
31
|
+
let client: Client | null = null;
|
|
32
32
|
|
|
33
33
|
export async function connectToMinio() {
|
|
34
34
|
if (!MINIO_ENDPOINT || !MINIO_BUCKET_NAME) {
|
|
@@ -56,8 +56,8 @@ export async function connectToMinio() {
|
|
|
56
56
|
if (MINIO_STS_ENDPOINT) {
|
|
57
57
|
const ap = new AssumeRoleProvider({
|
|
58
58
|
stsEndpoint: MINIO_STS_ENDPOINT,
|
|
59
|
-
accessKey: MINIO_ACCESS_KEY
|
|
60
|
-
secretKey: MINIO_SECRET_KEY
|
|
59
|
+
accessKey: MINIO_ACCESS_KEY!,
|
|
60
|
+
secretKey: MINIO_SECRET_KEY!,
|
|
61
61
|
});
|
|
62
62
|
// eslint-disable-next-line
|
|
63
63
|
// @ts-ignore
|
|
@@ -76,17 +76,17 @@ const generateMinioPath = (directoryName: string, fileName: string) => {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
const generateMinioUrl = (directoryName: string, hashedFilename: string) => {
|
|
79
|
-
return `${MINIO_ENDPOINT}/${MINIO_BUCKET_NAME}/${generateMinioPath(directoryName, hashedFilename)}`;
|
|
79
|
+
return `${MINIO_ENDPOINT}/${MINIO_BUCKET_NAME!}/${generateMinioPath(directoryName, hashedFilename)}`;
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
connectToMinio().then(function setClient(c) {
|
|
83
|
-
client = c;
|
|
83
|
+
client = c || client;
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
const getObjectStats = async (fileName: string) => {
|
|
87
87
|
if (!client) throw new Error('Minio not connected, check env variables');
|
|
88
88
|
|
|
89
|
-
return client.statObject(MINIO_BUCKET_NAME
|
|
89
|
+
return client.statObject(MINIO_BUCKET_NAME!, fileName);
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
const bufferToStream = (buffer: any) => {
|
|
@@ -116,7 +116,7 @@ export const MinioAdapter: IFileAdapter = {
|
|
|
116
116
|
const _id = await buildHashedFilename(directoryName, fileName, expiryDate);
|
|
117
117
|
|
|
118
118
|
const url = await client.presignedPutObject(
|
|
119
|
-
MINIO_BUCKET_NAME
|
|
119
|
+
MINIO_BUCKET_NAME!,
|
|
120
120
|
generateMinioPath(directoryName, _id),
|
|
121
121
|
expiryOffsetInMs() / 1000,
|
|
122
122
|
);
|
|
@@ -126,7 +126,7 @@ export const MinioAdapter: IFileAdapter = {
|
|
|
126
126
|
directoryName,
|
|
127
127
|
expiryDate,
|
|
128
128
|
fileName,
|
|
129
|
-
type:
|
|
129
|
+
type: mime.getType(fileName),
|
|
130
130
|
putURL: url,
|
|
131
131
|
url: generateMinioUrl(directoryName, _id),
|
|
132
132
|
} as UploadFileData & { putURL: string };
|
|
@@ -139,7 +139,7 @@ export const MinioAdapter: IFileAdapter = {
|
|
|
139
139
|
return `${path}/${_id}`;
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
-
await client.removeObjects(MINIO_BUCKET_NAME
|
|
142
|
+
await client.removeObjects(MINIO_BUCKET_NAME!, fileIds);
|
|
143
143
|
},
|
|
144
144
|
|
|
145
145
|
async uploadFileFromStream(directoryName: string, rawFile: any) {
|
|
@@ -157,14 +157,14 @@ export const MinioAdapter: IFileAdapter = {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
const _id = await buildHashedFilename(directoryName, fileName, new Date());
|
|
160
|
-
const type =
|
|
160
|
+
const type = mime.getType(fileName) || (await Promise.resolve(rawFile)).mimetype;
|
|
161
161
|
|
|
162
162
|
const metaData = {
|
|
163
163
|
'Content-Type': type,
|
|
164
164
|
};
|
|
165
165
|
|
|
166
166
|
await client.putObject(
|
|
167
|
-
MINIO_BUCKET_NAME
|
|
167
|
+
MINIO_BUCKET_NAME!,
|
|
168
168
|
generateMinioPath(directoryName, _id),
|
|
169
169
|
stream,
|
|
170
170
|
undefined,
|
|
@@ -193,14 +193,14 @@ export const MinioAdapter: IFileAdapter = {
|
|
|
193
193
|
|
|
194
194
|
const url = new URL(fileLink);
|
|
195
195
|
const response = await fetch(url, { headers });
|
|
196
|
-
const type =
|
|
196
|
+
const type = mime.getType(fileName) || response.headers['content-type'];
|
|
197
197
|
const readable = Readable.fromWeb(response.body as ReadableStream<Uint8Array<ArrayBufferLike>>);
|
|
198
198
|
const metaData = {
|
|
199
199
|
'Content-Type': type,
|
|
200
200
|
};
|
|
201
201
|
|
|
202
202
|
await client.putObject(
|
|
203
|
-
MINIO_BUCKET_NAME
|
|
203
|
+
MINIO_BUCKET_NAME!,
|
|
204
204
|
generateMinioPath(directoryName, hashedFilename),
|
|
205
205
|
readable,
|
|
206
206
|
undefined,
|
|
@@ -222,7 +222,7 @@ export const MinioAdapter: IFileAdapter = {
|
|
|
222
222
|
async createDownloadStream(file) {
|
|
223
223
|
if (!client) throw new Error('Minio not connected, check env variables');
|
|
224
224
|
|
|
225
|
-
const stream = await client.getObject(MINIO_BUCKET_NAME
|
|
225
|
+
const stream = await client.getObject(MINIO_BUCKET_NAME!, generateMinioPath(file.path, file._id));
|
|
226
226
|
return stream;
|
|
227
227
|
},
|
|
228
228
|
};
|
|
@@ -5,7 +5,7 @@ import { FilterDirector, FilterAdapter, IFilterAdapter } from '@unchainedshop/co
|
|
|
5
5
|
import { createLogger } from '@unchainedshop/logger';
|
|
6
6
|
import { isDocumentDBCompatModeEnabled } from '@unchainedshop/mongodb';
|
|
7
7
|
|
|
8
|
-
const logger = createLogger('unchained:
|
|
8
|
+
const logger = createLogger('unchained:local-search');
|
|
9
9
|
|
|
10
10
|
const LocalSearch: IFilterAdapter = {
|
|
11
11
|
...FilterAdapter,
|