@unchainedshop/plugins 4.6.2 → 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/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/index.d.ts +5 -4
- package/lib/files/gridfs/index.js +30 -3
- package/lib/files/minio/index.d.ts +4 -5
- package/lib/files/minio/index.js +18 -157
- package/lib/payment/apple-iap/adapter.d.ts +2 -1
- package/lib/payment/apple-iap/adapter.js +2 -3
- package/lib/payment/apple-iap/index.d.ts +6 -4
- package/lib/payment/apple-iap/index.js +28 -3
- package/lib/payment/cryptopay/index.d.ts +5 -4
- package/lib/payment/cryptopay/index.js +31 -3
- package/lib/payment/datatrans-v2/index.d.ts +4 -1
- package/lib/payment/datatrans-v2/index.js +17 -400
- package/lib/payment/payrexx/index.d.ts +4 -1
- package/lib/payment/payrexx/index.js +19 -158
- package/lib/payment/postfinance-checkout/index.d.ts +5 -0
- package/lib/payment/postfinance-checkout/index.js +25 -186
- 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/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/package.json +15 -10
- package/lib/delivery/post.d.ts +0 -1
- package/lib/delivery/post.js +0 -23
- package/lib/delivery/send-message.d.ts +0 -1
- package/lib/delivery/send-message.js +0 -40
- package/lib/delivery/stores.d.ts +0 -1
- package/lib/delivery/stores.js +0 -43
- package/lib/enrollments/licensed.d.ts +0 -4
- package/lib/enrollments/licensed.js +0 -52
- 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/local-search.js +0 -66
- package/lib/filters/strict-equal.d.ts +0 -1
- package/lib/filters/strict-equal.js +0 -24
- 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/apple-iap/handler-fastify.js +0 -102
- 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/cryptopay/plugin.js +0 -159
- 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-prepaid.js +0 -30
- package/lib/payment/invoice.d.ts +0 -1
- package/lib/payment/invoice.js +0 -27
- 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/delivery-swiss-tax.d.ts +0 -2
- package/lib/pricing/delivery-swiss-tax.js +0 -62
- package/lib/pricing/discount-100-off.d.ts +0 -2
- package/lib/pricing/discount-100-off.js +0 -30
- package/lib/pricing/discount-half-price-manual.d.ts +0 -2
- package/lib/pricing/discount-half-price-manual.js +0 -30
- package/lib/pricing/discount-half-price.d.ts +0 -2
- package/lib/pricing/discount-half-price.js +0 -33
- package/lib/pricing/free-delivery.d.ts +0 -2
- package/lib/pricing/free-delivery.js +0 -27
- package/lib/pricing/free-payment.d.ts +0 -2
- package/lib/pricing/free-payment.js +0 -27
- package/lib/pricing/order-delivery.d.ts +0 -2
- package/lib/pricing/order-delivery.js +0 -33
- package/lib/pricing/order-discount.d.ts +0 -2
- package/lib/pricing/order-discount.js +0 -74
- package/lib/pricing/order-items-discount.d.ts +0 -2
- package/lib/pricing/order-items-discount.js +0 -50
- package/lib/pricing/order-items.d.ts +0 -2
- package/lib/pricing/order-items.js +0 -43
- package/lib/pricing/order-payment.d.ts +0 -2
- package/lib/pricing/order-payment.js +0 -33
- 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-catalog-price.d.ts +0 -2
- package/lib/pricing/product-catalog-price.js +0 -60
- package/lib/pricing/product-discount.d.ts +0 -2
- package/lib/pricing/product-discount.js +0 -69
- package/lib/pricing/product-price-rateconversion.d.ts +0 -2
- package/lib/pricing/product-price-rateconversion.js +0 -53
- package/lib/pricing/product-round.d.ts +0 -10
- package/lib/pricing/product-round.js +0 -44
- package/lib/pricing/product-swiss-tax.d.ts +0 -2
- package/lib/pricing/product-swiss-tax.js +0 -76
- package/lib/quotations/manual.d.ts +0 -1
- package/lib/quotations/manual.js +0 -20
- package/lib/warehousing/eth-minter.d.ts +0 -1
- package/lib/warehousing/eth-minter.js +0 -120
- package/lib/warehousing/store.d.ts +0 -1
- package/lib/warehousing/store.js +0 -34
- package/lib/worker/budgetsms.d.ts +0 -9
- package/lib/worker/budgetsms.js +0 -169
- package/lib/worker/bulk-export.d.ts +0 -2
- package/lib/worker/bulk-export.js +0 -64
- package/lib/worker/bulk-import.d.ts +0 -2
- package/lib/worker/bulk-import.js +0 -65
- package/lib/worker/bulkgate.d.ts +0 -1
- package/lib/worker/bulkgate.js +0 -91
- package/lib/worker/email.d.ts +0 -1
- package/lib/worker/email.js +0 -136
- package/lib/worker/enrollment-order-generator.d.ts +0 -1
- package/lib/worker/enrollment-order-generator.js +0 -77
- package/lib/worker/error-notifications.d.ts +0 -9
- package/lib/worker/error-notifications.js +0 -61
- package/lib/worker/export-token.d.ts +0 -4
- package/lib/worker/export-token.js +0 -26
- package/lib/worker/external.d.ts +0 -2
- package/lib/worker/external.js +0 -13
- package/lib/worker/heartbeat.d.ts +0 -1
- package/lib/worker/heartbeat.js +0 -26
- package/lib/worker/http-request.d.ts +0 -8
- package/lib/worker/http-request.js +0 -56
- package/lib/worker/message.d.ts +0 -10
- package/lib/worker/message.js +0 -42
- package/lib/worker/push-notification.d.ts +0 -1
- package/lib/worker/push-notification.js +0 -87
- package/lib/worker/twilio.d.ts +0 -1
- package/lib/worker/twilio.js +0 -59
- package/lib/worker/update-coinbase-rates.d.ts +0 -1
- package/lib/worker/update-coinbase-rates.js +0 -59
- package/lib/worker/update-ecb-rates.d.ts +0 -1
- package/lib/worker/update-ecb-rates.js +0 -92
- package/lib/worker/update-token-ownership.d.ts +0 -3
- package/lib/worker/update-token-ownership.js +0 -57
- package/lib/worker/zombie-killer.d.ts +0 -13
- package/lib/worker/zombie-killer.js +0 -91
package/README.md
CHANGED
|
@@ -22,7 +22,6 @@ npm install @unchainedshop/plugins
|
|
|
22
22
|
| Stripe | `payment/stripe` | Stripe payment integration |
|
|
23
23
|
| Datatrans V2 | `payment/datatrans-v2` | Datatrans payment gateway |
|
|
24
24
|
| Saferpay | `payment/saferpay` | Saferpay payment gateway |
|
|
25
|
-
| PayPal Checkout | `payment/paypal-checkout` | PayPal Checkout integration |
|
|
26
25
|
| Braintree | `payment/braintree` | Braintree payments |
|
|
27
26
|
| Payrexx | `payment/payrexx` | Payrexx payment gateway |
|
|
28
27
|
| Apple IAP | `payment/apple-iap` | Apple In-App Purchase |
|
|
@@ -134,7 +133,6 @@ All payment plugins implement secure tokenization patterns for PCI DSS SAQ-A eli
|
|
|
134
133
|
| Stripe | PaymentIntent/SetupIntent tokenization |
|
|
135
134
|
| Datatrans | Secure Fields with HMAC-SHA-256 signatures |
|
|
136
135
|
| Saferpay | Redirect with SHA-256 transaction signatures |
|
|
137
|
-
| PayPal | Order ID references |
|
|
138
136
|
| Braintree | Client SDK tokenization |
|
|
139
137
|
| Cryptopay | BIP-32 HD wallet address derivation |
|
|
140
138
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
|
-
import {
|
|
3
|
-
const NodeEventEmitter = () => {
|
|
2
|
+
import {} from '@unchainedshop/events';
|
|
3
|
+
export const NodeEventEmitter = () => {
|
|
4
4
|
const eventEmitter = new EventEmitter();
|
|
5
5
|
return {
|
|
6
6
|
publish: (eventName, payload) => {
|
|
@@ -11,4 +11,4 @@ const NodeEventEmitter = () => {
|
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
export default NodeEventEmitter;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type IFileAdapter } from '@unchainedshop/
|
|
1
|
+
import { type IFileAdapter } from '@unchainedshop/core-files';
|
|
2
2
|
import { type UnchainedCore } from '@unchainedshop/core';
|
|
3
|
-
import { type GridFSFileUploadsModule } from './
|
|
3
|
+
import { type GridFSFileUploadsModule } from './module.ts';
|
|
4
4
|
export declare const GridFSAdapter: IFileAdapter<UnchainedCore & {
|
|
5
5
|
modules: GridFSFileUploadsModule;
|
|
6
6
|
}>;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { Readable, PassThrough } from 'node:stream';
|
|
2
2
|
import { finished, pipeline } from 'node:stream/promises';
|
|
3
3
|
import mime from 'mime/lite';
|
|
4
|
-
import { FileAdapter,
|
|
5
|
-
import {} from '@unchainedshop/file-upload';
|
|
4
|
+
import { FileAdapter, buildHashedFilename, resolveExpirationDate, filesSettings, } from '@unchainedshop/core-files';
|
|
6
5
|
import sign from "./sign.js";
|
|
7
|
-
import { filesSettings } from '@unchainedshop/core-files';
|
|
8
6
|
import {} from '@unchainedshop/core';
|
|
9
|
-
import {} from "./
|
|
7
|
+
import {} from "./module.js";
|
|
10
8
|
const { GRIDFS_PUT_SERVER_PATH = '/gridfs' } = process.env;
|
|
11
9
|
const bufferToStream = (buffer) => {
|
|
12
10
|
const stream = new Readable();
|
|
@@ -113,4 +111,3 @@ export const GridFSAdapter = {
|
|
|
113
111
|
await Promise.all(files.map(async ({ _id, path }) => modules.gridfsFileUploads.removeFileFromBucket(path, _id)));
|
|
114
112
|
},
|
|
115
113
|
};
|
|
116
|
-
FileDirector.registerAdapter(GridFSAdapter);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import '
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
import type { IPlugin } from '@unchainedshop/core';
|
|
2
|
+
export declare const GridFSPlugin: IPlugin;
|
|
3
|
+
export default GridFSPlugin;
|
|
4
|
+
export { GridFSAdapter } from './adapter.ts';
|
|
5
|
+
export { type GridFSFileUploadsModule } from './module.ts';
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
+
import { GridFSAdapter } from "./adapter.js";
|
|
3
|
+
import { configureGridFSFileUploadModule } from "./module.js";
|
|
4
|
+
import { gridfsRouteHandler } from "./api.js";
|
|
5
|
+
const { GRIDFS_PUT_SERVER_PATH = '/gridfs', UNCHAINED_GRIDFS_PUT_UPLOAD_SECRET } = process.env;
|
|
6
|
+
const logger = createLogger('unchained:gridfs');
|
|
7
|
+
export const GridFSPlugin = {
|
|
8
|
+
key: 'shop.unchained.file-upload-plugin.gridfs',
|
|
9
|
+
label: 'GridFS File Upload Plugin',
|
|
10
|
+
version: '1.0.0',
|
|
11
|
+
adapters: [GridFSAdapter],
|
|
12
|
+
module: ({ db }) => ({
|
|
13
|
+
gridfsFileUploads: configureGridFSFileUploadModule({ db }),
|
|
14
|
+
}),
|
|
15
|
+
routes: [
|
|
16
|
+
{
|
|
17
|
+
path: `${GRIDFS_PUT_SERVER_PATH}/:directoryName/:fileName`,
|
|
18
|
+
method: 'ALL',
|
|
19
|
+
handler: gridfsRouteHandler,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
onRegister: () => {
|
|
23
|
+
if (!UNCHAINED_GRIDFS_PUT_UPLOAD_SECRET) {
|
|
24
|
+
logger.warn('UNCHAINED_GRIDFS_PUT_UPLOAD_SECRET not set - PUT uploads and signed downloads will fail');
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export default GridFSPlugin;
|
|
29
|
+
export { GridFSAdapter } from "./adapter.js";
|
|
30
|
+
export {} from "./module.js";
|
|
@@ -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";
|
|
@@ -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,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,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';
|
|
@@ -1,3 +1,31 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import cryptopayModules from "./module.js";
|
|
2
|
+
import { Cryptopay } from "./adapter.js";
|
|
3
|
+
import { cryptopayWebhookHandler } from "./api.js";
|
|
4
|
+
const { CRYPTOPAY_SECRET, CRYPTOPAY_BTC_XPUB, CRYPTOPAY_ETH_XPUB, CRYPTOPAY_WEBHOOK_PATH = '/payment/cryptopay', } = process.env;
|
|
5
|
+
export const CryptopayPlugin = {
|
|
6
|
+
key: 'shop.unchained.payment.cryptopay',
|
|
7
|
+
label: 'Cryptopay Payment Plugin',
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
adapters: [Cryptopay],
|
|
10
|
+
module: ({ db }) => ({
|
|
11
|
+
cryptopay: cryptopayModules.cryptopay.configure({ db }),
|
|
12
|
+
}),
|
|
13
|
+
routes: [
|
|
14
|
+
{
|
|
15
|
+
path: CRYPTOPAY_WEBHOOK_PATH,
|
|
16
|
+
method: 'POST',
|
|
17
|
+
handler: cryptopayWebhookHandler,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
onRegister: () => {
|
|
21
|
+
if (!CRYPTOPAY_SECRET) {
|
|
22
|
+
throw new Error('CRYPTOPAY_SECRET not set');
|
|
23
|
+
}
|
|
24
|
+
if (!CRYPTOPAY_BTC_XPUB && !CRYPTOPAY_ETH_XPUB) {
|
|
25
|
+
throw new Error('No CRYPTOPAY_BTC_XPUB or CRYPTOPAY_ETH_XPUB set');
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export default CryptopayPlugin;
|
|
30
|
+
export { Cryptopay } from "./adapter.js";
|
|
31
|
+
export {} from "./module.js";
|