@unchainedshop/plugins 4.0.0-rc.9 → 4.0.1
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 +5 -5
- package/lib/presets/all.d.ts.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/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/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.js +4 -0
- package/lib/worker/twilio.js.map +1 -1
- 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/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 +1 -1
- package/src/worker/bulk-import.ts +12 -53
- 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/twilio.ts +10 -3
- package/src/pricing/product-swiss-tax.test.ts +0 -139
|
@@ -17,7 +17,6 @@ export const configureExportToken = (unchainedAPI) => {
|
|
|
17
17
|
if (work.type === 'EXPORT_TOKEN' && work.success) {
|
|
18
18
|
await unchainedAPI.modules.warehousing.updateTokenOwnership({
|
|
19
19
|
tokenId: work.input.token._id,
|
|
20
|
-
userId: null,
|
|
21
20
|
walletAddress: work.input.recipientWalletAddress,
|
|
22
21
|
});
|
|
23
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-token.js","sourceRoot":"","sources":["../../src/worker/export-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAQ,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAiC,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,MAAM,CAAC,MAAM,iBAAiB,GAA+B;IAC3D,GAAG,aAAa;IAEhB,GAAG,EAAE,2CAA2C;IAChD,KAAK,EAAE,2EAA2E;IAClF,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,cAAc;IACpB,QAAQ,EAAE,IAAI;IAEd,KAAK,CAAC,MAA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M,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC;gBAC1D,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG;gBAC7B,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,sBAAsB;aACjD,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC;AAEpC,cAAc,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC"}
|
package/lib/worker/message.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/worker/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,cAAc,EAAiC,MAAM,qBAAqB,CAAC;AACvG,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,eAAO,MAAM,aAAa,EAAE,cAAc,CACxC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/worker/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,cAAc,EAAiC,MAAM,qBAAqB,CAAC;AACvG,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,eAAO,MAAM,aAAa,EAAE,cAAc,CACxC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EACnD;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAA;CAAE,CAgDnC,CAAC"}
|
package/lib/worker/message.js
CHANGED
|
@@ -8,6 +8,8 @@ export const MessageWorker = {
|
|
|
8
8
|
doWork: async ({ template, ...payload }, unchainedAPI, workId) => {
|
|
9
9
|
try {
|
|
10
10
|
const templateResolver = MessagingDirector.getTemplate(template);
|
|
11
|
+
if (!templateResolver)
|
|
12
|
+
throw new Error(`No template resolver found for template ${template}`);
|
|
11
13
|
const workConfigurations = await templateResolver({
|
|
12
14
|
template,
|
|
13
15
|
...payload,
|
|
@@ -18,12 +20,12 @@ export const MessageWorker = {
|
|
|
18
20
|
...workConfiguration,
|
|
19
21
|
originalWorkId: workId,
|
|
20
22
|
});
|
|
21
|
-
delete work.input;
|
|
23
|
+
delete work.input; // Remove input from returned work for privacy
|
|
22
24
|
return work;
|
|
23
25
|
}));
|
|
24
26
|
return { success: true, result: { forked } };
|
|
25
27
|
}
|
|
26
|
-
return { success: true, result: {
|
|
28
|
+
return { success: true, result: { forked: [] } };
|
|
27
29
|
}
|
|
28
30
|
catch (err) {
|
|
29
31
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/worker/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkB,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGvG,MAAM,CAAC,MAAM,aAAa,GAGtB;IACF,GAAG,aAAa;IAEhB,GAAG,EAAE,sCAAsC;IAC3C,KAAK,EAAE,2EAA2E;IAClF,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,SAAS;IAEf,MAAM,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE;QAC/D,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAEjE,MAAM,kBAAkB,GAAG,MAAM,gBAAgB,CAC/C;gBACE,QAAQ;gBACR,GAAG,OAAO;aACX,EACD,YAAY,CACb,CAAC;YAEF,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAC9B,kBAAk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,OAAQ,IAAY,CAAC,KAAK,CAAC,CAAC,8CAA8C;oBAC1E,OAAO,IAAI,CAAC;gBACd,CAAC,CAAC,CACH,CAAC;gBACF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;YAC/C,CAAC;YACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC;QACnD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE;oBACL,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,OAAO,EAAE,GAAG,CAAC,OAAO;oBACpB,KAAK,EAAE,GAAG,CAAC,KAAK;iBACjB;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC;AAEF,cAAc,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC"}
|
package/lib/worker/sms.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core-worker';
|
|
2
|
+
import Twilio from 'twilio';
|
|
2
3
|
const { TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_SMS_FROM } = process.env;
|
|
4
|
+
/* Potential: no need for twilio npm
|
|
5
|
+
curl -X POST "https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json" \
|
|
6
|
+
--data-urlencode "From=+15017122661" \
|
|
7
|
+
--data-urlencode "Body=Hi there" \
|
|
8
|
+
--data-urlencode "To=+15558675310" \
|
|
9
|
+
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
|
|
10
|
+
*/
|
|
3
11
|
const SmsWorkerPlugin = {
|
|
4
12
|
...WorkerAdapter,
|
|
5
13
|
key: 'shop.unchained.worker-plugin.sms',
|
|
@@ -26,33 +34,25 @@ const SmsWorkerPlugin = {
|
|
|
26
34
|
};
|
|
27
35
|
}
|
|
28
36
|
try {
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
35
|
-
},
|
|
36
|
-
body: new URLSearchParams({
|
|
37
|
-
Body: text || '',
|
|
38
|
-
From: from || TWILIO_SMS_FROM,
|
|
39
|
-
To: to,
|
|
40
|
-
}),
|
|
37
|
+
const client = Twilio(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN);
|
|
38
|
+
const { sid, errorMessage } = await client.messages.create({
|
|
39
|
+
body: text,
|
|
40
|
+
from: from || TWILIO_SMS_FROM,
|
|
41
|
+
to,
|
|
41
42
|
});
|
|
42
|
-
|
|
43
|
-
if (!response.ok) {
|
|
43
|
+
if (errorMessage) {
|
|
44
44
|
return {
|
|
45
45
|
success: false,
|
|
46
46
|
error: {
|
|
47
47
|
name: 'TWILIO_ERROR',
|
|
48
|
-
message:
|
|
48
|
+
message: errorMessage.toString(),
|
|
49
49
|
},
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
return {
|
|
53
53
|
success: true,
|
|
54
54
|
result: {
|
|
55
|
-
sid
|
|
55
|
+
sid,
|
|
56
56
|
},
|
|
57
57
|
error: null,
|
|
58
58
|
};
|
package/lib/worker/sms.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sms.js","sourceRoot":"","sources":["../../src/worker/sms.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sms.js","sourceRoot":"","sources":["../../src/worker/sms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3E,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,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C;YACb,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE;oBACL,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,OAAO,EAAE,GAAG,CAAC,OAAO;oBACpB,KAAK,EAAE,GAAG,CAAC,KAAK;iBACjB;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC;AAEF,cAAc,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC"}
|
package/lib/worker/twilio.js
CHANGED
|
@@ -8,6 +8,10 @@ const SmsWorkerPlugin = {
|
|
|
8
8
|
type: 'TWILIO',
|
|
9
9
|
doWork: async ({ from, to, text, ...params }) => {
|
|
10
10
|
try {
|
|
11
|
+
if (!TWILIO_SMS_FROM && !from)
|
|
12
|
+
throw new Error('Missing Twilio "from" number. Set TWILIO_SMS_FROM env var or provide "from" in input');
|
|
13
|
+
if (!to)
|
|
14
|
+
throw new Error('Missing "to" in input');
|
|
11
15
|
const url = `https://api.twilio.com/2010-04-01/Accounts/${TWILIO_ACCOUNT_SID}/Messages.json`;
|
|
12
16
|
const response = await fetch(url, {
|
|
13
17
|
method: 'POST',
|
package/lib/worker/twilio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"twilio.js","sourceRoot":"","sources":["../../src/worker/twilio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEpF,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAE/E,MAAM,eAAe,GAQjB;IACF,GAAG,aAAa;IAEhB,GAAG,EAAE,qCAAqC;IAC1C,KAAK,EAAE,8BAA8B;IACrC,OAAO,EAAE,OAAO;IAEhB,IAAI,EAAE,QAAQ;IAEd,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE;QAC9C,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": "4.0.1",
|
|
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
|
|