@unchainedshop/plugins 3.0.0-alpha7 → 3.0.0-rc2
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/delivery/pick-mup.js +1 -2
- package/lib/delivery/pick-mup.js.map +1 -1
- package/lib/delivery/post.js +2 -1
- package/lib/delivery/post.js.map +1 -1
- package/lib/delivery/send-message.js +2 -1
- package/lib/delivery/send-message.js.map +1 -1
- package/lib/delivery/stores.js +2 -1
- package/lib/delivery/stores.js.map +1 -1
- package/lib/enrollments/licensed.d.ts.map +1 -1
- package/lib/enrollments/licensed.js +1 -1
- package/lib/enrollments/licensed.js.map +1 -1
- package/lib/events/aws-eventbridge.d.ts +2 -0
- package/lib/events/aws-eventbridge.d.ts.map +1 -0
- package/lib/events/aws-eventbridge.js +36 -0
- package/lib/events/aws-eventbridge.js.map +1 -0
- package/lib/events/node-event-emitter.js +1 -2
- package/lib/events/node-event-emitter.js.map +1 -1
- package/lib/events/redis.js +4 -2
- package/lib/events/redis.js.map +1 -1
- package/lib/files/gridfs/gridfs-adapter.d.ts.map +1 -1
- package/lib/files/gridfs/gridfs-adapter.js +14 -5
- package/lib/files/gridfs/gridfs-adapter.js.map +1 -1
- package/lib/files/gridfs/gridfs-webhook.d.ts +1 -1
- package/lib/files/gridfs/gridfs-webhook.d.ts.map +1 -1
- package/lib/files/gridfs/gridfs-webhook.js +25 -6
- package/lib/files/gridfs/gridfs-webhook.js.map +1 -1
- package/lib/files/gridfs/sign.d.ts +1 -1
- package/lib/files/gridfs/sign.d.ts.map +1 -1
- package/lib/files/gridfs/sign.js +8 -7
- package/lib/files/gridfs/sign.js.map +1 -1
- package/lib/files/minio/minio-adapter.d.ts.map +1 -1
- package/lib/files/minio/minio-adapter.js +13 -9
- package/lib/files/minio/minio-adapter.js.map +1 -1
- package/lib/files/minio/minio-webhook.d.ts.map +1 -1
- package/lib/files/minio/minio-webhook.js +4 -3
- package/lib/files/minio/minio-webhook.js.map +1 -1
- package/lib/filters/local-search.d.ts +1 -1
- package/lib/filters/local-search.d.ts.map +1 -1
- package/lib/filters/local-search.js +1 -1
- package/lib/filters/local-search.js.map +1 -1
- package/lib/filters/strict-equal.js +1 -1
- package/lib/filters/strict-equal.js.map +1 -1
- package/lib/payment/apple-iap/adapter.d.ts.map +1 -1
- package/lib/payment/apple-iap/adapter.js +15 -20
- 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/module/configureAppleTransactionsModule.d.ts +1 -1
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts.map +1 -1
- package/lib/payment/braintree.js +10 -8
- 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/middleware.d.ts.map +1 -1
- package/lib/payment/cryptopay/middleware.js +4 -4
- package/lib/payment/cryptopay/middleware.js.map +1 -1
- package/lib/payment/cryptopay/plugin.d.ts +1 -1
- package/lib/payment/cryptopay/plugin.d.ts.map +1 -1
- package/lib/payment/cryptopay/plugin.js +8 -9
- package/lib/payment/cryptopay/plugin.js.map +1 -1
- package/lib/payment/datatrans-v2/api/authorize.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/authorize.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/authorizeAuthenticated.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/authorizeAuthenticated.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/cancel.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/cancel.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/init.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/init.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/makeFetcher.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/makeFetcher.js +0 -1
- package/lib/payment/datatrans-v2/api/makeFetcher.js.map +1 -1
- package/lib/payment/datatrans-v2/api/secureFields.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/secureFields.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/settle.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/settle.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/status.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/status.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/types.d.ts +260 -0
- package/lib/payment/datatrans-v2/api/types.d.ts.map +1 -0
- package/lib/payment/datatrans-v2/api/types.js +2 -0
- package/lib/payment/datatrans-v2/api/types.js.map +1 -0
- package/lib/payment/datatrans-v2/api/validate.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/validate.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/generateSignature copy.d.ts +11 -0
- package/lib/payment/datatrans-v2/generateSignature copy.d.ts.map +1 -0
- package/lib/payment/datatrans-v2/generateSignature copy.js +19 -0
- package/lib/payment/datatrans-v2/generateSignature copy.js.map +1 -0
- package/lib/payment/datatrans-v2/generateSignature.d.ts +1 -1
- package/lib/payment/datatrans-v2/generateSignature.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/generateSignature.js +7 -4
- package/lib/payment/datatrans-v2/generateSignature.js.map +1 -1
- package/lib/payment/datatrans-v2/index.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/index.js +31 -29
- package/lib/payment/datatrans-v2/index.js.map +1 -1
- package/lib/payment/datatrans-v2/middleware.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/middleware.js +7 -5
- package/lib/payment/datatrans-v2/middleware.js.map +1 -1
- package/lib/payment/datatrans-v2/parseRegistrationData.d.ts +4 -4
- package/lib/payment/datatrans-v2/parseRegistrationData.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/parseRegistrationData.js +5 -3
- package/lib/payment/datatrans-v2/parseRegistrationData.js.map +1 -1
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +1 -2
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.js +6 -2
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.js.map +1 -1
- package/lib/payment/datatrans-v2/splitProperties.d.ts +0 -1
- package/lib/payment/datatrans-v2/splitProperties.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/splitProperties.js +0 -3
- package/lib/payment/datatrans-v2/splitProperties.js.map +1 -1
- package/lib/payment/invoice-prepaid.js +4 -3
- package/lib/payment/invoice-prepaid.js.map +1 -1
- package/lib/payment/invoice.js +4 -3
- package/lib/payment/invoice.js.map +1 -1
- package/lib/payment/paypal-checkout.js +10 -6
- package/lib/payment/paypal-checkout.js.map +1 -1
- package/lib/payment/payrexx/api/makeFetcher.d.ts.map +1 -1
- package/lib/payment/payrexx/api/makeFetcher.js +2 -3
- package/lib/payment/payrexx/api/makeFetcher.js.map +1 -1
- package/lib/payment/payrexx/index.d.ts.map +1 -1
- package/lib/payment/payrexx/index.js +20 -14
- package/lib/payment/payrexx/index.js.map +1 -1
- package/lib/payment/payrexx/middleware.d.ts.map +1 -1
- package/lib/payment/payrexx/middleware.js +12 -9
- package/lib/payment/payrexx/middleware.js.map +1 -1
- package/lib/payment/postfinance-checkout/index.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/index.js +18 -13
- package/lib/payment/postfinance-checkout/index.js.map +1 -1
- package/lib/payment/postfinance-checkout/middleware.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/middleware.js +4 -3
- package/lib/payment/postfinance-checkout/middleware.js.map +1 -1
- package/lib/payment/postfinance-checkout/utils.d.ts +2 -2
- package/lib/payment/postfinance-checkout/utils.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/utils.js +6 -2
- package/lib/payment/postfinance-checkout/utils.js.map +1 -1
- package/lib/payment/saferpay/adapter.d.ts +1 -1
- package/lib/payment/saferpay/adapter.d.ts.map +1 -1
- package/lib/payment/saferpay/adapter.js +17 -11
- package/lib/payment/saferpay/adapter.js.map +1 -1
- package/lib/payment/saferpay/api/api/SaferpayConnection.d.ts.map +1 -1
- package/lib/payment/saferpay/api/api/SaferpayConnection.js +0 -1
- package/lib/payment/saferpay/api/api/SaferpayConnection.js.map +1 -1
- package/lib/payment/saferpay/api/models/TransactionCapture.d.ts +1 -1
- package/lib/payment/saferpay/api/models/TransactionCapture.d.ts.map +1 -1
- package/lib/payment/saferpay/db/SaferpayTransactionsCollection.d.ts +1 -1
- package/lib/payment/saferpay/db/SaferpayTransactionsCollection.d.ts.map +1 -1
- package/lib/payment/saferpay/middleware.d.ts.map +1 -1
- package/lib/payment/saferpay/middleware.js +4 -4
- package/lib/payment/saferpay/middleware.js.map +1 -1
- package/lib/payment/stripe/index.d.ts.map +1 -1
- package/lib/payment/stripe/index.js +17 -11
- package/lib/payment/stripe/index.js.map +1 -1
- package/lib/payment/stripe/middleware.d.ts.map +1 -1
- package/lib/payment/stripe/middleware.js +10 -10
- package/lib/payment/stripe/middleware.js.map +1 -1
- package/lib/payment/stripe/stripe.d.ts +3 -4
- package/lib/payment/stripe/stripe.d.ts.map +1 -1
- package/lib/payment/stripe/stripe.js +3 -1
- package/lib/payment/stripe/stripe.js.map +1 -1
- package/lib/pricing/delivery-swiss-tax.d.ts +1 -1
- package/lib/pricing/delivery-swiss-tax.d.ts.map +1 -1
- package/lib/pricing/delivery-swiss-tax.js +1 -2
- package/lib/pricing/delivery-swiss-tax.js.map +1 -1
- package/lib/pricing/discount-100-off.d.ts +2 -3
- package/lib/pricing/discount-100-off.d.ts.map +1 -1
- package/lib/pricing/discount-100-off.js +1 -1
- package/lib/pricing/discount-100-off.js.map +1 -1
- package/lib/pricing/discount-half-price-manual.d.ts +2 -3
- package/lib/pricing/discount-half-price-manual.d.ts.map +1 -1
- package/lib/pricing/discount-half-price-manual.js +1 -1
- package/lib/pricing/discount-half-price-manual.js.map +1 -1
- package/lib/pricing/discount-half-price.d.ts +2 -3
- package/lib/pricing/discount-half-price.d.ts.map +1 -1
- package/lib/pricing/discount-half-price.js +1 -1
- package/lib/pricing/discount-half-price.js.map +1 -1
- package/lib/pricing/free-delivery.d.ts +1 -1
- package/lib/pricing/free-delivery.d.ts.map +1 -1
- package/lib/pricing/free-delivery.js +1 -1
- package/lib/pricing/free-delivery.js.map +1 -1
- package/lib/pricing/free-payment.d.ts +1 -1
- package/lib/pricing/free-payment.d.ts.map +1 -1
- package/lib/pricing/free-payment.js +1 -1
- package/lib/pricing/free-payment.js.map +1 -1
- package/lib/pricing/order-delivery.d.ts +1 -1
- package/lib/pricing/order-delivery.d.ts.map +1 -1
- package/lib/pricing/order-delivery.js +6 -3
- package/lib/pricing/order-delivery.js.map +1 -1
- package/lib/pricing/order-discount.d.ts +1 -2
- package/lib/pricing/order-discount.d.ts.map +1 -1
- package/lib/pricing/order-discount.js +15 -8
- package/lib/pricing/order-discount.js.map +1 -1
- package/lib/pricing/order-items-discount.js +7 -4
- package/lib/pricing/order-items-discount.js.map +1 -1
- package/lib/pricing/order-items.js +7 -3
- package/lib/pricing/order-items.js.map +1 -1
- package/lib/pricing/order-payment.js +6 -3
- package/lib/pricing/order-payment.js.map +1 -1
- package/lib/pricing/order-round.d.ts +1 -1
- package/lib/pricing/order-round.d.ts.map +1 -1
- package/lib/pricing/order-round.js +1 -2
- package/lib/pricing/order-round.js.map +1 -1
- package/lib/pricing/product-catalog-price.d.ts +2 -2
- package/lib/pricing/product-catalog-price.d.ts.map +1 -1
- package/lib/pricing/product-catalog-price.js +7 -6
- package/lib/pricing/product-catalog-price.js.map +1 -1
- package/lib/pricing/product-discount.js +1 -2
- package/lib/pricing/product-discount.js.map +1 -1
- package/lib/pricing/product-price-rateconversion.d.ts +1 -1
- package/lib/pricing/product-price-rateconversion.d.ts.map +1 -1
- package/lib/pricing/product-price-rateconversion.js +1 -1
- package/lib/pricing/product-price-rateconversion.js.map +1 -1
- package/lib/pricing/product-round.d.ts +1 -1
- package/lib/pricing/product-round.d.ts.map +1 -1
- package/lib/pricing/product-round.js +1 -1
- package/lib/pricing/product-round.js.map +1 -1
- package/lib/pricing/product-swiss-tax.d.ts +4 -3
- package/lib/pricing/product-swiss-tax.d.ts.map +1 -1
- package/lib/pricing/product-swiss-tax.js +1 -2
- package/lib/pricing/product-swiss-tax.js.map +1 -1
- package/lib/quotations/manual.js +1 -1
- package/lib/quotations/manual.js.map +1 -1
- package/lib/warehousing/eth-minter.js +7 -4
- package/lib/warehousing/eth-minter.js.map +1 -1
- package/lib/warehousing/store.js +2 -1
- package/lib/warehousing/store.js.map +1 -1
- package/lib/worker/BaseWorker.d.ts +30 -0
- package/lib/worker/BaseWorker.d.ts.map +1 -0
- package/lib/worker/BaseWorker.js +81 -0
- package/lib/worker/BaseWorker.js.map +1 -0
- package/lib/worker/EventListenerWorker.d.ts +6 -0
- package/lib/worker/EventListenerWorker.d.ts.map +1 -0
- package/lib/worker/EventListenerWorker.js +46 -0
- package/lib/worker/EventListenerWorker.js.map +1 -0
- package/lib/worker/FailedRescheduler.d.ts +15 -0
- package/lib/worker/FailedRescheduler.d.ts.map +1 -0
- package/lib/worker/FailedRescheduler.js +45 -0
- package/lib/worker/FailedRescheduler.js.map +1 -0
- package/lib/worker/IntervalWorker.d.ts +10 -0
- package/lib/worker/IntervalWorker.d.ts.map +1 -0
- package/lib/worker/IntervalWorker.js +37 -0
- package/lib/worker/IntervalWorker.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 +7 -8
- package/lib/worker/bulk-import.js.map +1 -1
- package/lib/worker/email.d.ts.map +1 -1
- package/lib/worker/email.js +1 -5
- 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 +17 -15
- package/lib/worker/enrollment-order-generator.js.map +1 -1
- package/lib/worker/error-notifications.d.ts +1 -1
- package/lib/worker/error-notifications.d.ts.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 +1 -2
- package/lib/worker/export-token.d.ts.map +1 -1
- package/lib/worker/export-token.js +2 -1
- package/lib/worker/export-token.js.map +1 -1
- package/lib/worker/external.d.ts +1 -1
- package/lib/worker/external.d.ts.map +1 -1
- package/lib/worker/external.js +1 -1
- package/lib/worker/external.js.map +1 -1
- package/lib/worker/heartbeat.js +1 -1
- package/lib/worker/heartbeat.js.map +1 -1
- package/lib/worker/http-request.d.ts +1 -1
- package/lib/worker/http-request.d.ts.map +1 -1
- package/lib/worker/http-request.js +1 -5
- package/lib/worker/http-request.js.map +1 -1
- package/lib/worker/message.d.ts +2 -2
- package/lib/worker/message.d.ts.map +1 -1
- package/lib/worker/message.js +1 -5
- package/lib/worker/message.js.map +1 -1
- package/lib/worker/push-notification.js +1 -4
- package/lib/worker/push-notification.js.map +1 -1
- package/lib/worker/sms.js +1 -4
- package/lib/worker/sms.js.map +1 -1
- package/lib/worker/update-coinbase-rates.js +1 -1
- package/lib/worker/update-coinbase-rates.js.map +1 -1
- package/lib/worker/update-ecb-rates.js +1 -1
- package/lib/worker/update-ecb-rates.js.map +1 -1
- package/lib/worker/update-token-ownership.d.ts +1 -1
- package/lib/worker/update-token-ownership.d.ts.map +1 -1
- package/lib/worker/update-token-ownership.js +1 -1
- package/lib/worker/update-token-ownership.js.map +1 -1
- package/lib/worker/zombie-killer.d.ts +8 -2
- package/lib/worker/zombie-killer.d.ts.map +1 -1
- package/lib/worker/zombie-killer.js +12 -9
- package/lib/worker/zombie-killer.js.map +1 -1
- package/package.json +37 -82
- package/src/delivery/pick-mup.ts +2 -3
- package/src/delivery/post.ts +2 -2
- package/src/delivery/send-message.ts +2 -2
- package/src/delivery/stores.ts +2 -2
- package/src/enrollments/licensed.ts +1 -2
- package/src/events/aws-eventbridge.ts +43 -0
- package/src/events/node-event-emitter.ts +1 -2
- package/src/events/redis.ts +4 -2
- package/src/files/gridfs/gridfs-adapter.ts +15 -5
- package/src/files/gridfs/gridfs-webhook.ts +29 -9
- package/src/files/gridfs/sign.ts +20 -8
- package/src/files/minio/minio-adapter.ts +14 -11
- package/src/files/minio/minio-webhook.ts +5 -3
- package/src/filters/local-search.ts +1 -2
- package/src/filters/strict-equal.ts +1 -2
- package/src/payment/apple-iap/adapter.ts +22 -40
- package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +1 -1
- package/src/payment/apple-iap/module/configureAppleTransactionsModule.ts +1 -1
- package/src/payment/braintree.ts +16 -9
- package/src/payment/cryptopay/db/CryptopayTransactions.ts +1 -1
- package/src/payment/cryptopay/middleware.ts +11 -8
- package/src/payment/cryptopay/plugin.ts +14 -11
- package/src/payment/datatrans-v2/api/authorize.ts +1 -1
- package/src/payment/datatrans-v2/api/authorizeAuthenticated.ts +1 -1
- package/src/payment/datatrans-v2/api/cancel.ts +1 -1
- package/src/payment/datatrans-v2/api/init.ts +1 -1
- package/src/payment/datatrans-v2/api/makeFetcher.ts +0 -1
- package/src/payment/datatrans-v2/api/secureFields.ts +1 -1
- package/src/payment/datatrans-v2/api/settle.ts +1 -1
- package/src/payment/datatrans-v2/api/status.ts +1 -1
- package/src/payment/datatrans-v2/api/validate.ts +1 -1
- package/src/payment/datatrans-v2/generateSignature.test.ts +15 -0
- package/src/payment/datatrans-v2/generateSignature.ts +18 -6
- package/src/payment/datatrans-v2/index.ts +41 -36
- package/src/payment/datatrans-v2/middleware.ts +8 -12
- package/src/payment/datatrans-v2/parseRegistrationData.ts +7 -5
- package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +6 -6
- package/src/payment/datatrans-v2/splitProperties.ts +0 -5
- package/src/payment/invoice-prepaid.ts +4 -4
- package/src/payment/invoice.ts +4 -4
- package/src/payment/paypal-checkout.ts +16 -7
- package/src/payment/payrexx/api/makeFetcher.ts +2 -3
- package/src/payment/payrexx/index.ts +26 -15
- package/src/payment/payrexx/middleware.ts +14 -19
- package/src/payment/postfinance-checkout/index.ts +26 -17
- package/src/payment/postfinance-checkout/middleware.ts +6 -9
- package/src/payment/postfinance-checkout/utils.ts +6 -3
- package/src/payment/saferpay/adapter.ts +23 -13
- package/src/payment/saferpay/api/api/SaferpayConnection.ts +0 -1
- package/src/payment/saferpay/api/models/TransactionCapture.ts +1 -1
- package/src/payment/saferpay/db/SaferpayTransactionsCollection.ts +1 -1
- package/src/payment/saferpay/middleware.ts +6 -10
- package/src/payment/stripe/index.ts +23 -12
- package/src/payment/stripe/middleware.ts +15 -23
- package/src/payment/stripe/stripe.ts +6 -5
- package/src/pricing/delivery-swiss-tax.ts +6 -2
- package/src/pricing/discount-100-off.ts +4 -3
- package/src/pricing/discount-half-price-manual.ts +9 -5
- package/src/pricing/discount-half-price.ts +9 -5
- package/src/pricing/free-delivery.ts +1 -1
- package/src/pricing/free-payment.ts +1 -1
- package/src/pricing/order-delivery.ts +11 -8
- package/src/pricing/order-discount.ts +26 -11
- package/src/pricing/order-items-discount.ts +12 -5
- package/src/pricing/order-items.ts +12 -8
- package/src/pricing/order-payment.ts +11 -8
- package/src/pricing/order-round.ts +6 -2
- package/src/pricing/product-catalog-price.ts +12 -7
- package/src/pricing/product-discount.ts +5 -4
- package/src/pricing/product-price-rateconversion.ts +5 -2
- package/src/pricing/product-round.ts +5 -2
- package/src/pricing/product-swiss-tax.ts +5 -3
- package/src/quotations/manual.ts +1 -2
- package/src/warehousing/eth-minter.ts +11 -10
- package/src/warehousing/store.ts +2 -6
- package/src/worker/BaseWorker.ts +119 -0
- package/src/worker/EventListenerWorker.ts +61 -0
- package/src/worker/FailedRescheduler.ts +80 -0
- package/src/worker/IntervalWorker.ts +54 -0
- package/src/worker/bulk-import.ts +12 -13
- package/src/worker/email.ts +1 -8
- package/src/worker/enrollment-order-generator.ts +25 -34
- package/src/worker/error-notifications.ts +2 -2
- package/src/worker/export-token.ts +2 -8
- package/src/worker/external.ts +1 -2
- package/src/worker/heartbeat.ts +1 -2
- package/src/worker/http-request.ts +1 -8
- package/src/worker/message.ts +2 -6
- package/src/worker/push-notification.ts +1 -6
- package/src/worker/sms.ts +1 -7
- package/src/worker/update-coinbase-rates.ts +1 -3
- package/src/worker/update-ecb-rates.ts +1 -3
- package/src/worker/update-token-ownership.ts +1 -2
- package/src/worker/zombie-killer.ts +23 -23
- package/tsconfig.json +4 -5
- /package/src/payment/datatrans-v2/api/{types.d.ts → types.ts} +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { FilterDirector, FilterAdapter } from '@unchainedshop/core-filters';
|
|
2
|
-
import { IFilterAdapter } from '@unchainedshop/core-filters';
|
|
3
1
|
import { mongodb } from '@unchainedshop/mongodb';
|
|
4
2
|
import { ProductText } from '@unchainedshop/core-products';
|
|
5
3
|
import { AssortmentText } from '@unchainedshop/core-assortments';
|
|
4
|
+
import { FilterDirector, FilterAdapter, IFilterAdapter } from '@unchainedshop/core';
|
|
6
5
|
|
|
7
6
|
function escapeStringRegexp(string) {
|
|
8
7
|
if (typeof string !== 'string') {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IFilterAdapter } from '@unchainedshop/core
|
|
2
|
-
import { FilterDirector, FilterAdapter } from '@unchainedshop/core-filters';
|
|
1
|
+
import { IFilterAdapter, FilterDirector, FilterAdapter } from '@unchainedshop/core';
|
|
3
2
|
|
|
4
3
|
const StrictQualFilter: IFilterAdapter = {
|
|
5
4
|
...FilterAdapter,
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
/// <reference lib="dom" />
|
|
2
1
|
import { Context } from '@unchainedshop/api';
|
|
3
|
-
import { IPaymentAdapter } from '@unchainedshop/core-payment';
|
|
4
2
|
import { EnrollmentStatus } from '@unchainedshop/core-enrollments';
|
|
5
|
-
import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core
|
|
3
|
+
import { IPaymentAdapter, PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core';
|
|
6
4
|
import { createLogger } from '@unchainedshop/logger';
|
|
7
5
|
import { UnchainedCore } from '@unchainedshop/core';
|
|
8
6
|
import { AppleTransactionsModule } from './module/configureAppleTransactionsModule.js';
|
|
@@ -82,7 +80,7 @@ export const appleIAPHandler = async (req, res) => {
|
|
|
82
80
|
if (req.method === 'POST') {
|
|
83
81
|
try {
|
|
84
82
|
const resolvedContext = req.unchainedContext as Context;
|
|
85
|
-
const { modules } = resolvedContext;
|
|
83
|
+
const { modules, services } = resolvedContext;
|
|
86
84
|
const responseBody = req.body || {};
|
|
87
85
|
if (responseBody.password !== APPLE_IAP_SHARED_SECRET) {
|
|
88
86
|
throw new Error('shared secret not valid');
|
|
@@ -101,15 +99,11 @@ export const appleIAPHandler = async (req, res) => {
|
|
|
101
99
|
|
|
102
100
|
if (!orderPayment) throw new Error('Could not find any matching order payment');
|
|
103
101
|
|
|
104
|
-
const order = await
|
|
105
|
-
|
|
106
|
-
{
|
|
107
|
-
paymentContext: {
|
|
102
|
+
const order = await services.orders.checkoutOrder(orderPayment.orderId, {
|
|
103
|
+
paymentContext: {
|
|
108
104
|
receiptData: responseBody?.unified_receipt?.latest_receipt, // eslint-disable-line
|
|
109
|
-
},
|
|
110
105
|
},
|
|
111
|
-
|
|
112
|
-
);
|
|
106
|
+
});
|
|
113
107
|
const orderId = order._id;
|
|
114
108
|
const enrollment = await modules.enrollments.findEnrollment({
|
|
115
109
|
orderId,
|
|
@@ -143,16 +137,12 @@ export const appleIAPHandler = async (req, res) => {
|
|
|
143
137
|
orderId: originalOrder._id,
|
|
144
138
|
});
|
|
145
139
|
|
|
146
|
-
await
|
|
147
|
-
|
|
148
|
-
{
|
|
149
|
-
transactionContext: {
|
|
140
|
+
await services.orders.registerPaymentCredentials(enrollment.payment.paymentProviderId, {
|
|
141
|
+
transactionContext: {
|
|
150
142
|
receiptData: responseBody?.unified_receipt?.latest_receipt, // eslint-disable-line
|
|
151
|
-
},
|
|
152
|
-
userId: enrollment.userId,
|
|
153
143
|
},
|
|
154
|
-
|
|
155
|
-
);
|
|
144
|
+
userId: enrollment.userId,
|
|
145
|
+
});
|
|
156
146
|
|
|
157
147
|
await fixPeriods(
|
|
158
148
|
{
|
|
@@ -173,7 +163,7 @@ export const appleIAPHandler = async (req, res) => {
|
|
|
173
163
|
enrollment.status !== EnrollmentStatus.TERMINATED &&
|
|
174
164
|
responseBody.auto_renew_status === 'false'
|
|
175
165
|
) {
|
|
176
|
-
await
|
|
166
|
+
await services.enrollments.terminateEnrollment(enrollment);
|
|
177
167
|
}
|
|
178
168
|
}
|
|
179
169
|
|
|
@@ -182,7 +172,7 @@ export const appleIAPHandler = async (req, res) => {
|
|
|
182
172
|
enrollment.status !== EnrollmentStatus.TERMINATED &&
|
|
183
173
|
responseBody.auto_renew_status === 'false'
|
|
184
174
|
) {
|
|
185
|
-
await
|
|
175
|
+
await services.enrollments.terminateEnrollment(enrollment);
|
|
186
176
|
}
|
|
187
177
|
}
|
|
188
178
|
logger.info(`Apple IAP Webhook: Updated enrollment from Apple`);
|
|
@@ -214,11 +204,11 @@ const AppleIAP: IPaymentAdapter = {
|
|
|
214
204
|
return type === 'GENERIC';
|
|
215
205
|
},
|
|
216
206
|
|
|
217
|
-
actions: (params) => {
|
|
218
|
-
const { modules } =
|
|
207
|
+
actions: (params, context) => {
|
|
208
|
+
const { modules } = context;
|
|
219
209
|
|
|
220
210
|
const adapterActions = {
|
|
221
|
-
...PaymentAdapter.actions(params),
|
|
211
|
+
...PaymentAdapter.actions(params, context),
|
|
222
212
|
|
|
223
213
|
configurationError() {
|
|
224
214
|
// eslint-disable-line
|
|
@@ -260,9 +250,7 @@ const AppleIAP: IPaymentAdapter = {
|
|
|
260
250
|
const { status, latest_receipt_info: latestReceiptInfo } = response; // eslint-disable-line
|
|
261
251
|
|
|
262
252
|
if (status === 0) {
|
|
263
|
-
logger.
|
|
264
|
-
level: 'verbose',
|
|
265
|
-
});
|
|
253
|
+
logger.debug('Apple IAP Plugin: Receipt validated and updated for the user');
|
|
266
254
|
const latestTransaction = latestReceiptInfo[latestReceiptInfo.length - 1]; // eslint-disable-line
|
|
267
255
|
return {
|
|
268
256
|
token: latestTransaction.web_order_line_item_id, // eslint-disable-line
|
|
@@ -271,7 +259,6 @@ const AppleIAP: IPaymentAdapter = {
|
|
|
271
259
|
}
|
|
272
260
|
|
|
273
261
|
logger.warn('Apple IAP Plugin: Receipt invalid', {
|
|
274
|
-
level: 'warn',
|
|
275
262
|
status: response.status,
|
|
276
263
|
});
|
|
277
264
|
return null;
|
|
@@ -279,11 +266,10 @@ const AppleIAP: IPaymentAdapter = {
|
|
|
279
266
|
|
|
280
267
|
// eslint-disable-next-line
|
|
281
268
|
async charge(transactionContext) {
|
|
282
|
-
const { order } =
|
|
269
|
+
const { order } = context;
|
|
283
270
|
const { meta, paymentCredentials, receiptData } = transactionContext || {};
|
|
284
271
|
const { transactionIdentifier } = meta || {};
|
|
285
|
-
const appleTransactions = (
|
|
286
|
-
.appleTransactions as AppleTransactionsModule;
|
|
272
|
+
const appleTransactions = (context.modules as any).appleTransactions as AppleTransactionsModule;
|
|
287
273
|
|
|
288
274
|
if (!transactionIdentifier) {
|
|
289
275
|
throw new Error('Apple IAP Plugin: You have to set the transaction id on the order payment');
|
|
@@ -344,15 +330,11 @@ const AppleIAP: IPaymentAdapter = {
|
|
|
344
330
|
throw new Error('Apple IAP Plugin: Transaction already processed');
|
|
345
331
|
|
|
346
332
|
// All good
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
orderId: order._id,
|
|
353
|
-
},
|
|
354
|
-
userId,
|
|
355
|
-
);
|
|
333
|
+
await appleTransactions.createTransaction({
|
|
334
|
+
_id: transactionIdentifier,
|
|
335
|
+
matchedTransaction,
|
|
336
|
+
orderId: order._id,
|
|
337
|
+
});
|
|
356
338
|
|
|
357
339
|
return {
|
|
358
340
|
transactionIdentifier,
|
|
@@ -3,7 +3,7 @@ import { AppleTransaction, AppleTransactionsCollection } from '../db/AppleTransa
|
|
|
3
3
|
export interface AppleTransactionsModule {
|
|
4
4
|
findTransactionById: (transactionIdentifier: string) => Promise<AppleTransaction>;
|
|
5
5
|
|
|
6
|
-
createTransaction: (doc: AppleTransaction
|
|
6
|
+
createTransaction: (doc: AppleTransaction) => Promise<string | null>;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export const configureAppleTransactionsModule = async ({ db }): Promise<AppleTransactionsModule> => {
|
package/src/payment/braintree.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { IPaymentAdapter } from '@unchainedshop/core-payment';
|
|
2
|
-
import { PaymentDirector, PaymentAdapter, PaymentError } from '@unchainedshop/core-payment';
|
|
3
1
|
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
+
import {
|
|
3
|
+
IPaymentAdapter,
|
|
4
|
+
PaymentAdapter,
|
|
5
|
+
PaymentDirector,
|
|
6
|
+
PaymentError,
|
|
7
|
+
OrderPricingSheet,
|
|
8
|
+
} from '@unchainedshop/core';
|
|
4
9
|
|
|
5
10
|
const logger = createLogger('unchained:core-payment:braintree');
|
|
6
11
|
|
|
@@ -28,16 +33,16 @@ const BraintreeDirect: IPaymentAdapter = {
|
|
|
28
33
|
return type === 'GENERIC';
|
|
29
34
|
},
|
|
30
35
|
|
|
31
|
-
actions: (
|
|
36
|
+
actions: (config, context) => {
|
|
32
37
|
const getPublicKey = () => {
|
|
33
|
-
return
|
|
38
|
+
return config.reduce((current, item) => {
|
|
34
39
|
if (item.key === 'publicKey') return item.value;
|
|
35
40
|
return current;
|
|
36
41
|
}, null);
|
|
37
42
|
};
|
|
38
43
|
|
|
39
44
|
const getMerchantId = () => {
|
|
40
|
-
return
|
|
45
|
+
return config.reduce((current, item) => {
|
|
41
46
|
if (item.key === 'merchantId') return item.value;
|
|
42
47
|
return current;
|
|
43
48
|
}, null);
|
|
@@ -69,7 +74,7 @@ const BraintreeDirect: IPaymentAdapter = {
|
|
|
69
74
|
};
|
|
70
75
|
|
|
71
76
|
const adapter = {
|
|
72
|
-
...PaymentAdapter.actions(
|
|
77
|
+
...PaymentAdapter.actions(config, context),
|
|
73
78
|
|
|
74
79
|
configurationError: () => {
|
|
75
80
|
const publicCredentialsValid =
|
|
@@ -103,8 +108,7 @@ const BraintreeDirect: IPaymentAdapter = {
|
|
|
103
108
|
},
|
|
104
109
|
|
|
105
110
|
charge: async ({ paypalPaymentMethodNonce }) => {
|
|
106
|
-
const {
|
|
107
|
-
const { order } = params.paymentContext;
|
|
111
|
+
const { order } = context;
|
|
108
112
|
if (!paypalPaymentMethodNonce)
|
|
109
113
|
throw new Error('You have to provide paypalPaymentMethodNonce in paymentContext');
|
|
110
114
|
|
|
@@ -113,7 +117,10 @@ const BraintreeDirect: IPaymentAdapter = {
|
|
|
113
117
|
const braintree = (await import('braintree')).default; // eslint-disable-line
|
|
114
118
|
const gateway = getGateway(braintree);
|
|
115
119
|
const address = order.billingAddress;
|
|
116
|
-
const pricing =
|
|
120
|
+
const pricing = OrderPricingSheet({
|
|
121
|
+
calculation: order.calculation,
|
|
122
|
+
currency: order.currency,
|
|
123
|
+
});
|
|
117
124
|
const rounded = Math.round(pricing.total({ useNetPrice: false }).amount / 10 || 0) * 10;
|
|
118
125
|
const saleRequest = {
|
|
119
126
|
amount: rounded / 100,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { createLogger } from '@unchainedshop/logger';
|
|
2
2
|
import { Context } from '@unchainedshop/api';
|
|
3
|
-
|
|
4
|
-
import { UnchainedCore } from '@unchainedshop/core';
|
|
5
3
|
import { OrderStatus } from '@unchainedshop/core-orders';
|
|
6
|
-
import
|
|
4
|
+
import { CryptopayModule } from './module/configureCryptopayModule.js';
|
|
7
5
|
import { ProductPriceRate } from '@unchainedshop/core-products';
|
|
8
6
|
|
|
9
7
|
const { CRYPTOPAY_SECRET, CRYPTOPAY_MAX_RATE_AGE = '360' } = process.env;
|
|
@@ -11,8 +9,13 @@ const { CRYPTOPAY_SECRET, CRYPTOPAY_MAX_RATE_AGE = '360' } = process.env;
|
|
|
11
9
|
const logger = createLogger('unchained:core-payment:cryptopay');
|
|
12
10
|
|
|
13
11
|
export const cryptopayHandler = async (req, res) => {
|
|
14
|
-
const resolvedContext = req.unchainedContext as Context
|
|
15
|
-
|
|
12
|
+
const resolvedContext = req.unchainedContext as Context & {
|
|
13
|
+
modules: {
|
|
14
|
+
cryptopay: CryptopayModule;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
const { modules, services } = resolvedContext;
|
|
18
|
+
|
|
16
19
|
if (req.method === 'POST') {
|
|
17
20
|
try {
|
|
18
21
|
const { secret, price, wallet, ping } = req.body;
|
|
@@ -42,9 +45,9 @@ export const cryptopayHandler = async (req, res) => {
|
|
|
42
45
|
// TODO: Not sure if it's correct to use processOrder here if status is PENDING!
|
|
43
46
|
const order = await modules.orders.findOrder({ orderId: orderPayment.orderId });
|
|
44
47
|
if (order.status === null) {
|
|
45
|
-
await
|
|
48
|
+
await services.orders.checkoutOrder(order._id, {});
|
|
46
49
|
} else if (order.status === OrderStatus.PENDING) {
|
|
47
|
-
await
|
|
50
|
+
await services.orders.processOrder(order, {});
|
|
48
51
|
} else {
|
|
49
52
|
throw new Error('Already processed');
|
|
50
53
|
}
|
|
@@ -64,7 +67,7 @@ export const cryptopayHandler = async (req, res) => {
|
|
|
64
67
|
expiresAt,
|
|
65
68
|
timestamp: timestampDate,
|
|
66
69
|
};
|
|
67
|
-
logger.
|
|
70
|
+
logger.info(`update rate ${JSON.stringify(price)}, ${JSON.stringify(rateData)}`);
|
|
68
71
|
await resolvedContext.modules.products.prices.rates.updateRates([rateData]);
|
|
69
72
|
}
|
|
70
73
|
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { IPaymentAdapter } from '@unchainedshop/core-payment';
|
|
2
|
-
import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
|
|
3
1
|
import { ethers } from 'ethers';
|
|
4
2
|
import { BIP32Factory } from 'bip32';
|
|
5
3
|
import * as ecc from 'tiny-secp256k1';
|
|
6
4
|
import { networks, payments } from 'bitcoinjs-lib';
|
|
7
5
|
import { createLogger } from '@unchainedshop/logger';
|
|
8
|
-
import {
|
|
9
|
-
|
|
6
|
+
import {
|
|
7
|
+
IPaymentAdapter,
|
|
8
|
+
PaymentAdapter,
|
|
9
|
+
PaymentDirector,
|
|
10
|
+
PaymentError,
|
|
11
|
+
OrderPricingSheet,
|
|
12
|
+
} from '@unchainedshop/core';
|
|
10
13
|
import { CryptopayModule } from './module/configureCryptopayModule.js';
|
|
11
14
|
|
|
12
15
|
const logger = createLogger('unchained:core-payment:cryptopay');
|
|
@@ -55,8 +58,8 @@ const Cryptopay: IPaymentAdapter = {
|
|
|
55
58
|
return type === 'GENERIC';
|
|
56
59
|
},
|
|
57
60
|
|
|
58
|
-
actions: (
|
|
59
|
-
const modules =
|
|
61
|
+
actions: (config, context) => {
|
|
62
|
+
const { modules } = context as typeof context & { modules: { cryptopay: CryptopayModule } };
|
|
60
63
|
|
|
61
64
|
const setConversionRates = async (currencyCode: string, existingAddresses: any[]) => {
|
|
62
65
|
const originCurrencyObj = await modules.currencies.findCurrency({ isoCode: currencyCode });
|
|
@@ -97,7 +100,7 @@ const Cryptopay: IPaymentAdapter = {
|
|
|
97
100
|
};
|
|
98
101
|
|
|
99
102
|
const adapterActions = {
|
|
100
|
-
...PaymentAdapter.actions(
|
|
103
|
+
...PaymentAdapter.actions(config, context),
|
|
101
104
|
|
|
102
105
|
// eslint-disable-next-line
|
|
103
106
|
configurationError() {
|
|
@@ -114,10 +117,10 @@ const Cryptopay: IPaymentAdapter = {
|
|
|
114
117
|
isActive() {
|
|
115
118
|
// Only support orders that have prices in BTC or ETH for the moment
|
|
116
119
|
if (adapterActions.configurationError() !== null) return false;
|
|
117
|
-
if (!
|
|
120
|
+
if (!context.order) return true;
|
|
118
121
|
// if (
|
|
119
122
|
// !Object.values(CryptopayCurrencies).includes(
|
|
120
|
-
//
|
|
123
|
+
// context.order.currency as CryptopayCurrencies,
|
|
121
124
|
// )
|
|
122
125
|
// )
|
|
123
126
|
// return false;
|
|
@@ -129,7 +132,7 @@ const Cryptopay: IPaymentAdapter = {
|
|
|
129
132
|
},
|
|
130
133
|
|
|
131
134
|
sign: async () => {
|
|
132
|
-
const { orderPayment, order } =
|
|
135
|
+
const { orderPayment, order } = context;
|
|
133
136
|
|
|
134
137
|
const existingAddresses = await modules.cryptopay.getWalletAddressesByOrderPaymentId(
|
|
135
138
|
orderPayment._id,
|
|
@@ -190,7 +193,7 @@ const Cryptopay: IPaymentAdapter = {
|
|
|
190
193
|
},
|
|
191
194
|
|
|
192
195
|
charge: async () => {
|
|
193
|
-
const { order, orderPayment } =
|
|
196
|
+
const { order, orderPayment } = context;
|
|
194
197
|
|
|
195
198
|
const foundWalletsWithBalances = await modules.cryptopay.getWalletAddressesByOrderPaymentId(
|
|
196
199
|
orderPayment._id,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://api-reference.datatrans.ch/#operation/Authorize
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { FetchDatatransFn, AuthorizeRequestPayload, AuthorizeResponse } from './types.js';
|
|
4
4
|
|
|
5
5
|
export default async function authorize({
|
|
6
6
|
...payload
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// https://api-reference.datatrans.ch/#operation/init
|
|
2
2
|
import getPaths from '../getPaths.js';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { FetchDatatransFn, InitRequestPayload, InitResponse } from './types.js';
|
|
5
5
|
|
|
6
6
|
const defaultRedirect = getPaths();
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// https://api-reference.datatrans.ch/#operation/init
|
|
2
2
|
import getPaths from '../getPaths.js';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { FetchDatatransFn, SecureFieldsRequestPayload, SecureFieldsResponse } from './types.js';
|
|
5
5
|
|
|
6
6
|
const defaultRedirect = getPaths();
|
|
7
7
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FetchDatatransFn, StatusRequestPayload, StatusResponse } from './types.js';
|
|
2
2
|
|
|
3
3
|
export default async function status({ transactionId }: StatusRequestPayload): Promise<StatusResponse> {
|
|
4
4
|
const { fetchDatatrans }: { fetchDatatrans: FetchDatatransFn } = this;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FetchDatatransFn, ValidateRequestPayload, ValidateResponse } from './types.js';
|
|
2
2
|
|
|
3
3
|
export default async function validate(payload: ValidateRequestPayload): Promise<ValidateResponse> {
|
|
4
4
|
const { fetchDatatrans }: { fetchDatatrans: FetchDatatransFn } = this;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import generateSignature from './generateSignature';
|
|
2
|
+
|
|
3
|
+
describe('Datatrans Signature', () => {
|
|
4
|
+
it('Correct hashing applies', async () => {
|
|
5
|
+
const { security, signKey, timestamp, body } = {
|
|
6
|
+
security: 'dynamic-sign' as any,
|
|
7
|
+
signKey: '1337',
|
|
8
|
+
timestamp: '12424123412',
|
|
9
|
+
body: '{"card":{"3D":{"authenticationResponse":"D"},"alias":"70119122433810042","expiryMonth":"12","expiryYear":"21","info":{"brand":"VISA CREDIT","country":"GB","issuer":"DATATRANS","type":"credit","usage":"consumer"},"masked":"424242xxxxxx4242"},"currency":"CHF","detail":{"authorize":{"acquirerAuthorizationCode":"100055"}},"history":[{"action":"init","date":"2021-09-03T08:00:32Z","ip":"212.232.234.26","source":"api","success":true},{"action":"authorize","date":"2021-09-03T08:00:55Z","ip":"212.232.234.26","source":"redirect","success":true}],"language":"de","paymentMethod":"VIS","refno":"1NTU1NQ=","refno2":"user","status":"authorized","transactionId":"card_check_authorized","type":"card_check"}',
|
|
10
|
+
};
|
|
11
|
+
expect(await generateSignature({ security, signKey })(timestamp, body)).toEqual(
|
|
12
|
+
'5118c93025fdb16a110cdde3aa7669422da320cfe9478e35b531f45c4619d4db',
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import crypto from 'crypto';
|
|
2
|
-
|
|
3
1
|
export const Security = {
|
|
4
2
|
NONE: '',
|
|
5
3
|
STATIC_SIGN: 'static-sign',
|
|
@@ -8,17 +6,31 @@ export const Security = {
|
|
|
8
6
|
|
|
9
7
|
const generateSignature =
|
|
10
8
|
({ security, signKey }: { security: '' | 'static-sign' | 'dynamic-sign'; signKey: string }) =>
|
|
11
|
-
(...parts) => {
|
|
9
|
+
async (...parts) => {
|
|
12
10
|
// https://docs.datatrans.ch/docs/security-sign
|
|
13
11
|
if (security.toLowerCase() === Security.STATIC_SIGN) return signKey;
|
|
14
12
|
if (security.toLowerCase() === Security.NONE) return '';
|
|
15
13
|
|
|
16
14
|
const resultString = parts.filter(Boolean).join('');
|
|
17
|
-
const signKeyInBytes = Buffer.from(signKey, 'hex');
|
|
18
15
|
|
|
19
|
-
const
|
|
16
|
+
const signKeyInBytes = Buffer.from(signKey, 'hex');
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
const key = await crypto.subtle.importKey(
|
|
19
|
+
'raw',
|
|
20
|
+
Uint8Array.from(signKeyInBytes),
|
|
21
|
+
{ name: 'HMAC', hash: 'SHA-256' },
|
|
22
|
+
false,
|
|
23
|
+
['sign'],
|
|
24
|
+
);
|
|
25
|
+
const signatureBinary = await crypto.subtle.sign(
|
|
26
|
+
'HMAC',
|
|
27
|
+
key,
|
|
28
|
+
new TextEncoder().encode(resultString),
|
|
29
|
+
);
|
|
30
|
+
const hmacSubtle = Array.from(new Uint8Array(signatureBinary))
|
|
31
|
+
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
32
|
+
.join('');
|
|
33
|
+
return hmacSubtle;
|
|
22
34
|
};
|
|
23
35
|
|
|
24
36
|
export default generateSignature;
|