@unchainedshop/plugins 1.1.7 → 1.2.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/jest.config.js +5 -0
- package/package.json +31 -25
- package/src/files/gridfs/gridfs-adapter.ts +1 -1
- package/src/files/gridfs/gridfs-webhook.ts +62 -0
- package/src/files/gridfs/{index.js → index.ts} +0 -0
- package/src/files/gridfs/{promisePipe.js → promisePipe.ts} +0 -0
- package/src/files/gridfs/{sign.js → sign.ts} +0 -0
- package/src/files/minio/minio-adapter.ts +1 -2
- package/src/files/minio/minio-webhook.js +33 -30
- package/src/payment/apple-iap/adapter.ts +113 -110
- package/src/payment/apple-iap/index.ts +2 -1
- package/src/payment/bity/adapter.ts +53 -51
- package/src/payment/bity/index.ts +2 -1
- package/src/payment/braintree.ts +2 -2
- package/src/payment/cryptopay.ts +69 -67
- package/src/payment/datatrans-v2/index.ts +3 -1
- package/src/payment/datatrans-v2/middleware.ts +129 -123
- package/src/payment/paypal-checkout.ts +1 -1
- package/src/payment/postfinance-checkout/index.ts +3 -1
- package/src/payment/postfinance-checkout/middleware.ts +42 -40
- package/src/payment/stripe.ts +82 -74
- package/src/payment/worldline-saferpay/worldline-saferpay-client/index.ts +3 -3
- package/src/pricing/product-discount.ts +1 -1
- package/src/pricing/product-price-ECB-interbank-exchange.ts +1 -1
- package/src/pricing/product-price-cryptopay.ts +20 -18
- package/src/worker/email.ts +1 -0
- package/tsconfig.json +26 -5
- package/lib/delivery/pick-mup.d.ts +0 -1
- package/lib/delivery/pick-mup.js +0 -98
- package/lib/delivery/pick-mup.js.map +0 -1
- package/lib/delivery/post.d.ts +0 -1
- package/lib/delivery/post.js +0 -23
- package/lib/delivery/post.js.map +0 -1
- package/lib/delivery/send-message.d.ts +0 -1
- package/lib/delivery/send-message.js +0 -41
- package/lib/delivery/send-message.js.map +0 -1
- package/lib/delivery/stores.d.ts +0 -1
- package/lib/delivery/stores.js +0 -39
- package/lib/delivery/stores.js.map +0 -1
- package/lib/enrollments/licensed.d.ts +0 -1
- package/lib/enrollments/licensed.js +0 -40
- package/lib/enrollments/licensed.js.map +0 -1
- package/lib/events/node-event-emitter.d.ts +0 -1
- package/lib/events/node-event-emitter.js +0 -16
- package/lib/events/node-event-emitter.js.map +0 -1
- package/lib/events/redis.d.ts +0 -1
- package/lib/events/redis.js +0 -24
- package/lib/events/redis.js.map +0 -1
- package/lib/files/gridfs/gridfs-adapter.d.ts +0 -2
- package/lib/files/gridfs/gridfs-adapter.js +0 -106
- package/lib/files/gridfs/gridfs-adapter.js.map +0 -1
- package/lib/files/gridfs/gridfs-webhook.d.ts +0 -1
- package/lib/files/gridfs/gridfs-webhook.js +0 -54
- package/lib/files/gridfs/gridfs-webhook.js.map +0 -1
- package/lib/files/gridfs/index.d.ts +0 -8
- package/lib/files/gridfs/index.js +0 -21
- package/lib/files/gridfs/index.js.map +0 -1
- package/lib/files/gridfs/promisePipe.d.ts +0 -2
- package/lib/files/gridfs/promisePipe.js +0 -21
- package/lib/files/gridfs/promisePipe.js.map +0 -1
- package/lib/files/gridfs/sign.d.ts +0 -2
- package/lib/files/gridfs/sign.js +0 -12
- package/lib/files/gridfs/sign.js.map +0 -1
- package/lib/files/minio/minio-adapter.d.ts +0 -4
- package/lib/files/minio/minio-adapter.js +0 -166
- package/lib/files/minio/minio-adapter.js.map +0 -1
- package/lib/files/minio/minio-webhook.d.ts +0 -1
- package/lib/files/minio/minio-webhook.js +0 -45
- package/lib/files/minio/minio-webhook.js.map +0 -1
- package/lib/filters/local-search.d.ts +0 -3
- package/lib/filters/local-search.js +0 -84
- package/lib/filters/local-search.js.map +0 -1
- package/lib/filters/strict-equal.d.ts +0 -1
- package/lib/filters/strict-equal.js +0 -25
- package/lib/filters/strict-equal.js.map +0 -1
- package/lib/payment/apple-iap/adapter.d.ts +0 -1
- package/lib/payment/apple-iap/adapter.js +0 -284
- package/lib/payment/apple-iap/adapter.js.map +0 -1
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts +0 -7
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.js +0 -5
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.js.map +0 -1
- package/lib/payment/apple-iap/index.d.ts +0 -2
- package/lib/payment/apple-iap/index.js +0 -3
- package/lib/payment/apple-iap/index.js.map +0 -1
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts +0 -9
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js +0 -18
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js.map +0 -1
- package/lib/payment/bity/adapter.d.ts +0 -1
- package/lib/payment/bity/adapter.js +0 -316
- package/lib/payment/bity/adapter.js.map +0 -1
- package/lib/payment/bity/db/BityCredentialsCollection.d.ts +0 -11
- package/lib/payment/bity/db/BityCredentialsCollection.js +0 -5
- package/lib/payment/bity/db/BityCredentialsCollection.js.map +0 -1
- package/lib/payment/bity/index.d.ts +0 -2
- package/lib/payment/bity/index.js +0 -3
- package/lib/payment/bity/index.js.map +0 -1
- package/lib/payment/bity/module/configureBityModule.d.ts +0 -11
- package/lib/payment/bity/module/configureBityModule.js +0 -33
- package/lib/payment/bity/module/configureBityModule.js.map +0 -1
- package/lib/payment/braintree.d.ts +0 -1
- package/lib/payment/braintree.js +0 -129
- package/lib/payment/braintree.js.map +0 -1
- package/lib/payment/cryptopay.d.ts +0 -1
- package/lib/payment/cryptopay.js +0 -159
- package/lib/payment/cryptopay.js.map +0 -1
- package/lib/payment/datatrans-v2/api/authorize.d.ts +0 -2
- package/lib/payment/datatrans-v2/api/authorize.js +0 -12
- package/lib/payment/datatrans-v2/api/authorize.js.map +0 -1
- package/lib/payment/datatrans-v2/api/authorizeAuthenticated.d.ts +0 -2
- package/lib/payment/datatrans-v2/api/authorizeAuthenticated.js +0 -11
- package/lib/payment/datatrans-v2/api/authorizeAuthenticated.js.map +0 -1
- package/lib/payment/datatrans-v2/api/cancel.d.ts +0 -2
- package/lib/payment/datatrans-v2/api/cancel.js +0 -10
- package/lib/payment/datatrans-v2/api/cancel.js.map +0 -1
- package/lib/payment/datatrans-v2/api/index.d.ts +0 -19
- package/lib/payment/datatrans-v2/api/index.js +0 -24
- package/lib/payment/datatrans-v2/api/index.js.map +0 -1
- package/lib/payment/datatrans-v2/api/init.d.ts +0 -2
- package/lib/payment/datatrans-v2/api/init.js +0 -31
- package/lib/payment/datatrans-v2/api/init.js.map +0 -1
- package/lib/payment/datatrans-v2/api/makeFetcher.d.ts +0 -2
- package/lib/payment/datatrans-v2/api/makeFetcher.js +0 -41
- package/lib/payment/datatrans-v2/api/makeFetcher.js.map +0 -1
- package/lib/payment/datatrans-v2/api/secureFields.d.ts +0 -2
- package/lib/payment/datatrans-v2/api/secureFields.js +0 -14
- package/lib/payment/datatrans-v2/api/secureFields.js.map +0 -1
- package/lib/payment/datatrans-v2/api/settle.d.ts +0 -2
- package/lib/payment/datatrans-v2/api/settle.js +0 -10
- package/lib/payment/datatrans-v2/api/settle.js.map +0 -1
- package/lib/payment/datatrans-v2/api/status.d.ts +0 -2
- package/lib/payment/datatrans-v2/api/status.js +0 -7
- package/lib/payment/datatrans-v2/api/status.js.map +0 -1
- package/lib/payment/datatrans-v2/api/validate.d.ts +0 -2
- package/lib/payment/datatrans-v2/api/validate.js +0 -10
- package/lib/payment/datatrans-v2/api/validate.js.map +0 -1
- package/lib/payment/datatrans-v2/generateSignature.d.ts +0 -10
- package/lib/payment/datatrans-v2/generateSignature.js +0 -19
- package/lib/payment/datatrans-v2/generateSignature.js.map +0 -1
- package/lib/payment/datatrans-v2/getPaths.d.ts +0 -9
- package/lib/payment/datatrans-v2/getPaths.js +0 -9
- package/lib/payment/datatrans-v2/getPaths.js.map +0 -1
- package/lib/payment/datatrans-v2/index.d.ts +0 -1
- package/lib/payment/datatrans-v2/index.js +0 -384
- package/lib/payment/datatrans-v2/index.js.map +0 -1
- package/lib/payment/datatrans-v2/middleware.d.ts +0 -1
- package/lib/payment/datatrans-v2/middleware.js +0 -111
- package/lib/payment/datatrans-v2/middleware.js.map +0 -1
- package/lib/payment/datatrans-v2/parseRegistrationData.d.ts +0 -11
- package/lib/payment/datatrans-v2/parseRegistrationData.js +0 -26
- package/lib/payment/datatrans-v2/parseRegistrationData.js.map +0 -1
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +0 -7
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.js +0 -10
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.js.map +0 -1
- package/lib/payment/datatrans-v2/splitProperties.d.ts +0 -8
- package/lib/payment/datatrans-v2/splitProperties.js +0 -58
- package/lib/payment/datatrans-v2/splitProperties.js.map +0 -1
- package/lib/payment/invoice-prepaid.d.ts +0 -1
- package/lib/payment/invoice-prepaid.js +0 -30
- package/lib/payment/invoice-prepaid.js.map +0 -1
- package/lib/payment/invoice.d.ts +0 -1
- package/lib/payment/invoice.js +0 -27
- package/lib/payment/invoice.js.map +0 -1
- package/lib/payment/paypal-checkout.d.ts +0 -1
- package/lib/payment/paypal-checkout.js +0 -82
- package/lib/payment/paypal-checkout.js.map +0 -1
- package/lib/payment/postfinance-checkout/api.d.ts +0 -11
- package/lib/payment/postfinance-checkout/api.js +0 -109
- package/lib/payment/postfinance-checkout/api.js.map +0 -1
- package/lib/payment/postfinance-checkout/index.d.ts +0 -1
- package/lib/payment/postfinance-checkout/index.js +0 -186
- package/lib/payment/postfinance-checkout/index.js.map +0 -1
- package/lib/payment/postfinance-checkout/middleware.d.ts +0 -1
- package/lib/payment/postfinance-checkout/middleware.js +0 -42
- package/lib/payment/postfinance-checkout/middleware.js.map +0 -1
- package/lib/payment/postfinance-checkout/types.d.ts +0 -23
- package/lib/payment/postfinance-checkout/types.js +0 -12
- package/lib/payment/postfinance-checkout/types.js.map +0 -1
- package/lib/payment/postfinance-checkout/utils.d.ts +0 -4
- package/lib/payment/postfinance-checkout/utils.js +0 -20
- package/lib/payment/postfinance-checkout/utils.js.map +0 -1
- package/lib/payment/stripe.d.ts +0 -1
- package/lib/payment/stripe.js +0 -214
- package/lib/payment/stripe.js.map +0 -1
- package/lib/payment/worldline-saferpay/index.d.ts +0 -1
- package/lib/payment/worldline-saferpay/index.js +0 -112
- package/lib/payment/worldline-saferpay/index.js.map +0 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.d.ts +0 -14
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js +0 -29
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js.map +0 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.d.ts +0 -9
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.js +0 -28
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.js.map +0 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.d.ts +0 -4
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js +0 -2
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js.map +0 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.d.ts +0 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.js +0 -2
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.js.map +0 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.d.ts +0 -73
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.js +0 -2
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.js.map +0 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.d.ts +0 -53
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.js +0 -2
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.js.map +0 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Request.d.ts +0 -13
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Request.js +0 -2
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Request.js.map +0 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Response.d.ts +0 -9
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Response.js +0 -2
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Response.js.map +0 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.d.ts +0 -5
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.js +0 -2
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.js.map +0 -1
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.d.ts +0 -13
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.js +0 -2
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.js.map +0 -1
- package/lib/pricing/delivery-swiss-tax.d.ts +0 -15
- package/lib/pricing/delivery-swiss-tax.js +0 -98
- package/lib/pricing/delivery-swiss-tax.js.map +0 -1
- package/lib/pricing/discount-100-off.d.ts +0 -1
- package/lib/pricing/discount-100-off.js +0 -34
- package/lib/pricing/discount-100-off.js.map +0 -1
- package/lib/pricing/discount-half-price-manual.d.ts +0 -1
- package/lib/pricing/discount-half-price-manual.js +0 -34
- package/lib/pricing/discount-half-price-manual.js.map +0 -1
- package/lib/pricing/discount-half-price.d.ts +0 -1
- package/lib/pricing/discount-half-price.js +0 -37
- package/lib/pricing/discount-half-price.js.map +0 -1
- package/lib/pricing/free-delivery.d.ts +0 -2
- package/lib/pricing/free-delivery.js +0 -26
- package/lib/pricing/free-delivery.js.map +0 -1
- package/lib/pricing/free-payment.d.ts +0 -2
- package/lib/pricing/free-payment.js +0 -26
- package/lib/pricing/free-payment.js.map +0 -1
- package/lib/pricing/order-delivery.d.ts +0 -1
- package/lib/pricing/order-delivery.js +0 -33
- package/lib/pricing/order-delivery.js.map +0 -1
- package/lib/pricing/order-discount.d.ts +0 -1
- package/lib/pricing/order-discount.js +0 -110
- package/lib/pricing/order-discount.js.map +0 -1
- package/lib/pricing/order-items-discount.d.ts +0 -1
- package/lib/pricing/order-items-discount.js +0 -88
- package/lib/pricing/order-items-discount.js.map +0 -1
- package/lib/pricing/order-items.d.ts +0 -1
- package/lib/pricing/order-items.js +0 -44
- package/lib/pricing/order-items.js.map +0 -1
- package/lib/pricing/order-payment.d.ts +0 -1
- package/lib/pricing/order-payment.js +0 -33
- package/lib/pricing/order-payment.js.map +0 -1
- package/lib/pricing/product-catalog-price.d.ts +0 -1
- package/lib/pricing/product-catalog-price.js +0 -37
- package/lib/pricing/product-catalog-price.js.map +0 -1
- package/lib/pricing/product-discount.d.ts +0 -1
- package/lib/pricing/product-discount.js +0 -55
- package/lib/pricing/product-discount.js.map +0 -1
- package/lib/pricing/product-price-ECB-interbank-exchange.d.ts +0 -1
- package/lib/pricing/product-price-ECB-interbank-exchange.js +0 -90
- package/lib/pricing/product-price-ECB-interbank-exchange.js.map +0 -1
- package/lib/pricing/product-price-coinbase-exchange.d.ts +0 -1
- package/lib/pricing/product-price-coinbase-exchange.js +0 -60
- package/lib/pricing/product-price-coinbase-exchange.js.map +0 -1
- package/lib/pricing/product-price-cryptopay.d.ts +0 -1
- package/lib/pricing/product-price-cryptopay.js +0 -21
- package/lib/pricing/product-price-cryptopay.js.map +0 -1
- package/lib/pricing/product-price-rateconversion.d.ts +0 -1
- package/lib/pricing/product-price-rateconversion.js +0 -51
- package/lib/pricing/product-price-rateconversion.js.map +0 -1
- package/lib/pricing/product-price-round.d.ts +0 -11
- package/lib/pricing/product-price-round.js +0 -54
- package/lib/pricing/product-price-round.js.map +0 -1
- package/lib/pricing/product-swiss-tax.d.ts +0 -13
- package/lib/pricing/product-swiss-tax.js +0 -102
- package/lib/pricing/product-swiss-tax.js.map +0 -1
- package/lib/pricing/utils/cache.d.ts +0 -8
- package/lib/pricing/utils/cache.js +0 -28
- package/lib/pricing/utils/cache.js.map +0 -1
- package/lib/quotations/manual.d.ts +0 -1
- package/lib/quotations/manual.js +0 -21
- package/lib/quotations/manual.js.map +0 -1
- package/lib/warehousing/google-sheets.d.ts +0 -1
- package/lib/warehousing/google-sheets.js +0 -153
- package/lib/warehousing/google-sheets.js.map +0 -1
- package/lib/warehousing/store.d.ts +0 -1
- package/lib/warehousing/store.js +0 -33
- package/lib/warehousing/store.js.map +0 -1
- package/lib/worker/BulkImportWorker.d.ts +0 -2
- package/lib/worker/BulkImportWorker.js +0 -91
- package/lib/worker/BulkImportWorker.js.map +0 -1
- package/lib/worker/GenerateOrderWorker.d.ts +0 -1
- package/lib/worker/GenerateOrderWorker.js +0 -110
- package/lib/worker/GenerateOrderWorker.js.map +0 -1
- package/lib/worker/MessageWorker.js +0 -45
- package/lib/worker/MessageWorker.js.map +0 -1
- package/lib/worker/ZombieKillerWorker.d.ts +0 -7
- package/lib/worker/ZombieKillerWorker.js +0 -88
- package/lib/worker/ZombieKillerWorker.js.map +0 -1
- package/lib/worker/email.d.ts +0 -1
- package/lib/worker/email.js +0 -96
- package/lib/worker/email.js.map +0 -1
- package/lib/worker/external.d.ts +0 -2
- package/lib/worker/external.js +0 -13
- package/lib/worker/external.js.map +0 -1
- package/lib/worker/heartbeat.d.ts +0 -1
- package/lib/worker/heartbeat.js +0 -32
- package/lib/worker/heartbeat.js.map +0 -1
- package/lib/worker/http-request.d.ts +0 -8
- package/lib/worker/http-request.js +0 -61
- package/lib/worker/http-request.js.map +0 -1
- package/lib/worker/sms.d.ts +0 -1
- package/lib/worker/sms.js +0 -69
- package/lib/worker/sms.js.map +0 -1
- package/license +0 -274
- package/src/files/gridfs/gridfs-webhook.js +0 -60
- package/tsconfig.build.json +0 -26
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/plugins",
|
|
3
|
-
"version": "1.1
|
|
4
|
-
"
|
|
5
|
-
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"exports": {
|
|
5
|
+
"./*": "./lib/*"
|
|
6
|
+
},
|
|
6
7
|
"type": "module",
|
|
7
8
|
"scripts": {
|
|
9
|
+
"prepublishOnly": "npm install && npm run build || :",
|
|
8
10
|
"clean": "rm -rf lib",
|
|
9
|
-
"build": "npm run clean && tsc
|
|
10
|
-
"watch": "tsc -
|
|
11
|
+
"build": "npm run clean && tsc",
|
|
12
|
+
"watch": "tsc -w",
|
|
13
|
+
"test": "jest --watch"
|
|
11
14
|
},
|
|
12
15
|
"repository": {
|
|
13
16
|
"type": "git",
|
|
@@ -25,37 +28,40 @@
|
|
|
25
28
|
},
|
|
26
29
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
27
30
|
"devDependencies": {
|
|
28
|
-
"@
|
|
31
|
+
"@types/node": "^16.11.44",
|
|
32
|
+
"@unchainedshop/api": "^1.1.9",
|
|
29
33
|
"@unchainedshop/client-oauth2": "^4.3.3",
|
|
30
|
-
"@unchainedshop/core-delivery": "^1.1.
|
|
31
|
-
"@unchainedshop/core-enrollments": "^1.1.
|
|
32
|
-
"@unchainedshop/core-filters": "^1.1.
|
|
33
|
-
"@unchainedshop/core-messaging": "^1.1.
|
|
34
|
-
"@unchainedshop/core-orders": "^1.1.
|
|
35
|
-
"@unchainedshop/core-payment": "^1.1.
|
|
36
|
-
"@unchainedshop/core-products": "^1.1.
|
|
37
|
-
"@unchainedshop/core-quotations": "^1.1.
|
|
38
|
-
"@unchainedshop/core-warehousing": "^1.1.
|
|
39
|
-
"@unchainedshop/core-worker": "^1.1.
|
|
40
|
-
"@unchainedshop/events": "^1.1.
|
|
41
|
-
"@unchainedshop/file-upload": "^1.1.
|
|
42
|
-
"@unchainedshop/logger": "^1.1.
|
|
43
|
-
"@unchainedshop/types": "^1.1.
|
|
44
|
-
"@unchainedshop/utils": "^1.1.
|
|
45
|
-
"JSONStream": "^1.3.5",
|
|
34
|
+
"@unchainedshop/core-delivery": "^1.1.9",
|
|
35
|
+
"@unchainedshop/core-enrollments": "^1.1.9",
|
|
36
|
+
"@unchainedshop/core-filters": "^1.1.9",
|
|
37
|
+
"@unchainedshop/core-messaging": "^1.1.9",
|
|
38
|
+
"@unchainedshop/core-orders": "^1.1.9",
|
|
39
|
+
"@unchainedshop/core-payment": "^1.1.9",
|
|
40
|
+
"@unchainedshop/core-products": "^1.1.9",
|
|
41
|
+
"@unchainedshop/core-quotations": "^1.1.9",
|
|
42
|
+
"@unchainedshop/core-warehousing": "^1.1.9",
|
|
43
|
+
"@unchainedshop/core-worker": "^1.1.9",
|
|
44
|
+
"@unchainedshop/events": "^1.1.9",
|
|
45
|
+
"@unchainedshop/file-upload": "^1.1.9",
|
|
46
|
+
"@unchainedshop/logger": "^1.1.9",
|
|
47
|
+
"@unchainedshop/types": "^1.1.9",
|
|
48
|
+
"@unchainedshop/utils": "^1.1.9",
|
|
46
49
|
"bluebird": "^3.7.2",
|
|
47
50
|
"body-parser": "^1.20.0",
|
|
48
51
|
"event-iterator": "^2.0.0",
|
|
52
|
+
"jest": "^28.1.2",
|
|
53
|
+
"JSONStream": "^1.3.5",
|
|
49
54
|
"minio": "^7.0.28",
|
|
50
55
|
"moment": "^2.29.3",
|
|
51
56
|
"mongodb": "^4.7.0",
|
|
52
|
-
"node-sheets": "^1.
|
|
57
|
+
"node-sheets": "^1.1.9",
|
|
53
58
|
"nodemailer": "^6.7.5",
|
|
54
59
|
"open": "^8.4.0",
|
|
55
60
|
"redis": "^4.1.0",
|
|
56
61
|
"request": "^2.88.2",
|
|
62
|
+
"ts-jest": "^28.0.5",
|
|
57
63
|
"typescript": "^4.7.4",
|
|
64
|
+
"xml-js": "^1.6.11",
|
|
58
65
|
"xml2js": "0.4.23"
|
|
59
|
-
}
|
|
60
|
-
"gitHead": "06cd41a39f57481555c743836481b9190b2ec2b5"
|
|
66
|
+
}
|
|
61
67
|
}
|
|
@@ -5,7 +5,7 @@ import http, { OutgoingHttpHeaders } from 'http';
|
|
|
5
5
|
import mimeType from 'mime-types';
|
|
6
6
|
import { URL } from 'url';
|
|
7
7
|
import { Readable } from 'stream';
|
|
8
|
-
import buildHashedFilename from '@unchainedshop/file-upload
|
|
8
|
+
import { buildHashedFilename } from '@unchainedshop/file-upload';
|
|
9
9
|
import sign from './sign';
|
|
10
10
|
import promisePipe from './promisePipe';
|
|
11
11
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useMiddlewareWithCurrentContext } from '@unchainedshop/api';
|
|
2
|
+
import { log, LogLevel } from '@unchainedshop/logger';
|
|
3
|
+
import { buildHashedFilename } from '@unchainedshop/file-upload';
|
|
4
|
+
import sign from './sign';
|
|
5
|
+
import promisePipe from './promisePipe';
|
|
6
|
+
|
|
7
|
+
const { ROOT_URL } = process.env;
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
curl -vvv -X PUT -T /Users/pozylon/Downloads/grafik.png http://localhost:4010/gridfs/user-avatars/hans.png?e=1653059591506&s=df8626a1c9b9006249d7f1928fd530579fed57216f1bdcb83c28a8322cdc90b1
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export default (app) =>
|
|
14
|
+
useMiddlewareWithCurrentContext(app, '/gridfs', async (req, res) => {
|
|
15
|
+
try {
|
|
16
|
+
const { services, modules } = req.unchainedContext;
|
|
17
|
+
const url = new URL(req.url, ROOT_URL);
|
|
18
|
+
const [, directoryName, fileName] = url.pathname.split('/');
|
|
19
|
+
|
|
20
|
+
if (req.method === 'PUT') {
|
|
21
|
+
const { s: signature, e: expiryTimestamp } = req.query;
|
|
22
|
+
const expiryDate = new Date(parseInt(expiryTimestamp, 10));
|
|
23
|
+
const fileId = buildHashedFilename(directoryName, fileName, expiryDate);
|
|
24
|
+
if (sign(directoryName, fileId, expiryDate.getTime()) === signature) {
|
|
25
|
+
const file = await modules.files.findFile({ fileId });
|
|
26
|
+
if (file.expires === null) {
|
|
27
|
+
res.writeHead(503);
|
|
28
|
+
res.end('File already linked');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const writeStream = await modules.gridfsFileUploads.createWriteStream(
|
|
32
|
+
directoryName,
|
|
33
|
+
fileId,
|
|
34
|
+
fileName,
|
|
35
|
+
);
|
|
36
|
+
res.writeHead(200);
|
|
37
|
+
const { length } = await promisePipe(req, writeStream);
|
|
38
|
+
await services.files.linkFile({ fileId, size: length }, req.unchainedContext);
|
|
39
|
+
res.end();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
res.writeHead(403);
|
|
43
|
+
res.end();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (req.method === 'GET') {
|
|
47
|
+
const fileId = fileName;
|
|
48
|
+
const readStream = await modules.gridfsFileUploads.createReadStream(directoryName, fileId);
|
|
49
|
+
res.writeHead(200);
|
|
50
|
+
await promisePipe(readStream, res);
|
|
51
|
+
res.end();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
res.writeHead(404);
|
|
55
|
+
res.end();
|
|
56
|
+
return;
|
|
57
|
+
} catch (e) {
|
|
58
|
+
log(e.message, { level: LogLevel.Error });
|
|
59
|
+
res.writeHead(503);
|
|
60
|
+
res.end(JSON.stringify(e));
|
|
61
|
+
}
|
|
62
|
+
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IFileAdapter } from '@unchainedshop/types/files';
|
|
2
|
-
import { FileAdapter, FileDirector } from '@unchainedshop/file-upload';
|
|
2
|
+
import { FileAdapter, FileDirector, buildHashedFilename } from '@unchainedshop/file-upload';
|
|
3
3
|
|
|
4
4
|
import https from 'https';
|
|
5
5
|
import http, { OutgoingHttpHeaders } from 'http';
|
|
@@ -8,7 +8,6 @@ import mimeType from 'mime-types';
|
|
|
8
8
|
import Minio from 'minio';
|
|
9
9
|
import { Readable } from 'stream';
|
|
10
10
|
import { URL } from 'url';
|
|
11
|
-
import buildHashedFilename from '@unchainedshop/file-upload/lib/buildHashedFilename';
|
|
12
11
|
|
|
13
12
|
const {
|
|
14
13
|
MINIO_ACCESS_KEY,
|
|
@@ -9,39 +9,42 @@ const isAuthorized = ({ authorization = '' }) => {
|
|
|
9
9
|
return type === 'Bearer' && token === MINIO_WEBHOOK_AUTH_TOKEN;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
export default (app) => {
|
|
13
|
+
useMiddlewareWithCurrentContext(
|
|
14
|
+
app,
|
|
15
|
+
'/minio/',
|
|
16
|
+
bodyParser.json({
|
|
17
|
+
strict: false,
|
|
18
|
+
}),
|
|
19
|
+
);
|
|
18
20
|
|
|
19
|
-
useMiddlewareWithCurrentContext('/minio/', async (req, res) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
useMiddlewareWithCurrentContext(app, '/minio/', async (req, res) => {
|
|
22
|
+
try {
|
|
23
|
+
if (req.method === 'POST' && req.body) {
|
|
24
|
+
const { headers } = req;
|
|
25
|
+
const { Records = [], EventName } = req.body;
|
|
26
|
+
if (EventName === 's3:ObjectCreated:Put' && isAuthorized(headers)) {
|
|
27
|
+
const [{ s3 }] = Records;
|
|
28
|
+
const { object } = s3;
|
|
29
|
+
const { size, contentType: type } = object;
|
|
30
|
+
const [fileId] = object.key.split('.');
|
|
31
|
+
const { services } = req.unchainedContext;
|
|
32
|
+
await services.files.linkFile({ fileId, type, size }, req.unchainedContext);
|
|
33
|
+
res.writeHead(200);
|
|
34
|
+
res.end();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
34
37
|
}
|
|
38
|
+
res.writeHead(404);
|
|
39
|
+
res.end();
|
|
40
|
+
return;
|
|
41
|
+
} catch (e) {
|
|
42
|
+
log(e.message, { level: LogLevel.Error });
|
|
43
|
+
res.writeHead(503);
|
|
44
|
+
res.end(JSON.stringify(e));
|
|
35
45
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return;
|
|
39
|
-
} catch (e) {
|
|
40
|
-
log(e.message, { level: LogLevel.Error });
|
|
41
|
-
res.writeHead(503);
|
|
42
|
-
res.end(JSON.stringify(e));
|
|
43
|
-
}
|
|
44
|
-
});
|
|
46
|
+
});
|
|
47
|
+
};
|
|
45
48
|
|
|
46
49
|
/*
|
|
47
50
|
|
|
@@ -13,7 +13,7 @@ const logger = createLogger('unchained:core-payment:iap');
|
|
|
13
13
|
const {
|
|
14
14
|
APPLE_IAP_SHARED_SECRET,
|
|
15
15
|
APPLE_IAP_ENVIRONMENT = 'sandbox',
|
|
16
|
-
APPLE_IAP_WEBHOOK_PATH = '/
|
|
16
|
+
APPLE_IAP_WEBHOOK_PATH = '/payment/apple-iap',
|
|
17
17
|
} = process.env;
|
|
18
18
|
|
|
19
19
|
// https://developer.apple.com/documentation/storekit/in-app_purchase/validating_receipts_with_the_app_store
|
|
@@ -88,44 +88,89 @@ const fixPeriods = async (
|
|
|
88
88
|
);
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (req.method === 'POST') {
|
|
100
|
-
try {
|
|
101
|
-
const resolvedContext = req.unchainedContext as Context;
|
|
102
|
-
const { modules, services } = resolvedContext;
|
|
103
|
-
const responseBody = req.body || {};
|
|
104
|
-
if (responseBody.password !== APPLE_IAP_SHARED_SECRET) {
|
|
105
|
-
throw new Error('shared secret not valid');
|
|
106
|
-
}
|
|
91
|
+
export default (app) => {
|
|
92
|
+
useMiddlewareWithCurrentContext(
|
|
93
|
+
app,
|
|
94
|
+
APPLE_IAP_WEBHOOK_PATH,
|
|
95
|
+
bodyParser.json({
|
|
96
|
+
strict: false,
|
|
97
|
+
}),
|
|
98
|
+
);
|
|
107
99
|
|
|
108
|
-
|
|
109
|
-
|
|
100
|
+
useMiddlewareWithCurrentContext(app, APPLE_IAP_WEBHOOK_PATH, async (req, res) => {
|
|
101
|
+
if (req.method === 'POST') {
|
|
102
|
+
try {
|
|
103
|
+
const resolvedContext = req.unchainedContext as Context;
|
|
104
|
+
const { modules, services } = resolvedContext;
|
|
105
|
+
const responseBody = req.body || {};
|
|
106
|
+
if (responseBody.password !== APPLE_IAP_SHARED_SECRET) {
|
|
107
|
+
throw new Error('shared secret not valid');
|
|
108
|
+
}
|
|
110
109
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const orderPayment = await modules.orders.payments.findOrderPaymentByContextData({
|
|
114
|
-
context: {
|
|
115
|
-
'meta.transactionIdentifier': latestTransaction.transaction_id,
|
|
116
|
-
},
|
|
117
|
-
});
|
|
110
|
+
const transactions = responseBody?.unified_receipt?.latest_receipt_info; // eslint-disable-line
|
|
111
|
+
const latestTransaction = transactions[0];
|
|
118
112
|
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
if (responseBody.notification_type === AppleNotificationTypes.INITIAL_BUY) {
|
|
114
|
+
// Find the cart to checkout
|
|
115
|
+
const orderPayment = await modules.orders.payments.findOrderPaymentByContextData({
|
|
116
|
+
context: {
|
|
117
|
+
'meta.transactionIdentifier': latestTransaction.transaction_id,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
if (!orderPayment) throw new Error('Could not find any matching order payment');
|
|
122
|
+
const order = await modules.orders.findOrder({
|
|
123
|
+
orderId: orderPayment.orderId,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
if (modules.orders.isCart(order)) {
|
|
127
|
+
// checkout if is cart, else just ignore because the cart is already checked out
|
|
128
|
+
// through submission of the receipt with GraphQL
|
|
129
|
+
const checkedOut = await modules.orders.checkout(
|
|
130
|
+
order._id,
|
|
131
|
+
{
|
|
132
|
+
paymentContext: {
|
|
133
|
+
receiptData: responseBody?.unified_receipt?.latest_receipt, // eslint-disable-line
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
resolvedContext,
|
|
137
|
+
);
|
|
138
|
+
const orderId = checkedOut._id;
|
|
139
|
+
const enrollment = await modules.enrollments.findEnrollment({
|
|
140
|
+
orderId,
|
|
141
|
+
});
|
|
142
|
+
await fixPeriods(
|
|
143
|
+
{
|
|
144
|
+
transactionId: latestTransaction.original_transaction_id,
|
|
145
|
+
transactions,
|
|
146
|
+
enrollmentId: enrollment._id,
|
|
147
|
+
orderId,
|
|
148
|
+
},
|
|
149
|
+
resolvedContext,
|
|
150
|
+
);
|
|
123
151
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
152
|
+
logger.info(`Apple IAP Webhook: Confirmed checkout for order ${checkedOut.orderNumber}`, {
|
|
153
|
+
orderId: checkedOut._id,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
// Just store payment credentials, use the enrollments paymentProvider reference and
|
|
158
|
+
// let the job do the rest
|
|
159
|
+
const originalOrderPayment = await modules.orders.payments.findOrderPaymentByContextData({
|
|
160
|
+
context: {
|
|
161
|
+
'meta.transactionIdentifier': latestTransaction.original_transaction_id,
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
if (!originalOrderPayment) throw new Error('Could not find any matching order payment');
|
|
165
|
+
const originalOrder = await modules.orders.findOrder({
|
|
166
|
+
orderId: originalOrderPayment.orderId,
|
|
167
|
+
});
|
|
168
|
+
const enrollment = await modules.enrollments.findEnrollment({
|
|
169
|
+
orderId: originalOrder._id,
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
await services.payment.registerPaymentCredentials(
|
|
173
|
+
enrollment.payment.paymentProviderId,
|
|
129
174
|
{
|
|
130
175
|
transactionContext: {
|
|
131
176
|
receiptData: responseBody?.unified_receipt?.latest_receipt, // eslint-disable-line
|
|
@@ -133,97 +178,55 @@ useMiddlewareWithCurrentContext(APPLE_IAP_WEBHOOK_PATH, async (req, res) => {
|
|
|
133
178
|
},
|
|
134
179
|
resolvedContext,
|
|
135
180
|
);
|
|
136
|
-
|
|
137
|
-
const enrollment = await modules.enrollments.findEnrollment({
|
|
138
|
-
orderId,
|
|
139
|
-
});
|
|
181
|
+
|
|
140
182
|
await fixPeriods(
|
|
141
183
|
{
|
|
142
184
|
transactionId: latestTransaction.original_transaction_id,
|
|
143
185
|
transactions,
|
|
144
186
|
enrollmentId: enrollment._id,
|
|
145
|
-
orderId,
|
|
187
|
+
orderId: originalOrder._id,
|
|
146
188
|
},
|
|
147
189
|
resolvedContext,
|
|
148
190
|
);
|
|
149
191
|
|
|
150
|
-
logger.info(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
// Just store payment credentials, use the enrollments paymentProvider reference and
|
|
156
|
-
// let the job do the rest
|
|
157
|
-
const originalOrderPayment = await modules.orders.payments.findOrderPaymentByContextData({
|
|
158
|
-
context: {
|
|
159
|
-
'meta.transactionIdentifier': latestTransaction.original_transaction_id,
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
if (!originalOrderPayment) throw new Error('Could not find any matching order payment');
|
|
163
|
-
const originalOrder = await modules.orders.findOrder({
|
|
164
|
-
orderId: originalOrderPayment.orderId,
|
|
165
|
-
});
|
|
166
|
-
const enrollment = await modules.enrollments.findEnrollment({
|
|
167
|
-
orderId: originalOrder._id,
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
await services.payment.registerPaymentCredentials(
|
|
171
|
-
enrollment.payment.paymentProviderId,
|
|
172
|
-
{
|
|
173
|
-
transactionContext: {
|
|
174
|
-
receiptData: responseBody?.unified_receipt?.latest_receipt, // eslint-disable-line
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
resolvedContext,
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
await fixPeriods(
|
|
181
|
-
{
|
|
182
|
-
transactionId: latestTransaction.original_transaction_id,
|
|
183
|
-
transactions,
|
|
184
|
-
enrollmentId: enrollment._id,
|
|
185
|
-
orderId: originalOrder._id,
|
|
186
|
-
},
|
|
187
|
-
resolvedContext,
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
logger.info(
|
|
191
|
-
`Apple IAP Webhook: Processed notification for ${latestTransaction.original_transaction_id} and type ${responseBody.notification_type}`,
|
|
192
|
-
);
|
|
192
|
+
logger.info(
|
|
193
|
+
`Apple IAP Webhook: Processed notification for ${latestTransaction.original_transaction_id} and type ${responseBody.notification_type}`,
|
|
194
|
+
);
|
|
193
195
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
if (responseBody.notification_type === AppleNotificationTypes.DID_RECOVER) {
|
|
197
|
+
if (
|
|
198
|
+
enrollment.status !== EnrollmentStatus.TERMINATED &&
|
|
199
|
+
responseBody.auto_renew_status === 'false'
|
|
200
|
+
) {
|
|
201
|
+
await modules.enrollments.terminateEnrollment(enrollment, {}, resolvedContext);
|
|
202
|
+
}
|
|
200
203
|
}
|
|
201
|
-
}
|
|
202
204
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
205
|
+
if (responseBody.notification_type === AppleNotificationTypes.DID_CHANGE_RENEWAL_STATUS) {
|
|
206
|
+
if (
|
|
207
|
+
enrollment.status !== EnrollmentStatus.TERMINATED &&
|
|
208
|
+
responseBody.auto_renew_status === 'false'
|
|
209
|
+
) {
|
|
210
|
+
await modules.enrollments.terminateEnrollment(enrollment, {}, resolvedContext);
|
|
211
|
+
}
|
|
209
212
|
}
|
|
213
|
+
logger.info(`Apple IAP Webhook: Updated enrollment from Apple`);
|
|
210
214
|
}
|
|
211
|
-
logger.info(`Apple IAP Webhook: Updated enrollment from Apple`);
|
|
212
|
-
}
|
|
213
215
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
216
|
+
res.writeHead(200);
|
|
217
|
+
res.end();
|
|
218
|
+
return;
|
|
219
|
+
} catch (e) {
|
|
220
|
+
logger.warn(`Apple IAP Webhook: ${e.message}`, e);
|
|
221
|
+
res.writeHead(503);
|
|
222
|
+
res.end(JSON.stringify(e));
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
222
225
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
226
|
+
res.writeHead(404);
|
|
227
|
+
res.end();
|
|
228
|
+
});
|
|
229
|
+
};
|
|
227
230
|
|
|
228
231
|
const AppleIAP: IPaymentAdapter = {
|
|
229
232
|
...PaymentAdapter,
|
|
@@ -29,10 +29,10 @@ const {
|
|
|
29
29
|
BITY_BANK_ACCOUNT_NAME,
|
|
30
30
|
BITY_BANK_ACCOUNT_ZIP,
|
|
31
31
|
BITY_API_ENDPOINT = 'https://exchange.api.bity.com',
|
|
32
|
-
BITY_OAUTH_INIT_PATH = '/
|
|
33
|
-
BITY_OAUTH_REDIRECT_URI = 'http://localhost:4010/
|
|
32
|
+
BITY_OAUTH_INIT_PATH = '/payment/bity-auth',
|
|
33
|
+
BITY_OAUTH_REDIRECT_URI = 'http://localhost:4010/payment/bity',
|
|
34
34
|
BITY_OAUTH_STATE = 'unchained',
|
|
35
|
-
BITY_OAUTH_PATH = '/
|
|
35
|
+
BITY_OAUTH_PATH = '/payment/bity',
|
|
36
36
|
} = process.env;
|
|
37
37
|
|
|
38
38
|
const createBityAuth = () => {
|
|
@@ -185,56 +185,58 @@ const estimateBityOrder = async (data: any, context: Context) => {
|
|
|
185
185
|
return response.json();
|
|
186
186
|
};
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
188
|
+
export default (app) => {
|
|
189
|
+
useMiddlewareWithCurrentContext(app, BITY_OAUTH_INIT_PATH, async (req, res) => {
|
|
190
|
+
if (req.method === 'GET') {
|
|
191
|
+
try {
|
|
192
|
+
const resolvedContext = req.unchainedContext;
|
|
193
|
+
await checkAction(resolvedContext, actions.managePaymentProviders);
|
|
194
|
+
|
|
195
|
+
const bityAuthClient = createBityAuth();
|
|
196
|
+
const uri = bityAuthClient.code.getUri();
|
|
197
|
+
logger.info(`Bity Webhook: Login ${uri}`);
|
|
198
|
+
res.writeHead(302, {
|
|
199
|
+
Location: uri,
|
|
200
|
+
});
|
|
201
|
+
res.end();
|
|
202
|
+
return;
|
|
203
|
+
} catch (e) {
|
|
204
|
+
logger.warn(`Bity Webhook: Failed with ${e.message}`);
|
|
205
|
+
res.writeHead(503);
|
|
206
|
+
res.end(JSON.stringify(e));
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
207
209
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
210
|
+
res.writeHead(404);
|
|
211
|
+
res.end();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
useMiddlewareWithCurrentContext(app, BITY_OAUTH_PATH, async (req, res, next) => {
|
|
215
|
+
bodyParser.urlencoded({ extended: false })(req, res, next);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
useMiddlewareWithCurrentContext(app, BITY_OAUTH_PATH, async (req, res) => {
|
|
219
|
+
if (req.method === 'GET') {
|
|
220
|
+
try {
|
|
221
|
+
const resolvedContext = req.unchainedContext as Context;
|
|
222
|
+
await checkAction(resolvedContext, actions.managePaymentProviders);
|
|
223
|
+
const bityAuthClient = createBityAuth();
|
|
224
|
+
const user = await bityAuthClient.code.getToken(req.originalUrl);
|
|
225
|
+
await upsertBityCredentials(user, resolvedContext);
|
|
226
|
+
res.writeHead(200);
|
|
227
|
+
res.end('Bity Credentials Setup Complete');
|
|
228
|
+
return;
|
|
229
|
+
} catch (e) {
|
|
230
|
+
logger.warn(`Bity Webhook: Failed with ${e.message}`);
|
|
231
|
+
res.writeHead(503);
|
|
232
|
+
res.end(JSON.stringify(e));
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
233
235
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
236
|
+
res.writeHead(404);
|
|
237
|
+
res.end();
|
|
238
|
+
});
|
|
239
|
+
};
|
|
238
240
|
|
|
239
241
|
let bityAuthClient;
|
|
240
242
|
const loadToken = async (context: Context) => {
|