@unchainedshop/plugins 4.6.1 → 4.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/lib/delivery/post/adapter.d.ts +2 -0
- package/lib/delivery/{post.js → post/adapter.js} +2 -3
- package/lib/delivery/post/index.d.ts +4 -0
- package/lib/delivery/post/index.js +10 -0
- package/lib/delivery/send-message/adapter.d.ts +2 -0
- package/lib/delivery/{send-message.js → send-message/adapter.js} +2 -3
- package/lib/delivery/send-message/index.d.ts +4 -0
- package/lib/delivery/send-message/index.js +10 -0
- package/lib/delivery/stores/adapter.d.ts +2 -0
- package/lib/delivery/{stores.js → stores/adapter.js} +2 -3
- package/lib/delivery/stores/index.d.ts +4 -0
- package/lib/delivery/stores/index.js +10 -0
- package/lib/enrollments/licensed/adapter.d.ts +6 -0
- package/lib/enrollments/{licensed.js → licensed/adapter.js} +2 -3
- package/lib/enrollments/licensed/index.d.ts +4 -0
- package/lib/enrollments/licensed/index.js +10 -0
- package/lib/events/node-event-emitter.d.ts +3 -1
- package/lib/events/node-event-emitter.js +3 -3
- package/lib/files/gridfs/adapter.d.ts +2 -2
- package/lib/files/gridfs/adapter.js +2 -5
- package/lib/files/gridfs/api.d.ts +7 -0
- package/lib/files/gridfs/api.js +163 -0
- package/lib/files/gridfs/index.d.ts +5 -4
- package/lib/files/gridfs/index.js +30 -3
- package/lib/files/minio/adapter.d.ts +4 -0
- package/lib/files/minio/adapter.js +160 -0
- package/lib/files/minio/api.d.ts +2 -0
- package/lib/files/minio/api.js +41 -0
- package/lib/files/minio/index.d.ts +4 -5
- package/lib/files/minio/index.js +18 -157
- package/lib/files/temp-upload/api.d.ts +6 -0
- package/lib/files/temp-upload/api.js +49 -0
- package/lib/files/temp-upload/index.d.ts +3 -0
- package/lib/files/temp-upload/index.js +15 -0
- package/lib/filters/local-search/adapter.d.ts +2 -0
- package/lib/filters/{local-search.js → local-search/adapter.js} +2 -12
- package/lib/filters/local-search/index.d.ts +4 -0
- package/lib/filters/local-search/index.js +16 -0
- package/lib/filters/strict-equal/adapter.d.ts +2 -0
- package/lib/filters/{strict-equal.js → strict-equal/adapter.js} +2 -3
- package/lib/filters/strict-equal/index.d.ts +4 -0
- package/lib/filters/strict-equal/index.js +10 -0
- package/lib/payment/apple-iap/adapter.d.ts +2 -1
- package/lib/payment/apple-iap/adapter.js +2 -3
- package/lib/payment/apple-iap/api.d.ts +2 -0
- package/lib/payment/apple-iap/{handler-fastify.js → api.js} +47 -30
- package/lib/payment/apple-iap/index.d.ts +6 -4
- package/lib/payment/apple-iap/index.js +28 -3
- package/lib/payment/cryptopay/adapter.d.ts +2 -0
- package/lib/payment/cryptopay/{plugin.js → adapter.js} +2 -4
- package/lib/payment/cryptopay/api.d.ts +2 -0
- package/lib/payment/cryptopay/api.js +23 -0
- package/lib/payment/cryptopay/index.d.ts +5 -4
- package/lib/payment/cryptopay/index.js +31 -3
- package/lib/payment/datatrans-v2/adapter.d.ts +2 -0
- package/lib/payment/datatrans-v2/adapter.js +406 -0
- package/lib/payment/datatrans-v2/api.d.ts +2 -0
- package/lib/payment/datatrans-v2/api.js +108 -0
- package/lib/payment/datatrans-v2/index.d.ts +4 -1
- package/lib/payment/datatrans-v2/index.js +17 -400
- package/lib/payment/invoice/adapter.d.ts +2 -0
- package/lib/payment/{invoice.js → invoice/adapter.js} +2 -3
- package/lib/payment/invoice/index.d.ts +4 -0
- package/lib/payment/invoice/index.js +10 -0
- package/lib/payment/invoice-prepaid/adapter.d.ts +2 -0
- package/lib/payment/{invoice-prepaid.js → invoice-prepaid/adapter.js} +2 -3
- package/lib/payment/invoice-prepaid/index.d.ts +4 -0
- package/lib/payment/invoice-prepaid/index.js +10 -0
- package/lib/payment/payrexx/adapter.d.ts +2 -0
- package/lib/payment/payrexx/adapter.js +161 -0
- package/lib/payment/payrexx/api.d.ts +2 -0
- package/lib/payment/payrexx/api.js +97 -0
- package/lib/payment/payrexx/index.d.ts +4 -1
- package/lib/payment/payrexx/index.js +19 -158
- package/lib/payment/postfinance-checkout/adapter.d.ts +2 -0
- package/lib/payment/postfinance-checkout/adapter.js +189 -0
- package/lib/payment/postfinance-checkout/index.d.ts +5 -0
- package/lib/payment/postfinance-checkout/index.js +25 -186
- package/lib/payment/postfinance-checkout/webhook.d.ts +2 -0
- package/lib/payment/postfinance-checkout/webhook.js +48 -0
- package/lib/payment/saferpay/adapter.js +1 -2
- package/lib/payment/saferpay/index.d.ts +5 -4
- package/lib/payment/saferpay/index.js +29 -3
- package/lib/payment/saferpay/webhook.d.ts +2 -0
- package/lib/payment/saferpay/webhook.js +64 -0
- package/lib/payment/stripe/adapter.d.ts +2 -0
- package/lib/payment/stripe/adapter.js +121 -0
- package/lib/payment/stripe/api.d.ts +6 -0
- package/lib/payment/stripe/api.js +165 -0
- package/lib/payment/stripe/index.d.ts +4 -1
- package/lib/payment/stripe/index.js +22 -116
- package/lib/payment/stripe/stripe.js +2 -5
- package/lib/presets/all.d.ts +1 -70
- package/lib/presets/all.js +41 -27
- package/lib/presets/base.d.ts +1 -25
- package/lib/presets/base.js +56 -25
- package/lib/presets/countries/ch.d.ts +1 -2
- package/lib/presets/countries/ch.js +7 -2
- package/lib/presets/crypto.d.ts +3 -7
- package/lib/presets/crypto.js +18 -7
- package/lib/pricing/{delivery-swiss-tax.d.ts → delivery-swiss-tax/adapter.d.ts} +1 -0
- package/lib/pricing/{delivery-swiss-tax.js → delivery-swiss-tax/adapter.js} +4 -4
- package/lib/pricing/delivery-swiss-tax/index.d.ts +4 -0
- package/lib/pricing/delivery-swiss-tax/index.js +10 -0
- package/lib/pricing/{discount-100-off.d.ts → discount-100-off/adapter.d.ts} +1 -0
- package/lib/pricing/{discount-100-off.js → discount-100-off/adapter.js} +2 -2
- package/lib/pricing/discount-100-off/index.d.ts +4 -0
- package/lib/pricing/discount-100-off/index.js +10 -0
- package/lib/pricing/{discount-half-price-manual.d.ts → discount-half-price-manual/adapter.d.ts} +1 -0
- package/lib/pricing/{discount-half-price-manual.js → discount-half-price-manual/adapter.js} +2 -2
- package/lib/pricing/discount-half-price-manual/index.d.ts +4 -0
- package/lib/pricing/discount-half-price-manual/index.js +10 -0
- package/lib/pricing/{free-delivery.d.ts → free-delivery/adapter.d.ts} +1 -0
- package/lib/pricing/{free-delivery.js → free-delivery/adapter.js} +2 -2
- package/lib/pricing/free-delivery/index.d.ts +4 -0
- package/lib/pricing/free-delivery/index.js +10 -0
- package/lib/pricing/{free-payment.d.ts → free-payment/adapter.d.ts} +1 -0
- package/lib/pricing/{free-payment.js → free-payment/adapter.js} +2 -2
- package/lib/pricing/free-payment/index.d.ts +4 -0
- package/lib/pricing/free-payment/index.js +10 -0
- package/lib/pricing/{order-delivery.d.ts → order-delivery/adapter.d.ts} +1 -0
- package/lib/pricing/{order-delivery.js → order-delivery/adapter.js} +2 -2
- package/lib/pricing/order-delivery/index.d.ts +4 -0
- package/lib/pricing/order-delivery/index.js +10 -0
- package/lib/pricing/{order-discount.d.ts → order-discount/adapter.d.ts} +1 -0
- package/lib/pricing/{order-discount.js → order-discount/adapter.js} +2 -2
- package/lib/pricing/order-discount/index.d.ts +4 -0
- package/lib/pricing/order-discount/index.js +10 -0
- package/lib/pricing/{order-items.d.ts → order-items/adapter.d.ts} +1 -0
- package/lib/pricing/{order-items.js → order-items/adapter.js} +2 -2
- package/lib/pricing/order-items/index.d.ts +4 -0
- package/lib/pricing/order-items/index.js +10 -0
- package/lib/pricing/{order-payment.d.ts → order-payment/adapter.d.ts} +1 -0
- package/lib/pricing/{order-payment.js → order-payment/adapter.js} +2 -2
- package/lib/pricing/order-payment/index.d.ts +4 -0
- package/lib/pricing/order-payment/index.js +10 -0
- package/lib/pricing/{product-catalog-price.d.ts → product-catalog-price/adapter.d.ts} +1 -0
- package/lib/pricing/{product-catalog-price.js → product-catalog-price/adapter.js} +2 -2
- package/lib/pricing/product-catalog-price/index.d.ts +4 -0
- package/lib/pricing/product-catalog-price/index.js +10 -0
- package/lib/pricing/{product-discount.d.ts → product-discount/adapter.d.ts} +1 -0
- package/lib/pricing/{product-discount.js → product-discount/adapter.js} +2 -2
- package/lib/pricing/product-discount/index.d.ts +4 -0
- package/lib/pricing/product-discount/index.js +10 -0
- package/lib/pricing/{product-price-rateconversion.d.ts → product-price-rateconversion/adapter.d.ts} +1 -0
- package/lib/pricing/{product-price-rateconversion.js → product-price-rateconversion/adapter.js} +2 -2
- package/lib/pricing/product-price-rateconversion/index.d.ts +4 -0
- package/lib/pricing/product-price-rateconversion/index.js +10 -0
- package/lib/pricing/{product-swiss-tax.d.ts → product-swiss-tax/adapter.d.ts} +1 -0
- package/lib/pricing/{product-swiss-tax.js → product-swiss-tax/adapter.js} +4 -4
- package/lib/pricing/product-swiss-tax/index.d.ts +4 -0
- package/lib/pricing/product-swiss-tax/index.js +10 -0
- package/lib/quotations/manual/adapter.d.ts +2 -0
- package/lib/quotations/{manual.js → manual/adapter.js} +2 -3
- package/lib/quotations/manual/index.d.ts +4 -0
- package/lib/quotations/manual/index.js +10 -0
- package/lib/warehousing/erc-metadata/api.d.ts +12 -0
- package/lib/warehousing/erc-metadata/api.js +43 -0
- package/lib/warehousing/erc-metadata/index.d.ts +3 -0
- package/lib/warehousing/erc-metadata/index.js +15 -0
- package/lib/warehousing/eth-minter/adapter.d.ts +2 -0
- package/lib/warehousing/{eth-minter.js → eth-minter/adapter.js} +3 -4
- package/lib/warehousing/eth-minter/index.d.ts +4 -0
- package/lib/warehousing/eth-minter/index.js +10 -0
- package/lib/warehousing/store/adapter.d.ts +2 -0
- package/lib/warehousing/{store.js → store/adapter.js} +2 -3
- package/lib/warehousing/store/index.d.ts +4 -0
- package/lib/warehousing/store/index.js +10 -0
- package/lib/worker/budgetsms/adapter.d.ts +22 -0
- package/lib/worker/{budgetsms.js → budgetsms/adapter.js} +3 -3
- package/lib/worker/budgetsms/index.d.ts +4 -0
- package/lib/worker/budgetsms/index.js +10 -0
- package/lib/worker/bulk-export/adapter.d.ts +3 -0
- package/lib/worker/{bulk-export.js → bulk-export/adapter.js} +3 -3
- package/lib/worker/bulk-export/index.d.ts +4 -0
- package/lib/worker/bulk-export/index.js +10 -0
- package/lib/worker/{bulk-import.d.ts → bulk-import/adapter.d.ts} +1 -0
- package/lib/worker/{bulk-import.js → bulk-import/adapter.js} +2 -2
- package/lib/worker/bulk-import/api.d.ts +7 -0
- package/lib/worker/bulk-import/api.js +53 -0
- package/lib/worker/bulk-import/index.d.ts +4 -0
- package/lib/worker/bulk-import/index.js +18 -0
- package/lib/worker/bulkgate/adapter.d.ts +12 -0
- package/lib/worker/{bulkgate.js → bulkgate/adapter.js} +3 -3
- package/lib/worker/bulkgate/index.d.ts +4 -0
- package/lib/worker/bulkgate/index.js +10 -0
- package/lib/worker/email/adapter.d.ts +9 -0
- package/lib/worker/{email.js → email/adapter.js} +27 -13
- package/lib/worker/email/index.d.ts +4 -0
- package/lib/worker/email/index.js +10 -0
- package/lib/worker/enrollment-order-generator/adapter.d.ts +4 -0
- package/lib/worker/{enrollment-order-generator.js → enrollment-order-generator/adapter.js} +2 -2
- package/lib/worker/enrollment-order-generator/index.d.ts +4 -0
- package/lib/worker/enrollment-order-generator/index.js +13 -0
- package/lib/worker/{error-notifications.d.ts → error-notifications/adapter.d.ts} +1 -0
- package/lib/worker/{error-notifications.js → error-notifications/adapter.js} +9 -8
- package/lib/worker/error-notifications/index.d.ts +4 -0
- package/lib/worker/error-notifications/index.js +13 -0
- package/lib/worker/{export-token.d.ts → export-token/adapter.d.ts} +1 -1
- package/lib/worker/{export-token.js → export-token/adapter.js} +2 -3
- package/lib/worker/export-token/index.d.ts +4 -0
- package/lib/worker/export-token/index.js +13 -0
- package/lib/worker/{external.d.ts → external/adapter.d.ts} +1 -0
- package/lib/worker/{external.js → external/adapter.js} +2 -2
- package/lib/worker/external/index.d.ts +4 -0
- package/lib/worker/external/index.js +10 -0
- package/lib/worker/heartbeat/adapter.d.ts +8 -0
- package/lib/worker/{heartbeat.js → heartbeat/adapter.js} +3 -3
- package/lib/worker/heartbeat/index.d.ts +4 -0
- package/lib/worker/heartbeat/index.js +10 -0
- package/lib/worker/{http-request.d.ts → http-request/adapter.d.ts} +1 -1
- package/lib/worker/{http-request.js → http-request/adapter.js} +2 -3
- package/lib/worker/http-request/index.d.ts +4 -0
- package/lib/worker/http-request/index.js +10 -0
- package/lib/worker/{message.d.ts → message/adapter.d.ts} +1 -0
- package/lib/worker/{message.js → message/adapter.js} +2 -2
- package/lib/worker/message/index.d.ts +4 -0
- package/lib/worker/message/index.js +10 -0
- package/lib/worker/push-notification/adapter.d.ts +9 -0
- package/lib/worker/{push-notification.js → push-notification/adapter.js} +3 -3
- package/lib/worker/push-notification/index.d.ts +4 -0
- package/lib/worker/push-notification/index.js +10 -0
- package/lib/worker/twilio/adapter.d.ts +8 -0
- package/lib/worker/{twilio.js → twilio/adapter.js} +3 -3
- package/lib/worker/twilio/index.d.ts +4 -0
- package/lib/worker/twilio/index.js +10 -0
- package/lib/worker/update-coinbase-rates/adapter.d.ts +4 -0
- package/lib/worker/{update-coinbase-rates.js → update-coinbase-rates/adapter.js} +8 -6
- package/lib/worker/update-coinbase-rates/index.d.ts +4 -0
- package/lib/worker/update-coinbase-rates/index.js +13 -0
- package/lib/worker/update-ecb-rates/adapter.d.ts +4 -0
- package/lib/worker/{update-ecb-rates.js → update-ecb-rates/adapter.js} +11 -9
- package/lib/worker/update-ecb-rates/index.d.ts +4 -0
- package/lib/worker/update-ecb-rates/index.js +13 -0
- package/lib/worker/{update-token-ownership.d.ts → update-token-ownership/adapter.d.ts} +2 -0
- package/lib/worker/{update-token-ownership.js → update-token-ownership/adapter.js} +8 -7
- package/lib/worker/update-token-ownership/index.d.ts +4 -0
- package/lib/worker/update-token-ownership/index.js +13 -0
- package/lib/worker/{zombie-killer.js → zombie-killer/adapter.js} +1 -2
- package/lib/worker/zombie-killer/index.d.ts +4 -0
- package/lib/worker/zombie-killer/index.js +10 -0
- package/package.json +15 -10
- package/lib/delivery/post.d.ts +0 -1
- package/lib/delivery/send-message.d.ts +0 -1
- package/lib/delivery/stores.d.ts +0 -1
- package/lib/enrollments/licensed.d.ts +0 -4
- package/lib/files/gridfs/handler-express.d.ts +0 -9
- package/lib/files/gridfs/handler-express.js +0 -110
- package/lib/files/gridfs/handler-fastify.d.ts +0 -3
- package/lib/files/gridfs/handler-fastify.js +0 -138
- package/lib/files/minio/handler-express.d.ts +0 -2
- package/lib/files/minio/handler-express.js +0 -36
- package/lib/files/minio/handler-fastify.d.ts +0 -3
- package/lib/files/minio/handler-fastify.js +0 -40
- package/lib/filters/local-search.d.ts +0 -3
- package/lib/filters/strict-equal.d.ts +0 -1
- package/lib/payment/apple-iap/handler-express.d.ts +0 -2
- package/lib/payment/apple-iap/handler-express.js +0 -103
- package/lib/payment/apple-iap/handler-fastify.d.ts +0 -3
- package/lib/payment/braintree.d.ts +0 -1
- package/lib/payment/braintree.js +0 -138
- package/lib/payment/cryptopay/handler-express.d.ts +0 -2
- package/lib/payment/cryptopay/handler-express.js +0 -19
- package/lib/payment/cryptopay/handler-fastify.d.ts +0 -3
- package/lib/payment/cryptopay/handler-fastify.js +0 -17
- package/lib/payment/cryptopay/plugin.d.ts +0 -3
- package/lib/payment/datatrans-v2/handler-express.d.ts +0 -1
- package/lib/payment/datatrans-v2/handler-express.js +0 -71
- package/lib/payment/datatrans-v2/handler-fastify.d.ts +0 -2
- package/lib/payment/datatrans-v2/handler-fastify.js +0 -71
- package/lib/payment/invoice-prepaid.d.ts +0 -1
- package/lib/payment/invoice.d.ts +0 -1
- package/lib/payment/paypal-checkout.d.ts +0 -1
- package/lib/payment/paypal-checkout.js +0 -87
- package/lib/payment/payrexx/handler-express.d.ts +0 -1
- package/lib/payment/payrexx/handler-express.js +0 -85
- package/lib/payment/payrexx/handler-fastify.d.ts +0 -2
- package/lib/payment/payrexx/handler-fastify.js +0 -91
- package/lib/payment/postfinance-checkout/handler-express.d.ts +0 -1
- package/lib/payment/postfinance-checkout/handler-express.js +0 -37
- package/lib/payment/postfinance-checkout/handler-fastify.d.ts +0 -2
- package/lib/payment/postfinance-checkout/handler-fastify.js +0 -40
- package/lib/payment/saferpay/handler-express.d.ts +0 -1
- package/lib/payment/saferpay/handler-express.js +0 -59
- package/lib/payment/saferpay/handler-fastify.d.ts +0 -2
- package/lib/payment/saferpay/handler-fastify.js +0 -62
- package/lib/payment/stripe/handler-express.d.ts +0 -5
- package/lib/payment/stripe/handler-express.js +0 -121
- package/lib/payment/stripe/handler-fastify.d.ts +0 -6
- package/lib/payment/stripe/handler-fastify.js +0 -131
- package/lib/presets/all-express.d.ts +0 -6
- package/lib/presets/all-express.js +0 -26
- package/lib/presets/all-fastify.d.ts +0 -6
- package/lib/presets/all-fastify.js +0 -49
- package/lib/presets/base-express.d.ts +0 -2
- package/lib/presets/base-express.js +0 -5
- package/lib/presets/base-fastify.d.ts +0 -3
- package/lib/presets/base-fastify.js +0 -16
- package/lib/presets/crypto-express.d.ts +0 -3
- package/lib/presets/crypto-express.js +0 -8
- package/lib/presets/crypto-fastify.d.ts +0 -3
- package/lib/presets/crypto-fastify.js +0 -11
- package/lib/pricing/discount-half-price.d.ts +0 -2
- package/lib/pricing/discount-half-price.js +0 -33
- package/lib/pricing/order-items-discount.d.ts +0 -2
- package/lib/pricing/order-items-discount.js +0 -50
- package/lib/pricing/order-round.d.ts +0 -10
- package/lib/pricing/order-round.js +0 -135
- package/lib/pricing/product-catalog-price-options.d.ts +0 -2
- package/lib/pricing/product-catalog-price-options.js +0 -51
- package/lib/pricing/product-round.d.ts +0 -10
- package/lib/pricing/product-round.js +0 -44
- package/lib/quotations/manual.d.ts +0 -1
- package/lib/warehousing/eth-minter.d.ts +0 -1
- package/lib/warehousing/store.d.ts +0 -1
- package/lib/worker/budgetsms.d.ts +0 -9
- package/lib/worker/bulk-export.d.ts +0 -2
- package/lib/worker/bulkgate.d.ts +0 -1
- package/lib/worker/email.d.ts +0 -1
- package/lib/worker/enrollment-order-generator.d.ts +0 -1
- package/lib/worker/heartbeat.d.ts +0 -1
- package/lib/worker/push-notification.d.ts +0 -1
- package/lib/worker/twilio.d.ts +0 -1
- package/lib/worker/update-coinbase-rates.d.ts +0 -1
- package/lib/worker/update-ecb-rates.d.ts +0 -1
- /package/lib/worker/{zombie-killer.d.ts → zombie-killer/adapter.d.ts} +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export default MinioAdapter;
|
|
1
|
+
import type { IPlugin } from '@unchainedshop/core';
|
|
2
|
+
export declare const MinioPlugin: IPlugin;
|
|
3
|
+
export default MinioPlugin;
|
|
4
|
+
export { MinioAdapter, connectToMinio } from './adapter.ts';
|
package/lib/files/minio/index.js
CHANGED
|
@@ -1,164 +1,25 @@
|
|
|
1
|
-
import { Readable } from 'node:stream';
|
|
2
|
-
import {} from '@unchainedshop/file-upload';
|
|
3
|
-
import { FileAdapter, FileDirector, buildHashedFilename, resolveExpirationDate, } from '@unchainedshop/file-upload';
|
|
4
|
-
import mime from 'mime/lite';
|
|
5
|
-
import { Client } from 'minio';
|
|
6
|
-
import { AssumeRoleProvider } from 'minio/dist/esm/AssumeRoleProvider.mjs';
|
|
7
|
-
import { expiryOffsetInMs } from '@unchainedshop/file-upload/lib/put-expiration.js';
|
|
8
1
|
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
+
import { MinioAdapter } from "./adapter.js";
|
|
3
|
+
import { minioWebhookHandler } from "./api.js";
|
|
9
4
|
const logger = createLogger('unchained:minio');
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
export async function connectToMinio() {
|
|
13
|
-
if (!MINIO_ENDPOINT || !MINIO_BUCKET_NAME) {
|
|
14
|
-
logger.error('Please configure Minio/S3 by providing MINIO_ENDPOINT & MINIO_BUCKET_NAME to use upload features');
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
try {
|
|
18
|
-
const resolvedUrl = new URL(MINIO_ENDPOINT);
|
|
19
|
-
const minioClient = new Client({
|
|
20
|
-
endPoint: resolvedUrl.hostname,
|
|
21
|
-
useSSL: resolvedUrl.protocol === 'https:',
|
|
22
|
-
port: parseInt(resolvedUrl.port, 10) || undefined,
|
|
23
|
-
region: MINIO_REGION,
|
|
24
|
-
sessionToken: AMAZON_S3_SESSION_TOKEN,
|
|
25
|
-
accessKey: MINIO_ACCESS_KEY,
|
|
26
|
-
secretKey: MINIO_SECRET_KEY,
|
|
27
|
-
});
|
|
28
|
-
if (NODE_ENV === 'development')
|
|
29
|
-
minioClient?.traceOn(process.stdout);
|
|
30
|
-
if (MINIO_STS_ENDPOINT) {
|
|
31
|
-
const ap = new AssumeRoleProvider({
|
|
32
|
-
stsEndpoint: MINIO_STS_ENDPOINT,
|
|
33
|
-
accessKey: MINIO_ACCESS_KEY,
|
|
34
|
-
secretKey: MINIO_SECRET_KEY,
|
|
35
|
-
});
|
|
36
|
-
await minioClient.setCredentialsProvider(ap);
|
|
37
|
-
}
|
|
38
|
-
return minioClient;
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
logger.error(`Exception while creating Minio client: ${error.message}`);
|
|
42
|
-
}
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
const generateMinioPath = (directoryName, fileName) => {
|
|
46
|
-
const prefix = MINIO_UPLOAD_PREFIX || '';
|
|
47
|
-
return [prefix, directoryName, fileName].filter(Boolean).join('/');
|
|
48
|
-
};
|
|
49
|
-
const generateMinioUrl = (directoryName, hashedFilename) => {
|
|
50
|
-
return `${MINIO_ENDPOINT}/${MINIO_BUCKET_NAME}/${generateMinioPath(directoryName, hashedFilename)}`;
|
|
51
|
-
};
|
|
52
|
-
connectToMinio().then(function setClient(c) {
|
|
53
|
-
client = c || client;
|
|
54
|
-
});
|
|
55
|
-
const getObjectStats = async (fileName) => {
|
|
56
|
-
if (!client)
|
|
57
|
-
throw new Error('Minio not connected, check env variables');
|
|
58
|
-
return client.statObject(MINIO_BUCKET_NAME, fileName);
|
|
59
|
-
};
|
|
60
|
-
const bufferToStream = (buffer) => {
|
|
61
|
-
const stream = new Readable();
|
|
62
|
-
stream.push(buffer);
|
|
63
|
-
stream.push(null);
|
|
64
|
-
return stream;
|
|
65
|
-
};
|
|
66
|
-
export const MinioAdapter = {
|
|
5
|
+
const { MINIO_WEBHOOK_AUTH_TOKEN, MINIO_WEBHOOK_PATH = '/minio/webhook' } = process.env;
|
|
6
|
+
export const MinioPlugin = {
|
|
67
7
|
key: 'shop.unchained.file-upload-plugin.minio',
|
|
68
|
-
label: '
|
|
8
|
+
label: 'Minio/S3 File Upload Plugin with Webhook',
|
|
69
9
|
version: '1.1.0',
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const url = await client.presignedPutObject(MINIO_BUCKET_NAME, generateMinioPath(directoryName, _id), expiryOffsetInMs() / 1000);
|
|
82
|
-
return {
|
|
83
|
-
_id,
|
|
84
|
-
directoryName,
|
|
85
|
-
expiryDate,
|
|
86
|
-
fileName,
|
|
87
|
-
type: mime.getType(fileName),
|
|
88
|
-
putURL: url,
|
|
89
|
-
url: generateMinioUrl(directoryName, _id),
|
|
90
|
-
};
|
|
91
|
-
},
|
|
92
|
-
async removeFiles(files) {
|
|
93
|
-
if (!client)
|
|
94
|
-
throw new Error('Minio not connected, check env variables');
|
|
95
|
-
const fileIds = files.map(({ path, _id }) => {
|
|
96
|
-
return `${path}/${_id}`;
|
|
97
|
-
});
|
|
98
|
-
await client.removeObjects(MINIO_BUCKET_NAME, fileIds);
|
|
99
|
-
},
|
|
100
|
-
async uploadFileFromStream(directoryName, rawFile) {
|
|
101
|
-
if (!client)
|
|
102
|
-
throw new Error('Minio not connected, check env variables');
|
|
103
|
-
let stream;
|
|
104
|
-
let fileName;
|
|
105
|
-
if (rawFile instanceof Promise) {
|
|
106
|
-
const { filename: fname, createReadStream } = await rawFile;
|
|
107
|
-
fileName = fname;
|
|
108
|
-
stream = createReadStream();
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
fileName = rawFile.filename;
|
|
112
|
-
stream = bufferToStream(Buffer.from(rawFile.buffer, 'base64'));
|
|
10
|
+
adapters: [MinioAdapter],
|
|
11
|
+
routes: [
|
|
12
|
+
{
|
|
13
|
+
path: MINIO_WEBHOOK_PATH,
|
|
14
|
+
method: 'POST',
|
|
15
|
+
handler: minioWebhookHandler,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
onRegister: () => {
|
|
19
|
+
if (!MINIO_WEBHOOK_AUTH_TOKEN) {
|
|
20
|
+
logger.warn('MINIO_WEBHOOK_AUTH_TOKEN not set - webhooks will be disabled');
|
|
113
21
|
}
|
|
114
|
-
const _id = await buildHashedFilename(directoryName, fileName, new Date());
|
|
115
|
-
const type = mime.getType(fileName) || (await Promise.resolve(rawFile)).mimetype;
|
|
116
|
-
const metaData = {
|
|
117
|
-
'Content-Type': type,
|
|
118
|
-
};
|
|
119
|
-
await client.putObject(MINIO_BUCKET_NAME, generateMinioPath(directoryName, _id), stream, undefined, metaData);
|
|
120
|
-
const { size } = await getObjectStats(generateMinioPath(directoryName, _id));
|
|
121
|
-
return {
|
|
122
|
-
_id,
|
|
123
|
-
directoryName,
|
|
124
|
-
expiryDate: null,
|
|
125
|
-
fileName,
|
|
126
|
-
size,
|
|
127
|
-
type,
|
|
128
|
-
url: generateMinioUrl(directoryName, _id),
|
|
129
|
-
};
|
|
130
|
-
},
|
|
131
|
-
async uploadFileFromURL(directoryName, { fileLink, fileName: fname, fileId, headers }) {
|
|
132
|
-
if (!client)
|
|
133
|
-
throw new Error('Minio not connected, check env variables');
|
|
134
|
-
const { href } = new URL(fileLink);
|
|
135
|
-
const fileName = fname || href.split('/').pop();
|
|
136
|
-
const hashedFilename = await buildHashedFilename(directoryName, fileName, new Date());
|
|
137
|
-
const url = new URL(fileLink);
|
|
138
|
-
const response = await fetch(url, { headers });
|
|
139
|
-
const type = mime.getType(fileName) || response.headers['content-type'];
|
|
140
|
-
const readable = Readable.fromWeb(response.body);
|
|
141
|
-
const metaData = {
|
|
142
|
-
'Content-Type': type,
|
|
143
|
-
};
|
|
144
|
-
await client.putObject(MINIO_BUCKET_NAME, generateMinioPath(directoryName, hashedFilename), readable, undefined, metaData);
|
|
145
|
-
const { size } = await getObjectStats(generateMinioPath(directoryName, hashedFilename));
|
|
146
|
-
return {
|
|
147
|
-
_id: fileId || hashedFilename,
|
|
148
|
-
directoryName,
|
|
149
|
-
expiryDate: null,
|
|
150
|
-
fileName,
|
|
151
|
-
size,
|
|
152
|
-
type,
|
|
153
|
-
url: generateMinioUrl(directoryName, hashedFilename),
|
|
154
|
-
};
|
|
155
|
-
},
|
|
156
|
-
async createDownloadStream(file) {
|
|
157
|
-
if (!client)
|
|
158
|
-
throw new Error('Minio not connected, check env variables');
|
|
159
|
-
const stream = await client.getObject(MINIO_BUCKET_NAME, generateMinioPath(file.path, file._id));
|
|
160
|
-
return stream;
|
|
161
22
|
},
|
|
162
23
|
};
|
|
163
|
-
|
|
164
|
-
export
|
|
24
|
+
export default MinioPlugin;
|
|
25
|
+
export { MinioAdapter, connectToMinio } from "./adapter.js";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
+
import { getFileAdapter } from '@unchainedshop/core';
|
|
3
|
+
import { Roles } from '@unchainedshop/roles';
|
|
4
|
+
const logger = createLogger('unchained:temp-upload');
|
|
5
|
+
export async function tempUploadHandler(request, context) {
|
|
6
|
+
try {
|
|
7
|
+
const hasPermission = await Roles.userHasPermission(context, 'uploadTempFile', []);
|
|
8
|
+
if (!hasPermission) {
|
|
9
|
+
return Response.json({ error: 'Permission denied', message: 'User does not have uploadTempFile permission' }, { status: 403 });
|
|
10
|
+
}
|
|
11
|
+
const formData = await request.formData();
|
|
12
|
+
let file = formData.get('file');
|
|
13
|
+
if (!file || !(file instanceof File)) {
|
|
14
|
+
for (const [, value] of formData.entries()) {
|
|
15
|
+
if (value instanceof File) {
|
|
16
|
+
file = value;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (!file) {
|
|
22
|
+
return Response.json({ error: 'No file uploaded' }, { status: 400 });
|
|
23
|
+
}
|
|
24
|
+
const buffer = Buffer.from(await file.arrayBuffer());
|
|
25
|
+
const uploadedFile = await context.services.files.uploadFileFromStream({
|
|
26
|
+
directoryName: 'temp-uploads',
|
|
27
|
+
rawFile: {
|
|
28
|
+
filename: file.name,
|
|
29
|
+
buffer,
|
|
30
|
+
mimetype: file.type,
|
|
31
|
+
},
|
|
32
|
+
meta: { encoding: 'binary' },
|
|
33
|
+
});
|
|
34
|
+
const expires = new Date(Date.now() + 24 * 60 * 60 * 1000);
|
|
35
|
+
await context.modules.files.update(uploadedFile._id, {
|
|
36
|
+
expires,
|
|
37
|
+
});
|
|
38
|
+
const fileUploadAdapter = getFileAdapter();
|
|
39
|
+
const rawUrl = await fileUploadAdapter.createDownloadURL(uploadedFile);
|
|
40
|
+
if (!rawUrl)
|
|
41
|
+
throw new Error('Could not create download URL for file');
|
|
42
|
+
const url = context.modules.files.normalizeUrl(rawUrl, {});
|
|
43
|
+
return Response.json({ fileId: uploadedFile._id, url, expires: expires.toISOString() }, { status: 200 });
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
logger.error(e);
|
|
47
|
+
return Response.json({ name: e.name, code: e.code, message: e.message }, { status: 503 });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { tempUploadHandler } from "./api.js";
|
|
2
|
+
const { TEMP_UPLOAD_API_PATH = '/temp-upload' } = process.env;
|
|
3
|
+
export const TempUploadPlugin = {
|
|
4
|
+
key: 'shop.unchained.files.temp-upload',
|
|
5
|
+
label: 'Temp Upload Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
routes: [
|
|
8
|
+
{
|
|
9
|
+
path: TEMP_UPLOAD_API_PATH,
|
|
10
|
+
method: 'POST',
|
|
11
|
+
handler: tempUploadHandler,
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
export default TempUploadPlugin;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { isDocumentDBCompatModeEnabled } from '@unchainedshop/mongodb';
|
|
4
|
-
const logger = createLogger('unchained:local-search');
|
|
5
|
-
const LocalSearch = {
|
|
1
|
+
import { FilterAdapter } from '@unchainedshop/core';
|
|
2
|
+
export const LocalSearch = {
|
|
6
3
|
...FilterAdapter,
|
|
7
4
|
key: 'shop.unchained.filters.local-search',
|
|
8
5
|
label: 'Simple Fulltext search with MongoDB',
|
|
@@ -57,10 +54,3 @@ const LocalSearch = {
|
|
|
57
54
|
};
|
|
58
55
|
},
|
|
59
56
|
};
|
|
60
|
-
export default LocalSearch;
|
|
61
|
-
if (!isDocumentDBCompatModeEnabled()) {
|
|
62
|
-
FilterDirector.registerAdapter(LocalSearch);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
logger.warn('Free text search queries have been disabled due to DocumentDB compatibility mode (env UNCHAINED_DOCUMENTDB_COMPAT_MODE is trueish)');
|
|
66
|
-
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { LocalSearch } from "./adapter.js";
|
|
3
|
+
import { isDocumentDBCompatModeEnabled } from '@unchainedshop/mongodb';
|
|
4
|
+
export const LocalSearchPlugin = {
|
|
5
|
+
key: 'shop.unchained.filters.local-search',
|
|
6
|
+
label: 'Local Search Filter Plugin',
|
|
7
|
+
version: '1.0.0',
|
|
8
|
+
adapters: [LocalSearch],
|
|
9
|
+
onRegister: () => {
|
|
10
|
+
if (isDocumentDBCompatModeEnabled()) {
|
|
11
|
+
throw new Error('Full-text search queries have been disabled due to DocumentDB compatibility mode (env UNCHAINED_DOCUMENTDB_COMPAT_MODE is trueish)');
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export default LocalSearchPlugin;
|
|
16
|
+
export { LocalSearch } from "./adapter.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const StrictQualFilter = {
|
|
1
|
+
import { FilterAdapter } from '@unchainedshop/core';
|
|
2
|
+
export const StrictQualFilter = {
|
|
3
3
|
...FilterAdapter,
|
|
4
4
|
key: 'shop.unchained.filters.strict-qual',
|
|
5
5
|
label: 'Simple Strict Equal DB Filter',
|
|
@@ -21,4 +21,3 @@ const StrictQualFilter = {
|
|
|
21
21
|
};
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
|
-
FilterDirector.registerAdapter(StrictQualFilter);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {} from '@unchainedshop/core';
|
|
2
|
+
import { StrictQualFilter } from "./adapter.js";
|
|
3
|
+
export const StrictQualFilterPlugin = {
|
|
4
|
+
key: 'shop.unchained.filters.strict-qual',
|
|
5
|
+
label: 'Strict Equal Filter Plugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
adapters: [StrictQualFilter],
|
|
8
|
+
};
|
|
9
|
+
export default StrictQualFilterPlugin;
|
|
10
|
+
export { StrictQualFilter } from "./adapter.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { type IPaymentAdapter } from '@unchainedshop/core';
|
|
2
|
+
export declare const AppleIAP: IPaymentAdapter;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { PaymentAdapter,
|
|
1
|
+
import { PaymentAdapter, PaymentError } from '@unchainedshop/core';
|
|
2
2
|
import { createLogger } from '@unchainedshop/logger';
|
|
3
3
|
import {} from "./module.js";
|
|
4
4
|
import { verifyReceipt } from "./verify-receipt.js";
|
|
5
5
|
const logger = createLogger('unchained:apple-iap');
|
|
6
6
|
const { APPLE_IAP_SHARED_SECRET } = process.env;
|
|
7
|
-
const AppleIAP = {
|
|
7
|
+
export const AppleIAP = {
|
|
8
8
|
...PaymentAdapter,
|
|
9
9
|
key: 'shop.unchained.apple-iap',
|
|
10
10
|
label: 'Apple In-App-Purchase',
|
|
@@ -111,4 +111,3 @@ const AppleIAP = {
|
|
|
111
111
|
return adapterActions;
|
|
112
112
|
},
|
|
113
113
|
};
|
|
114
|
-
PaymentDirector.registerAdapter(AppleIAP);
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {} from '@unchainedshop/api';
|
|
2
|
-
import { EnrollmentStatus } from '@unchainedshop/core-enrollments';
|
|
3
1
|
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
+
import { EnrollmentStatus } from '@unchainedshop/core-enrollments';
|
|
4
3
|
import { fixPeriods } from "./fix-periods.js";
|
|
5
|
-
|
|
6
|
-
import {} from "./module.js";
|
|
7
|
-
const logger = createLogger('unchained:apple-iap:handler');
|
|
4
|
+
const logger = createLogger('unchained:apple-iap');
|
|
8
5
|
const { APPLE_IAP_SHARED_SECRET } = process.env;
|
|
9
6
|
const AppleNotificationTypes = {
|
|
10
7
|
INITIAL_BUY: 'INITIAL_BUY',
|
|
@@ -13,47 +10,61 @@ const AppleNotificationTypes = {
|
|
|
13
10
|
DID_FAIL_TO_RENEW: 'DID_FAIL_TO_RENEW',
|
|
14
11
|
DID_CHANGE_RENEWAL_PREF: 'DID_CHANGE_RENEWAL_PREF',
|
|
15
12
|
};
|
|
16
|
-
export
|
|
13
|
+
export async function appleIAPWebhookHandler(request, context) {
|
|
17
14
|
try {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const responseBody = req.body || {};
|
|
15
|
+
const { modules, services } = context;
|
|
16
|
+
const responseBody = await request.json();
|
|
21
17
|
if (responseBody.password !== APPLE_IAP_SHARED_SECRET) {
|
|
22
|
-
|
|
18
|
+
logger.warn('Apple IAP Webhook: Invalid shared secret');
|
|
19
|
+
return new Response(JSON.stringify({
|
|
20
|
+
error: 'Invalid shared secret',
|
|
21
|
+
name: 'AuthenticationError',
|
|
22
|
+
code: 'INVALID_SECRET',
|
|
23
|
+
}), {
|
|
24
|
+
status: 403,
|
|
25
|
+
headers: { 'Content-Type': 'application/json' },
|
|
26
|
+
});
|
|
23
27
|
}
|
|
24
28
|
const transactions = responseBody?.unified_receipt?.latest_receipt_info;
|
|
25
|
-
const latestTransaction = transactions[0];
|
|
29
|
+
const latestTransaction = transactions?.[0];
|
|
30
|
+
if (!latestTransaction) {
|
|
31
|
+
throw new Error('No transaction found in receipt');
|
|
32
|
+
}
|
|
26
33
|
if (responseBody.notification_type === AppleNotificationTypes.INITIAL_BUY) {
|
|
27
34
|
const orderPayment = await modules.orders.payments.findOrderPaymentByTransactionId(latestTransaction.transaction_id);
|
|
28
|
-
if (!orderPayment)
|
|
35
|
+
if (!orderPayment) {
|
|
29
36
|
throw new Error('Could not find any matching order payment');
|
|
37
|
+
}
|
|
30
38
|
const order = await services.orders.checkoutOrder(orderPayment.orderId, {
|
|
31
39
|
paymentContext: {
|
|
32
40
|
receiptData: responseBody?.unified_receipt?.latest_receipt,
|
|
33
41
|
},
|
|
34
42
|
});
|
|
35
|
-
if (!order)
|
|
43
|
+
if (!order) {
|
|
36
44
|
throw new Error(`Order with id ${orderPayment.orderId} not found`);
|
|
45
|
+
}
|
|
37
46
|
const orderId = order._id;
|
|
38
47
|
const enrollment = await modules.enrollments.findEnrollment({
|
|
39
48
|
orderId,
|
|
40
49
|
});
|
|
41
|
-
if (!enrollment)
|
|
42
|
-
throw new Error('
|
|
50
|
+
if (!enrollment) {
|
|
51
|
+
throw new Error('Could not find any matching enrollment');
|
|
52
|
+
}
|
|
43
53
|
await fixPeriods({
|
|
44
54
|
transactionId: latestTransaction.original_transaction_id,
|
|
45
55
|
transactions,
|
|
46
56
|
enrollmentId: enrollment._id,
|
|
47
57
|
orderId,
|
|
48
|
-
},
|
|
49
|
-
logger.info(`Webhook
|
|
58
|
+
}, context);
|
|
59
|
+
logger.info(`Apple IAP Webhook: Confirmed checkout for order ${order.orderNumber}`, {
|
|
50
60
|
orderId: order._id,
|
|
51
61
|
});
|
|
52
62
|
}
|
|
53
63
|
else {
|
|
54
64
|
const originalOrderPayment = await modules.orders.payments.findOrderPaymentByTransactionId(latestTransaction.original_transaction_id);
|
|
55
|
-
if (!originalOrderPayment)
|
|
65
|
+
if (!originalOrderPayment) {
|
|
56
66
|
throw new Error('Could not find any matching order payment');
|
|
67
|
+
}
|
|
57
68
|
const originalOrder = await modules.orders.findOrder({
|
|
58
69
|
orderId: originalOrderPayment.orderId,
|
|
59
70
|
});
|
|
@@ -61,8 +72,9 @@ export const appleIAPHandler = async (req, reply) => {
|
|
|
61
72
|
(await modules.enrollments.findEnrollment({
|
|
62
73
|
orderId: originalOrder._id,
|
|
63
74
|
}));
|
|
64
|
-
if (!enrollment?.payment)
|
|
75
|
+
if (!enrollment?.payment) {
|
|
65
76
|
throw new Error('Could not find a valid enrollment payment method');
|
|
77
|
+
}
|
|
66
78
|
await services.orders.registerPaymentCredentials(enrollment.payment.paymentProviderId, {
|
|
67
79
|
transactionContext: {
|
|
68
80
|
receiptData: responseBody?.unified_receipt?.latest_receipt,
|
|
@@ -74,8 +86,8 @@ export const appleIAPHandler = async (req, reply) => {
|
|
|
74
86
|
transactions,
|
|
75
87
|
enrollmentId: enrollment._id,
|
|
76
88
|
orderId: originalOrder._id,
|
|
77
|
-
},
|
|
78
|
-
logger.info(`Webhook
|
|
89
|
+
}, context);
|
|
90
|
+
logger.info(`Apple IAP Webhook: Processed notification for ${latestTransaction.original_transaction_id} and type ${responseBody.notification_type}`);
|
|
79
91
|
if (responseBody.notification_type === AppleNotificationTypes.DID_RECOVER) {
|
|
80
92
|
if (enrollment.status !== EnrollmentStatus.TERMINATED &&
|
|
81
93
|
responseBody.auto_renew_status === 'false') {
|
|
@@ -88,15 +100,20 @@ export const appleIAPHandler = async (req, reply) => {
|
|
|
88
100
|
await services.enrollments.terminateEnrollment(enrollment);
|
|
89
101
|
}
|
|
90
102
|
}
|
|
91
|
-
logger.info(
|
|
103
|
+
logger.info('Apple IAP Webhook: Updated enrollment from Apple');
|
|
92
104
|
}
|
|
93
|
-
|
|
94
|
-
return reply.send();
|
|
105
|
+
return new Response(null, { status: 200 });
|
|
95
106
|
}
|
|
96
|
-
catch (
|
|
97
|
-
logger.error(
|
|
98
|
-
|
|
99
|
-
|
|
107
|
+
catch (error) {
|
|
108
|
+
logger.error('Apple IAP Webhook error:', error);
|
|
109
|
+
return new Response(JSON.stringify({
|
|
110
|
+
success: false,
|
|
111
|
+
error: error.message,
|
|
112
|
+
name: error.name,
|
|
113
|
+
code: error.code,
|
|
114
|
+
}), {
|
|
115
|
+
status: 503,
|
|
116
|
+
headers: { 'Content-Type': 'application/json' },
|
|
117
|
+
});
|
|
100
118
|
}
|
|
101
|
-
}
|
|
102
|
-
export default appleIAPHandler;
|
|
119
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
export
|
|
4
|
-
export default
|
|
1
|
+
import type { IPlugin } from '@unchainedshop/core';
|
|
2
|
+
import { type AppleTransactionsModule } from './module.ts';
|
|
3
|
+
export declare const AppleIAPPlugin: IPlugin;
|
|
4
|
+
export default AppleIAPPlugin;
|
|
5
|
+
export { AppleIAP } from './adapter.ts';
|
|
6
|
+
export { type AppleTransactionsModule };
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { AppleIAP } from "./adapter.js";
|
|
2
|
+
import { configureAppleTransactionsModule } from "./module.js";
|
|
3
|
+
import { appleIAPWebhookHandler } from "./api.js";
|
|
4
|
+
const { APPLE_IAP_WEBHOOK_PATH = '/payment/apple-iap', APPLE_IAP_SHARED_SECRET } = process.env;
|
|
5
|
+
export const AppleIAPPlugin = {
|
|
6
|
+
key: 'shop.unchained.payment.apple-iap',
|
|
7
|
+
label: 'Apple In-App-Purchase Payment Plugin',
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
adapters: [AppleIAP],
|
|
10
|
+
module: ({ db }) => ({
|
|
11
|
+
appleTransactions: configureAppleTransactionsModule({ db }),
|
|
12
|
+
}),
|
|
13
|
+
routes: [
|
|
14
|
+
{
|
|
15
|
+
path: APPLE_IAP_WEBHOOK_PATH,
|
|
16
|
+
method: 'POST',
|
|
17
|
+
handler: appleIAPWebhookHandler,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
onRegister: () => {
|
|
21
|
+
if (!APPLE_IAP_SHARED_SECRET) {
|
|
22
|
+
throw new Error('APPLE_IAP_SHARED_SECRET not set');
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
export default AppleIAPPlugin;
|
|
27
|
+
export { AppleIAP } from "./adapter.js";
|
|
28
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PaymentAdapter,
|
|
1
|
+
import { PaymentAdapter, PaymentError, OrderPricingSheet, } from '@unchainedshop/core';
|
|
2
2
|
import { createLogger } from '@unchainedshop/logger';
|
|
3
3
|
import {} from "./module.js";
|
|
4
4
|
import deriveBtcAddress from "./derive-btc-address.js";
|
|
@@ -10,7 +10,7 @@ const CryptopayCurrencies = {
|
|
|
10
10
|
BTC: 'BTC',
|
|
11
11
|
ETH: 'ETH',
|
|
12
12
|
};
|
|
13
|
-
const Cryptopay = {
|
|
13
|
+
export const Cryptopay = {
|
|
14
14
|
...PaymentAdapter,
|
|
15
15
|
key: 'shop.unchained.payment.cryptopay',
|
|
16
16
|
label: 'Cryptopay',
|
|
@@ -155,5 +155,3 @@ const Cryptopay = {
|
|
|
155
155
|
return adapterActions;
|
|
156
156
|
},
|
|
157
157
|
};
|
|
158
|
-
PaymentDirector.registerAdapter(Cryptopay);
|
|
159
|
-
export default Cryptopay;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
+
import handleWebhook from "./handle-webhook.js";
|
|
3
|
+
const logger = createLogger('unchained:cryptopay');
|
|
4
|
+
export async function cryptopayWebhookHandler(request, context) {
|
|
5
|
+
try {
|
|
6
|
+
const body = await request.json();
|
|
7
|
+
await handleWebhook(body, context);
|
|
8
|
+
return new Response(JSON.stringify({ success: true }), {
|
|
9
|
+
status: 200,
|
|
10
|
+
headers: { 'Content-Type': 'application/json' },
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
logger.error('Cryptopay webhook error:', error);
|
|
15
|
+
return new Response(JSON.stringify({
|
|
16
|
+
success: false,
|
|
17
|
+
error: error.message,
|
|
18
|
+
}), {
|
|
19
|
+
status: 500,
|
|
20
|
+
headers: { 'Content-Type': 'application/json' },
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import '
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
import type { IPlugin } from '@unchainedshop/core';
|
|
2
|
+
export declare const CryptopayPlugin: IPlugin;
|
|
3
|
+
export default CryptopayPlugin;
|
|
4
|
+
export { Cryptopay } from './adapter.ts';
|
|
5
|
+
export { type CryptopayModule } from './module.ts';
|