@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.
- package/README.md +0 -2
- package/lib/delivery/post/adapter.d.ts +2 -0
- package/lib/delivery/{post.js → post/adapter.js} +2 -3
- package/lib/delivery/post/index.d.ts +4 -0
- package/lib/delivery/post/index.js +10 -0
- package/lib/delivery/send-message/adapter.d.ts +2 -0
- package/lib/delivery/{send-message.js → send-message/adapter.js} +2 -3
- package/lib/delivery/send-message/index.d.ts +4 -0
- package/lib/delivery/send-message/index.js +10 -0
- package/lib/delivery/stores/adapter.d.ts +2 -0
- package/lib/delivery/{stores.js → stores/adapter.js} +2 -3
- package/lib/delivery/stores/index.d.ts +4 -0
- package/lib/delivery/stores/index.js +10 -0
- package/lib/enrollments/licensed/adapter.d.ts +6 -0
- package/lib/enrollments/{licensed.js → licensed/adapter.js} +2 -3
- package/lib/enrollments/licensed/index.d.ts +4 -0
- package/lib/enrollments/licensed/index.js +10 -0
- package/lib/events/node-event-emitter.d.ts +3 -1
- package/lib/events/node-event-emitter.js +3 -3
- package/lib/files/gridfs/adapter.d.ts +2 -2
- package/lib/files/gridfs/adapter.js +2 -5
- package/lib/files/gridfs/api.d.ts +7 -0
- package/lib/files/gridfs/api.js +163 -0
- package/lib/files/gridfs/index.d.ts +5 -4
- package/lib/files/gridfs/index.js +30 -3
- package/lib/files/minio/adapter.d.ts +4 -0
- package/lib/files/minio/adapter.js +160 -0
- package/lib/files/minio/api.d.ts +2 -0
- package/lib/files/minio/api.js +41 -0
- package/lib/files/minio/index.d.ts +4 -5
- package/lib/files/minio/index.js +18 -157
- package/lib/files/temp-upload/api.d.ts +6 -0
- package/lib/files/temp-upload/api.js +49 -0
- package/lib/files/temp-upload/index.d.ts +3 -0
- package/lib/files/temp-upload/index.js +15 -0
- package/lib/filters/local-search/adapter.d.ts +2 -0
- package/lib/filters/{local-search.js → local-search/adapter.js} +2 -12
- package/lib/filters/local-search/index.d.ts +4 -0
- package/lib/filters/local-search/index.js +16 -0
- package/lib/filters/strict-equal/adapter.d.ts +2 -0
- package/lib/filters/{strict-equal.js → strict-equal/adapter.js} +2 -3
- package/lib/filters/strict-equal/index.d.ts +4 -0
- package/lib/filters/strict-equal/index.js +10 -0
- package/lib/payment/apple-iap/adapter.d.ts +2 -1
- package/lib/payment/apple-iap/adapter.js +2 -3
- package/lib/payment/apple-iap/api.d.ts +2 -0
- package/lib/payment/apple-iap/{handler-fastify.js → api.js} +47 -30
- package/lib/payment/apple-iap/index.d.ts +6 -4
- package/lib/payment/apple-iap/index.js +28 -3
- package/lib/payment/cryptopay/adapter.d.ts +2 -0
- package/lib/payment/cryptopay/{plugin.js → adapter.js} +2 -4
- package/lib/payment/cryptopay/api.d.ts +2 -0
- package/lib/payment/cryptopay/api.js +23 -0
- package/lib/payment/cryptopay/index.d.ts +5 -4
- package/lib/payment/cryptopay/index.js +31 -3
- package/lib/payment/datatrans-v2/adapter.d.ts +2 -0
- package/lib/payment/datatrans-v2/adapter.js +406 -0
- package/lib/payment/datatrans-v2/api.d.ts +2 -0
- package/lib/payment/datatrans-v2/api.js +108 -0
- package/lib/payment/datatrans-v2/index.d.ts +4 -1
- package/lib/payment/datatrans-v2/index.js +17 -400
- package/lib/payment/invoice/adapter.d.ts +2 -0
- package/lib/payment/{invoice.js → invoice/adapter.js} +2 -3
- package/lib/payment/invoice/index.d.ts +4 -0
- package/lib/payment/invoice/index.js +10 -0
- package/lib/payment/invoice-prepaid/adapter.d.ts +2 -0
- package/lib/payment/{invoice-prepaid.js → invoice-prepaid/adapter.js} +2 -3
- package/lib/payment/invoice-prepaid/index.d.ts +4 -0
- package/lib/payment/invoice-prepaid/index.js +10 -0
- package/lib/payment/payrexx/adapter.d.ts +2 -0
- package/lib/payment/payrexx/adapter.js +161 -0
- package/lib/payment/payrexx/api.d.ts +2 -0
- package/lib/payment/payrexx/api.js +97 -0
- package/lib/payment/payrexx/index.d.ts +4 -1
- package/lib/payment/payrexx/index.js +19 -158
- package/lib/payment/postfinance-checkout/adapter.d.ts +2 -0
- package/lib/payment/postfinance-checkout/adapter.js +189 -0
- package/lib/payment/postfinance-checkout/index.d.ts +5 -0
- package/lib/payment/postfinance-checkout/index.js +25 -186
- package/lib/payment/postfinance-checkout/webhook.d.ts +2 -0
- package/lib/payment/postfinance-checkout/webhook.js +48 -0
- package/lib/payment/saferpay/adapter.js +1 -2
- package/lib/payment/saferpay/index.d.ts +5 -4
- package/lib/payment/saferpay/index.js +29 -3
- package/lib/payment/saferpay/webhook.d.ts +2 -0
- package/lib/payment/saferpay/webhook.js +64 -0
- package/lib/payment/stripe/adapter.d.ts +2 -0
- package/lib/payment/stripe/adapter.js +121 -0
- package/lib/payment/stripe/api.d.ts +6 -0
- package/lib/payment/stripe/api.js +165 -0
- package/lib/payment/stripe/index.d.ts +4 -1
- package/lib/payment/stripe/index.js +22 -116
- package/lib/payment/stripe/stripe.js +2 -5
- package/lib/presets/all.d.ts +1 -70
- package/lib/presets/all.js +41 -27
- package/lib/presets/base.d.ts +1 -25
- package/lib/presets/base.js +56 -25
- package/lib/presets/countries/ch.d.ts +1 -2
- package/lib/presets/countries/ch.js +7 -2
- package/lib/presets/crypto.d.ts +3 -7
- package/lib/presets/crypto.js +18 -7
- package/lib/pricing/{delivery-swiss-tax.d.ts → delivery-swiss-tax/adapter.d.ts} +1 -0
- package/lib/pricing/{delivery-swiss-tax.js → delivery-swiss-tax/adapter.js} +4 -4
- package/lib/pricing/delivery-swiss-tax/index.d.ts +4 -0
- package/lib/pricing/delivery-swiss-tax/index.js +10 -0
- package/lib/pricing/{discount-100-off.d.ts → discount-100-off/adapter.d.ts} +1 -0
- package/lib/pricing/{discount-100-off.js → discount-100-off/adapter.js} +2 -2
- package/lib/pricing/discount-100-off/index.d.ts +4 -0
- package/lib/pricing/discount-100-off/index.js +10 -0
- package/lib/pricing/{discount-half-price-manual.d.ts → discount-half-price-manual/adapter.d.ts} +1 -0
- package/lib/pricing/{discount-half-price-manual.js → discount-half-price-manual/adapter.js} +2 -2
- package/lib/pricing/discount-half-price-manual/index.d.ts +4 -0
- package/lib/pricing/discount-half-price-manual/index.js +10 -0
- package/lib/pricing/{free-delivery.d.ts → free-delivery/adapter.d.ts} +1 -0
- package/lib/pricing/{free-delivery.js → free-delivery/adapter.js} +2 -2
- package/lib/pricing/free-delivery/index.d.ts +4 -0
- package/lib/pricing/free-delivery/index.js +10 -0
- package/lib/pricing/{free-payment.d.ts → free-payment/adapter.d.ts} +1 -0
- package/lib/pricing/{free-payment.js → free-payment/adapter.js} +2 -2
- package/lib/pricing/free-payment/index.d.ts +4 -0
- package/lib/pricing/free-payment/index.js +10 -0
- package/lib/pricing/{order-delivery.d.ts → order-delivery/adapter.d.ts} +1 -0
- package/lib/pricing/{order-delivery.js → order-delivery/adapter.js} +2 -2
- package/lib/pricing/order-delivery/index.d.ts +4 -0
- package/lib/pricing/order-delivery/index.js +10 -0
- package/lib/pricing/{order-discount.d.ts → order-discount/adapter.d.ts} +1 -0
- package/lib/pricing/{order-discount.js → order-discount/adapter.js} +2 -2
- package/lib/pricing/order-discount/index.d.ts +4 -0
- package/lib/pricing/order-discount/index.js +10 -0
- package/lib/pricing/{order-items.d.ts → order-items/adapter.d.ts} +1 -0
- package/lib/pricing/{order-items.js → order-items/adapter.js} +2 -2
- package/lib/pricing/order-items/index.d.ts +4 -0
- package/lib/pricing/order-items/index.js +10 -0
- package/lib/pricing/{order-payment.d.ts → order-payment/adapter.d.ts} +1 -0
- package/lib/pricing/{order-payment.js → order-payment/adapter.js} +2 -2
- package/lib/pricing/order-payment/index.d.ts +4 -0
- package/lib/pricing/order-payment/index.js +10 -0
- package/lib/pricing/{product-catalog-price.d.ts → product-catalog-price/adapter.d.ts} +1 -0
- package/lib/pricing/{product-catalog-price.js → product-catalog-price/adapter.js} +2 -2
- package/lib/pricing/product-catalog-price/index.d.ts +4 -0
- package/lib/pricing/product-catalog-price/index.js +10 -0
- package/lib/pricing/{product-discount.d.ts → product-discount/adapter.d.ts} +1 -0
- package/lib/pricing/{product-discount.js → product-discount/adapter.js} +2 -2
- package/lib/pricing/product-discount/index.d.ts +4 -0
- package/lib/pricing/product-discount/index.js +10 -0
- package/lib/pricing/{product-price-rateconversion.d.ts → product-price-rateconversion/adapter.d.ts} +1 -0
- package/lib/pricing/{product-price-rateconversion.js → product-price-rateconversion/adapter.js} +2 -2
- package/lib/pricing/product-price-rateconversion/index.d.ts +4 -0
- package/lib/pricing/product-price-rateconversion/index.js +10 -0
- package/lib/pricing/{product-swiss-tax.d.ts → product-swiss-tax/adapter.d.ts} +1 -0
- package/lib/pricing/{product-swiss-tax.js → product-swiss-tax/adapter.js} +4 -4
- package/lib/pricing/product-swiss-tax/index.d.ts +4 -0
- package/lib/pricing/product-swiss-tax/index.js +10 -0
- package/lib/quotations/manual/adapter.d.ts +2 -0
- package/lib/quotations/{manual.js → manual/adapter.js} +2 -3
- package/lib/quotations/manual/index.d.ts +4 -0
- package/lib/quotations/manual/index.js +10 -0
- package/lib/warehousing/erc-metadata/api.d.ts +12 -0
- package/lib/warehousing/erc-metadata/api.js +43 -0
- package/lib/warehousing/erc-metadata/index.d.ts +3 -0
- package/lib/warehousing/erc-metadata/index.js +15 -0
- package/lib/warehousing/eth-minter/adapter.d.ts +2 -0
- package/lib/warehousing/{eth-minter.js → eth-minter/adapter.js} +3 -4
- package/lib/warehousing/eth-minter/index.d.ts +4 -0
- package/lib/warehousing/eth-minter/index.js +10 -0
- package/lib/warehousing/store/adapter.d.ts +2 -0
- package/lib/warehousing/{store.js → store/adapter.js} +2 -3
- package/lib/warehousing/store/index.d.ts +4 -0
- package/lib/warehousing/store/index.js +10 -0
- package/lib/worker/budgetsms/adapter.d.ts +22 -0
- package/lib/worker/{budgetsms.js → budgetsms/adapter.js} +3 -3
- package/lib/worker/budgetsms/index.d.ts +4 -0
- package/lib/worker/budgetsms/index.js +10 -0
- package/lib/worker/bulk-export/adapter.d.ts +3 -0
- package/lib/worker/{bulk-export.js → bulk-export/adapter.js} +3 -3
- package/lib/worker/bulk-export/index.d.ts +4 -0
- package/lib/worker/bulk-export/index.js +10 -0
- package/lib/worker/{bulk-import.d.ts → bulk-import/adapter.d.ts} +1 -0
- package/lib/worker/{bulk-import.js → bulk-import/adapter.js} +2 -2
- package/lib/worker/bulk-import/api.d.ts +7 -0
- package/lib/worker/bulk-import/api.js +53 -0
- package/lib/worker/bulk-import/index.d.ts +4 -0
- package/lib/worker/bulk-import/index.js +18 -0
- package/lib/worker/bulkgate/adapter.d.ts +12 -0
- package/lib/worker/{bulkgate.js → bulkgate/adapter.js} +3 -3
- package/lib/worker/bulkgate/index.d.ts +4 -0
- package/lib/worker/bulkgate/index.js +10 -0
- package/lib/worker/email/adapter.d.ts +9 -0
- package/lib/worker/{email.js → email/adapter.js} +27 -13
- package/lib/worker/email/index.d.ts +4 -0
- package/lib/worker/email/index.js +10 -0
- package/lib/worker/enrollment-order-generator/adapter.d.ts +4 -0
- package/lib/worker/{enrollment-order-generator.js → enrollment-order-generator/adapter.js} +2 -2
- package/lib/worker/enrollment-order-generator/index.d.ts +4 -0
- package/lib/worker/enrollment-order-generator/index.js +13 -0
- package/lib/worker/{error-notifications.d.ts → error-notifications/adapter.d.ts} +1 -0
- package/lib/worker/{error-notifications.js → error-notifications/adapter.js} +9 -8
- package/lib/worker/error-notifications/index.d.ts +4 -0
- package/lib/worker/error-notifications/index.js +13 -0
- package/lib/worker/{export-token.d.ts → export-token/adapter.d.ts} +1 -1
- package/lib/worker/{export-token.js → export-token/adapter.js} +2 -3
- package/lib/worker/export-token/index.d.ts +4 -0
- package/lib/worker/export-token/index.js +13 -0
- package/lib/worker/{external.d.ts → external/adapter.d.ts} +1 -0
- package/lib/worker/{external.js → external/adapter.js} +2 -2
- package/lib/worker/external/index.d.ts +4 -0
- package/lib/worker/external/index.js +10 -0
- package/lib/worker/heartbeat/adapter.d.ts +8 -0
- package/lib/worker/{heartbeat.js → heartbeat/adapter.js} +3 -3
- package/lib/worker/heartbeat/index.d.ts +4 -0
- package/lib/worker/heartbeat/index.js +10 -0
- package/lib/worker/{http-request.d.ts → http-request/adapter.d.ts} +1 -1
- package/lib/worker/{http-request.js → http-request/adapter.js} +2 -3
- package/lib/worker/http-request/index.d.ts +4 -0
- package/lib/worker/http-request/index.js +10 -0
- package/lib/worker/{message.d.ts → message/adapter.d.ts} +1 -0
- package/lib/worker/{message.js → message/adapter.js} +2 -2
- package/lib/worker/message/index.d.ts +4 -0
- package/lib/worker/message/index.js +10 -0
- package/lib/worker/push-notification/adapter.d.ts +9 -0
- package/lib/worker/{push-notification.js → push-notification/adapter.js} +3 -3
- package/lib/worker/push-notification/index.d.ts +4 -0
- package/lib/worker/push-notification/index.js +10 -0
- package/lib/worker/twilio/adapter.d.ts +8 -0
- package/lib/worker/{twilio.js → twilio/adapter.js} +3 -3
- package/lib/worker/twilio/index.d.ts +4 -0
- package/lib/worker/twilio/index.js +10 -0
- package/lib/worker/update-coinbase-rates/adapter.d.ts +4 -0
- package/lib/worker/{update-coinbase-rates.js → update-coinbase-rates/adapter.js} +8 -6
- package/lib/worker/update-coinbase-rates/index.d.ts +4 -0
- package/lib/worker/update-coinbase-rates/index.js +13 -0
- package/lib/worker/update-ecb-rates/adapter.d.ts +4 -0
- package/lib/worker/{update-ecb-rates.js → update-ecb-rates/adapter.js} +11 -9
- package/lib/worker/update-ecb-rates/index.d.ts +4 -0
- package/lib/worker/update-ecb-rates/index.js +13 -0
- package/lib/worker/{update-token-ownership.d.ts → update-token-ownership/adapter.d.ts} +2 -0
- package/lib/worker/{update-token-ownership.js → update-token-ownership/adapter.js} +8 -7
- package/lib/worker/update-token-ownership/index.d.ts +4 -0
- package/lib/worker/update-token-ownership/index.js +13 -0
- package/lib/worker/{zombie-killer.js → zombie-killer/adapter.js} +1 -2
- package/lib/worker/zombie-killer/index.d.ts +4 -0
- package/lib/worker/zombie-killer/index.js +10 -0
- package/package.json +15 -10
- package/lib/delivery/post.d.ts +0 -1
- package/lib/delivery/send-message.d.ts +0 -1
- package/lib/delivery/stores.d.ts +0 -1
- package/lib/enrollments/licensed.d.ts +0 -4
- package/lib/files/gridfs/handler-express.d.ts +0 -9
- package/lib/files/gridfs/handler-express.js +0 -110
- package/lib/files/gridfs/handler-fastify.d.ts +0 -3
- package/lib/files/gridfs/handler-fastify.js +0 -138
- package/lib/files/minio/handler-express.d.ts +0 -2
- package/lib/files/minio/handler-express.js +0 -36
- package/lib/files/minio/handler-fastify.d.ts +0 -3
- package/lib/files/minio/handler-fastify.js +0 -40
- package/lib/filters/local-search.d.ts +0 -3
- package/lib/filters/strict-equal.d.ts +0 -1
- package/lib/payment/apple-iap/handler-express.d.ts +0 -2
- package/lib/payment/apple-iap/handler-express.js +0 -103
- package/lib/payment/apple-iap/handler-fastify.d.ts +0 -3
- package/lib/payment/braintree.d.ts +0 -1
- package/lib/payment/braintree.js +0 -138
- package/lib/payment/cryptopay/handler-express.d.ts +0 -2
- package/lib/payment/cryptopay/handler-express.js +0 -19
- package/lib/payment/cryptopay/handler-fastify.d.ts +0 -3
- package/lib/payment/cryptopay/handler-fastify.js +0 -17
- package/lib/payment/cryptopay/plugin.d.ts +0 -3
- package/lib/payment/datatrans-v2/handler-express.d.ts +0 -1
- package/lib/payment/datatrans-v2/handler-express.js +0 -71
- package/lib/payment/datatrans-v2/handler-fastify.d.ts +0 -2
- package/lib/payment/datatrans-v2/handler-fastify.js +0 -71
- package/lib/payment/invoice-prepaid.d.ts +0 -1
- package/lib/payment/invoice.d.ts +0 -1
- package/lib/payment/paypal-checkout.d.ts +0 -1
- package/lib/payment/paypal-checkout.js +0 -87
- package/lib/payment/payrexx/handler-express.d.ts +0 -1
- package/lib/payment/payrexx/handler-express.js +0 -85
- package/lib/payment/payrexx/handler-fastify.d.ts +0 -2
- package/lib/payment/payrexx/handler-fastify.js +0 -91
- package/lib/payment/postfinance-checkout/handler-express.d.ts +0 -1
- package/lib/payment/postfinance-checkout/handler-express.js +0 -37
- package/lib/payment/postfinance-checkout/handler-fastify.d.ts +0 -2
- package/lib/payment/postfinance-checkout/handler-fastify.js +0 -40
- package/lib/payment/saferpay/handler-express.d.ts +0 -1
- package/lib/payment/saferpay/handler-express.js +0 -59
- package/lib/payment/saferpay/handler-fastify.d.ts +0 -2
- package/lib/payment/saferpay/handler-fastify.js +0 -62
- package/lib/payment/stripe/handler-express.d.ts +0 -5
- package/lib/payment/stripe/handler-express.js +0 -121
- package/lib/payment/stripe/handler-fastify.d.ts +0 -6
- package/lib/payment/stripe/handler-fastify.js +0 -131
- package/lib/presets/all-express.d.ts +0 -6
- package/lib/presets/all-express.js +0 -26
- package/lib/presets/all-fastify.d.ts +0 -6
- package/lib/presets/all-fastify.js +0 -49
- package/lib/presets/base-express.d.ts +0 -2
- package/lib/presets/base-express.js +0 -5
- package/lib/presets/base-fastify.d.ts +0 -3
- package/lib/presets/base-fastify.js +0 -16
- package/lib/presets/crypto-express.d.ts +0 -3
- package/lib/presets/crypto-express.js +0 -8
- package/lib/presets/crypto-fastify.d.ts +0 -3
- package/lib/presets/crypto-fastify.js +0 -11
- package/lib/pricing/discount-half-price.d.ts +0 -2
- package/lib/pricing/discount-half-price.js +0 -33
- package/lib/pricing/order-items-discount.d.ts +0 -2
- package/lib/pricing/order-items-discount.js +0 -50
- package/lib/pricing/order-round.d.ts +0 -10
- package/lib/pricing/order-round.js +0 -135
- package/lib/pricing/product-catalog-price-options.d.ts +0 -2
- package/lib/pricing/product-catalog-price-options.js +0 -51
- package/lib/pricing/product-round.d.ts +0 -10
- package/lib/pricing/product-round.js +0 -44
- package/lib/quotations/manual.d.ts +0 -1
- package/lib/warehousing/eth-minter.d.ts +0 -1
- package/lib/warehousing/store.d.ts +0 -1
- package/lib/worker/budgetsms.d.ts +0 -9
- package/lib/worker/bulk-export.d.ts +0 -2
- package/lib/worker/bulkgate.d.ts +0 -1
- package/lib/worker/email.d.ts +0 -1
- package/lib/worker/enrollment-order-generator.d.ts +0 -1
- package/lib/worker/heartbeat.d.ts +0 -1
- package/lib/worker/push-notification.d.ts +0 -1
- package/lib/worker/twilio.d.ts +0 -1
- package/lib/worker/update-coinbase-rates.d.ts +0 -1
- package/lib/worker/update-ecb-rates.d.ts +0 -1
- /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,4 +1,4 @@
|
|
|
1
|
-
import { WorkerAdapter
|
|
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,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";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MessagingDirector, WorkerAdapter
|
|
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
|
-
|
|
42
|
+
export default MessageWorker;
|
|
@@ -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
|
|
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
|
-
|
|
87
|
+
export default PushNotificationWorkerPlugin;
|
|
@@ -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";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { WorkerAdapter
|
|
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
|
-
|
|
59
|
+
export default SmsWorkerPlugin;
|
|
@@ -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";
|
|
@@ -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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
export default UpdateCoinbaseRates;
|
|
56
|
+
export const configureUpdateCoinbaseRatesAutoscheduling = () => {
|
|
57
|
+
WorkerDirector.configureAutoscheduling({
|
|
58
|
+
type: UpdateCoinbaseRates.type,
|
|
59
|
+
schedule: everyMinute,
|
|
60
|
+
});
|
|
61
|
+
};
|
|
@@ -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";
|
|
@@ -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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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,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
|
-
|
|
52
|
-
|
|
53
|
-
WorkerDirector.configureAutoscheduling({
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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,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
|
|
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,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.
|
|
4
|
+
"version": "4.7.2",
|
|
5
5
|
"main": "lib/plugins-index.js",
|
|
6
6
|
"types": "lib/plugins-index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
|
-
"
|
|
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 <
|
|
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": "^
|
|
130
|
+
"nodemailer": "^8.0.1",
|
|
126
131
|
"p-memoize": "^8.0.0",
|
|
127
132
|
"stripe": "^20.0.0",
|
|
128
133
|
"typescript": "^5.8.3",
|
package/lib/delivery/post.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/delivery/stores.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -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;
|