@unchainedshop/plugins 2.5.5 → 2.5.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/plugins",
3
- "version": "2.5.5",
3
+ "version": "2.5.7",
4
4
  "main": "lib/plugins-index.js",
5
5
  "types": "lib/plugins-index.d.ts",
6
6
  "exports": {
@@ -75,44 +75,44 @@
75
75
  "@redis/client": "^1.5.8",
76
76
  "bip32": "^4.0.0",
77
77
  "escape-string-regexp": "^5.0.0",
78
- "ethers": "^6.7.1",
78
+ "ethers": "^6.8.0",
79
79
  "express": "^4.18.2",
80
80
  "mongodb": "^5.9.0",
81
81
  "postfinancecheckout": "^4.1.1",
82
- "stripe": "^13.7.0",
82
+ "stripe": "^13.11.0",
83
83
  "tiny-secp256k1": "^2.2.3",
84
84
  "web-push": "^3.6.3"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@redis/client": "^1.5.11",
88
- "@types/node": "^18.18.0",
89
- "@unchainedshop/api": "^2.5.5",
90
- "@unchainedshop/core-delivery": "^2.5.5",
91
- "@unchainedshop/core-enrollments": "^2.5.5",
92
- "@unchainedshop/core-filters": "^2.5.5",
93
- "@unchainedshop/core-messaging": "^2.5.5",
94
- "@unchainedshop/core-orders": "^2.5.5",
95
- "@unchainedshop/core-payment": "^2.5.5",
96
- "@unchainedshop/core-products": "^2.5.5",
97
- "@unchainedshop/core-quotations": "^2.5.5",
98
- "@unchainedshop/core-warehousing": "^2.5.5",
99
- "@unchainedshop/core-worker": "^2.5.5",
100
- "@unchainedshop/events": "^2.5.5",
101
- "@unchainedshop/file-upload": "^2.5.5",
102
- "@unchainedshop/logger": "^2.5.5",
103
- "@unchainedshop/types": "^2.5.5",
104
- "@unchainedshop/utils": "^2.5.5",
88
+ "@types/node": "^18.18.8",
89
+ "@unchainedshop/api": "^2.5.7",
90
+ "@unchainedshop/core-delivery": "^2.5.7",
91
+ "@unchainedshop/core-enrollments": "^2.5.7",
92
+ "@unchainedshop/core-filters": "^2.5.7",
93
+ "@unchainedshop/core-messaging": "^2.5.7",
94
+ "@unchainedshop/core-orders": "^2.5.7",
95
+ "@unchainedshop/core-payment": "^2.5.7",
96
+ "@unchainedshop/core-products": "^2.5.7",
97
+ "@unchainedshop/core-quotations": "^2.5.7",
98
+ "@unchainedshop/core-warehousing": "^2.5.7",
99
+ "@unchainedshop/core-worker": "^2.5.7",
100
+ "@unchainedshop/events": "^2.5.7",
101
+ "@unchainedshop/file-upload": "^2.5.7",
102
+ "@unchainedshop/logger": "^2.5.7",
103
+ "@unchainedshop/types": "^2.5.7",
104
+ "@unchainedshop/utils": "^2.5.7",
105
105
  "bluebird": "^3.7.2",
106
106
  "event-iterator": "^2.0.0",
107
107
  "express": "^4.18.2",
108
108
  "jest": "^29.7.0",
109
109
  "JSONStream": "^1.3.5",
110
110
  "minio": "^7.1.3",
111
- "mongodb": "^5.9.0",
111
+ "mongodb": "^5.9.1",
112
112
  "node-sheets": "^1.2.0",
113
- "nodemailer": "^6.9.5",
113
+ "nodemailer": "^6.9.7",
114
114
  "open": "^9.1.0",
115
- "postfinancecheckout": "^4.1.1",
115
+ "postfinancecheckout": "^4.2.0",
116
116
  "request": "^2.88.2",
117
117
  "ts-jest": "^29.1.1",
118
118
  "typescript": "^5.2.2",
@@ -65,7 +65,7 @@ const Cryptopay: IPaymentAdapter = {
65
65
  const targetCurrencyObj = await modules.currencies.findCurrency({
66
66
  isoCode: addressData.currency,
67
67
  });
68
- if (!targetCurrencyObj.isActive) return null;
68
+ if (!targetCurrencyObj?.isActive) return null;
69
69
  const rateData = await modules.products.prices.rates.getRate(
70
70
  originCurrencyObj,
71
71
  targetCurrencyObj,
@@ -171,7 +171,7 @@ const Cryptopay: IPaymentAdapter = {
171
171
  // we neuter for security reasons, it's still quite complicated for most ethereum clients to show an appropriate
172
172
  // xpub, that's why
173
173
  const hdWallet = ethers.HDNodeWallet.fromExtendedKey(CRYPTOPAY_ETH_XPUB);
174
- const hardenedMaster = (hdWallet as HDNodeWallet)?.neuter() || (hdWallet as HDNodeVoidWallet);
174
+ const hardenedMaster = 'neuter' in hdWallet ? hdWallet.neuter() : hdWallet;
175
175
 
176
176
  const ethDerivationNumber = await modules.cryptopay.getNextDerivationNumber(
177
177
  CryptopayCurrencies.ETH,
@@ -10,7 +10,7 @@ const {
10
10
  DATATRANS_SECURITY = Security.DYNAMIC_SIGN,
11
11
  } = process.env;
12
12
 
13
- const logger = createLogger('unchained:core-payment:datatrans');
13
+ const logger = createLogger('unchained:core-payment:datatrans:webhook');
14
14
 
15
15
  export const datatransHandler = async (req, res) => {
16
16
  const resolvedContext = req.unchainedContext as Context;
@@ -27,7 +27,7 @@ export const datatransHandler = async (req, res) => {
27
27
  })(timestamp, req.body);
28
28
 
29
29
  if (hash !== comparableSignature) {
30
- logger.error(`Datatrans Plugin: Hash mismatch: ${signature} / ${comparableSignature}`, req.body);
30
+ logger.error(`hash mismatch: ${signature} / ${comparableSignature}`, req.body);
31
31
  res.writeHead(403);
32
32
  res.end('Hash mismatch');
33
33
  return;
@@ -35,6 +35,10 @@ export const datatransHandler = async (req, res) => {
35
35
 
36
36
  const transaction: StatusResponseSuccess = JSON.parse(req.body) as StatusResponseSuccess;
37
37
 
38
+ logger.verbose(`received request`, {
39
+ type: transaction.type,
40
+ });
41
+
38
42
  if (transaction.status === 'authorized') {
39
43
  const userId = transaction.refno2;
40
44
  const referenceId = Buffer.from(transaction.refno, 'base64').toString('hex');
@@ -47,7 +51,7 @@ export const datatransHandler = async (req, res) => {
47
51
  { userId, transactionContext: { transactionId: transaction.transactionId } },
48
52
  { ...resolvedContext },
49
53
  );
50
- logger.info(`Datatrans Webhook: Unchained registered payment credentials for ${userId}`, {
54
+ logger.info(`registered payment credentials for ${userId}`, {
51
55
  userId,
52
56
  });
53
57
  res.writeHead(200);
@@ -67,14 +71,14 @@ export const datatransHandler = async (req, res) => {
67
71
  resolvedContext,
68
72
  );
69
73
  res.writeHead(200);
70
- logger.info(`Datatrans Webhook: Unchained confirmed checkout for order ${order.orderNumber}`, {
74
+ logger.info(`confirmed checkout for order ${order.orderNumber}`, {
71
75
  orderId: order._id,
72
76
  });
73
77
  res.end(JSON.stringify(order));
74
78
  return;
75
79
  }
76
80
  } catch (e) {
77
- logger.error(`Datatrans Webhook: Unchained rejected to checkout with message`, e);
81
+ logger.error(`rejected to checkout with message`, e);
78
82
  res.writeHead(500);
79
83
  res.end(JSON.stringify({ name: e.name, code: e.code, message: e.message }));
80
84
  return;
@@ -0,0 +1,145 @@
1
+ import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
2
+ import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
3
+ import { createLogger } from '@unchainedshop/logger';
4
+ import stripe, { createOrderPaymentIntent, createRegistrationIntent } from './stripe.js';
5
+
6
+ export * from './middleware.js';
7
+
8
+ const logger = createLogger('unchained:core-payment:stripe');
9
+
10
+ const Stripe: IPaymentAdapter = {
11
+ ...PaymentAdapter,
12
+
13
+ key: 'shop.unchained.payment.stripe',
14
+ label: 'Stripe',
15
+ version: '2.0.0',
16
+
17
+ typeSupported(type) {
18
+ return type === 'GENERIC';
19
+ },
20
+
21
+ actions: (params) => {
22
+ const { modules } = params.context;
23
+
24
+ const adapterActions = {
25
+ ...PaymentAdapter.actions(params),
26
+
27
+ configurationError() {
28
+ if (!stripe) {
29
+ return PaymentError.INCOMPLETE_CONFIGURATION;
30
+ }
31
+ return null;
32
+ },
33
+
34
+ isActive: () => {
35
+ if (adapterActions.configurationError() === null) return true;
36
+ return false;
37
+ },
38
+
39
+ isPayLaterAllowed() {
40
+ return false;
41
+ },
42
+
43
+ validate: async ({ token }) => {
44
+ const paymentMethod = await stripe.paymentMethods.retrieve(token);
45
+ return !!paymentMethod;
46
+ },
47
+
48
+ register: async ({ setupIntentId }) => {
49
+ if (!setupIntentId) {
50
+ throw new Error('You have to provide a setupIntentId');
51
+ }
52
+
53
+ const setupIntent = await stripe.setupIntents.retrieve(setupIntentId);
54
+ if (setupIntent.status === 'succeeded') {
55
+ return {
56
+ token: setupIntent.payment_method,
57
+ customer: setupIntent.customer,
58
+ // payment_method_options: setupIntent.payment_method_options,
59
+ payment_method_types: setupIntent.payment_method_types,
60
+ usage: setupIntent.usage,
61
+ };
62
+ }
63
+
64
+ logger.warn('Registration declined', setupIntentId);
65
+ return null;
66
+ },
67
+
68
+ sign: async (transactionContext = {}) => {
69
+ const { orderPayment, order, paymentProviderId } = params.paymentContext;
70
+
71
+ if (orderPayment) {
72
+ const pricing = await modules.orders.pricingSheet(order);
73
+ const paymentIntent = await createOrderPaymentIntent(
74
+ { order, orderPayment, pricing },
75
+ transactionContext,
76
+ );
77
+ return paymentIntent.client_secret;
78
+ }
79
+
80
+ const userId = order?.userId || params.paymentContext?.userId;
81
+ const user = await modules.users.findUserById(userId);
82
+ const email = modules.users.primaryEmail(user)?.address;
83
+ const name = user.profile.displayName || user.username || email;
84
+
85
+ const paymentIntent = await createRegistrationIntent(
86
+ { userId, name, email, paymentProviderId },
87
+ transactionContext,
88
+ );
89
+ return paymentIntent.client_secret;
90
+ },
91
+
92
+ charge: async ({ paymentIntentId, paymentCredentials }) => {
93
+ if (!paymentIntentId && !paymentCredentials) {
94
+ throw new Error('You have to provide paymentIntentId or paymentCredentials');
95
+ }
96
+
97
+ const { order } = params.paymentContext;
98
+ const orderPayment = await modules.orders.payments.findOrderPayment({
99
+ orderPaymentId: order.paymentId,
100
+ });
101
+
102
+ const pricing = await modules.orders.pricingSheet(order);
103
+
104
+ const paymentIntentObject = paymentIntentId
105
+ ? await stripe.paymentIntents.retrieve(paymentIntentId)
106
+ : await createOrderPaymentIntent(
107
+ { orderPayment, order, pricing },
108
+ {
109
+ customer: paymentCredentials.meta?.customer,
110
+ confirm: true,
111
+ payment_method: paymentCredentials.token,
112
+ payment_method_types: paymentCredentials.meta?.payment_method_types, // eslint-disable-line
113
+ // payment_method_options: paymentCredentials.meta?.payment_method_options, // eslint-disable-line
114
+ },
115
+ );
116
+
117
+ const { currency, amount } = pricing.total({ useNetPrice: false });
118
+
119
+ if (
120
+ paymentIntentObject.currency !== currency.toLowerCase() ||
121
+ paymentIntentObject.amount !== Math.round(amount)
122
+ ) {
123
+ throw new Error('The price has changed since the intent has been created');
124
+ }
125
+ if (paymentIntentObject.metadata?.orderPaymentId !== orderPayment?._id) {
126
+ throw new Error('The order payment is different from the initiating intent');
127
+ }
128
+
129
+ if (paymentIntentObject.status === 'succeeded') {
130
+ return paymentIntentObject;
131
+ }
132
+
133
+ logger.verbose('Charge postponed because paymentIntent has wrong status', {
134
+ orderPaymentId: paymentIntentObject.id,
135
+ });
136
+
137
+ return false;
138
+ },
139
+ };
140
+
141
+ return adapterActions;
142
+ },
143
+ };
144
+
145
+ PaymentDirector.registerAdapter(Stripe);
@@ -0,0 +1,132 @@
1
+ import { Context } from '@unchainedshop/types/api.js';
2
+ import { createLogger } from '@unchainedshop/logger';
3
+ import stripe from './stripe.js';
4
+
5
+ const logger = createLogger('unchained:core-payment:stripe:webhook');
6
+
7
+ const { STRIPE_ENDPOINT_SECRET, STRIPE_WEBHOOK_ENVIRONMENT } = process.env;
8
+
9
+ function checkEnvironment(metadata: any) {
10
+ const environmentInMetadata = metadata?.environment;
11
+ const environmentInEnv = STRIPE_WEBHOOK_ENVIRONMENT;
12
+
13
+ if (!environmentInMetadata && !environmentInEnv) {
14
+ return true;
15
+ }
16
+
17
+ return environmentInEnv === environmentInMetadata;
18
+ }
19
+
20
+ export const stripeHandler = async (request, response) => {
21
+ const resolvedContext = request.unchainedContext as Context;
22
+ const { modules } = resolvedContext;
23
+
24
+ let event;
25
+
26
+ try {
27
+ const sig = request.headers['stripe-signature'];
28
+ event = stripe.webhooks.constructEvent(request.body, sig, STRIPE_ENDPOINT_SECRET);
29
+ logger.verbose(`received event`, {
30
+ type: event.type,
31
+ });
32
+ } catch (err) {
33
+ logger.error(`failed event validation with: ${err.message}`);
34
+ response.writeHead(400);
35
+ response.end(err.message);
36
+ return;
37
+ }
38
+
39
+ try {
40
+ if (event.type === 'payment_intent.succeeded') {
41
+ const paymentIntent = event.data.object;
42
+ const { orderPaymentId } = paymentIntent.metadata || {};
43
+
44
+ if (!checkEnvironment(paymentIntent.metadata)) {
45
+ logger.verbose(`event ignored because of environment difference`, {
46
+ type: event.type,
47
+ });
48
+ response.end(JSON.stringify({ received: true, ignored: true }));
49
+ return;
50
+ }
51
+
52
+ logger.verbose(`checkout with orderPaymentId: ${orderPaymentId}`, {
53
+ type: event.type,
54
+ });
55
+
56
+ await modules.orders.payments.logEvent(orderPaymentId, event);
57
+ const orderPayment = await modules.orders.payments.findOrderPayment({
58
+ orderPaymentId,
59
+ });
60
+
61
+ if (!orderPayment) {
62
+ throw new Error(`order payment not found with orderPaymentId: ${orderPaymentId}`);
63
+ }
64
+
65
+ const order = await modules.orders.checkout(
66
+ orderPayment.orderId,
67
+ {
68
+ transactionContext: {
69
+ paymentIntentId: paymentIntent.id,
70
+ },
71
+ paymentContext: {
72
+ paymentIntentId: paymentIntent.id,
73
+ },
74
+ },
75
+ resolvedContext,
76
+ );
77
+
78
+ logger.info(`confirmed checkout for order: ${order._id}`, {
79
+ orderId: order._id,
80
+ type: event.type,
81
+ });
82
+ } else if (event.type === 'setup_intent.succeeded') {
83
+ const setupIntent = event.data.object;
84
+ const { paymentProviderId, userId } = setupIntent.metadata || {};
85
+
86
+ if (!checkEnvironment(setupIntent.metadata)) {
87
+ response.end(JSON.stringify({ received: true, ignored: true }));
88
+ return;
89
+ }
90
+
91
+ logger.verbose(`registered payment credential with paymentProviderId: ${paymentProviderId}`, {
92
+ type: event.type,
93
+ userId,
94
+ });
95
+
96
+ await modules.payment.registerCredentials(
97
+ paymentProviderId,
98
+ {
99
+ transactionContext: {
100
+ setupIntentId: setupIntent.id,
101
+ },
102
+ userId,
103
+ },
104
+ resolvedContext,
105
+ );
106
+
107
+ logger.info(`registered payment credentials with paymentProviderId: ${paymentProviderId}`, {
108
+ userId,
109
+ type: event.type,
110
+ });
111
+ } else {
112
+ logger.verbose(`unhandled type`, {
113
+ type: event.type,
114
+ });
115
+ response.writeHead(404);
116
+ response.end();
117
+ return;
118
+ }
119
+ } catch (err) {
120
+ logger.error(`failed with: ${err.message}`, {
121
+ type: event.type,
122
+ });
123
+ response.writeHead(400);
124
+ response.end(err.message || 'Error');
125
+ return;
126
+ }
127
+ // Return a 200 response to acknowledge receipt of the event
128
+ logger.verbose(`event processed`, {
129
+ type: event.type,
130
+ });
131
+ response.end(JSON.stringify({ received: true }));
132
+ };
@@ -0,0 +1,8 @@
1
+ ## Test Webhooks:
2
+
3
+ ```
4
+ brew install stripe/stripe-cli/stripe
5
+ stripe login --api-key sk_....
6
+ stripe listen --forward-to http://localhost:4010/payment/stripe
7
+ stripe trigger payment_intent.succeeded
8
+ ```
@@ -0,0 +1,53 @@
1
+ import Stripe from 'stripe';
2
+
3
+ const { STRIPE_SECRET, STRIPE_WEBHOOK_ENVIRONMENT, EMAIL_WEBSITE_NAME } = process.env;
4
+
5
+ const stripe = new Stripe(STRIPE_SECRET, {
6
+ apiVersion: '2023-08-16',
7
+ });
8
+
9
+ export default stripe;
10
+
11
+ export const createRegistrationIntent = async (
12
+ { userId, name, email, paymentProviderId },
13
+ options = {},
14
+ ) => {
15
+ const customer = await stripe.customers.create({
16
+ metadata: {
17
+ userId,
18
+ environment: STRIPE_WEBHOOK_ENVIRONMENT ?? null,
19
+ },
20
+ name,
21
+ email,
22
+ });
23
+ const setupIntent = await stripe.setupIntents.create({
24
+ customer: customer.id,
25
+ metadata: {
26
+ userId,
27
+ paymentProviderId,
28
+ environment: STRIPE_WEBHOOK_ENVIRONMENT ?? null,
29
+ },
30
+ ...options,
31
+ });
32
+ return setupIntent;
33
+ };
34
+
35
+ export const createOrderPaymentIntent = async ({ order, orderPayment, pricing }, options = {}) => {
36
+ const reference = EMAIL_WEBSITE_NAME || order._id;
37
+ const { currency, amount } = pricing.total({ useNetPrice: false });
38
+ const paymentIntent = await stripe.paymentIntents.create({
39
+ amount: Math.round(amount),
40
+ currency: currency.toLowerCase(),
41
+ description: `${reference} #${order.orderNumber}`,
42
+ statement_descriptor: order.orderNumber,
43
+ statement_descriptor_suffix: reference,
44
+ receipt_email: order.contact?.emailAddress,
45
+ setup_future_usage: 'off_session', // Verify your integration in this guide by including this parameter
46
+ metadata: {
47
+ orderPaymentId: orderPayment._id,
48
+ environment: STRIPE_WEBHOOK_ENVIRONMENT ?? null,
49
+ },
50
+ ...options,
51
+ });
52
+ return paymentIntent;
53
+ };
@@ -16,7 +16,7 @@ import './payment/worldline-saferpay/index.js';
16
16
  import { datatransHandler } from './payment/datatrans-v2/index.js';
17
17
  import { configureCryptopayModule, cryptopayHandler } from './payment/cryptopay/index.js';
18
18
  import { appleIAPHandler, configureAppleTransactionsModule } from './payment/apple-iap/index.js';
19
- import { stripeHandler } from './payment/stripe.js';
19
+ import { stripeHandler } from './payment/stripe/index.js';
20
20
  import { postfinanceCheckoutHandler } from './payment/postfinance-checkout/index.js';
21
21
 
22
22
  // Warehousing
@@ -1,6 +1,6 @@
1
- import fs from 'fs';
1
+ import { mkdtemp, writeFile } from 'fs/promises';
2
2
  import { join, isAbsolute } from 'path';
3
- import os from 'os';
3
+ import { tmpdir } from 'os';
4
4
  import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core-worker';
5
5
  import { createLogger } from '@unchainedshop/logger';
6
6
  import { IWorkerAdapter } from '@unchainedshop/types/worker.js';
@@ -26,20 +26,17 @@ const buildLink = ({ filename, content, href, contentType, encoding, path }) =>
26
26
  return '';
27
27
  };
28
28
 
29
- function writeFile(filename, data, done) {
30
- fs.mkdtemp(join(os.tmpdir(), 'email-'), (err1, folder) => {
31
- if (err1) return done(err1);
32
- const temporaryFolderPath = `${folder}/${filename}`;
33
- return fs.writeFile(temporaryFolderPath, data, (err2) => {
34
- if (err2) return done(err2);
35
- return done(null, temporaryFolderPath);
36
- });
37
- });
38
- }
39
-
40
- const openInBrowser = (options) => {
29
+ const openInBrowser = async (options) => {
41
30
  const filename = `${Date.now()}.html`;
31
+ const messageBody = options.html || options.text.replace(/(\r\n|\n|\r)/gm, '<br/>');
42
32
  const content = `
33
+ <!DOCTYPE html>
34
+ <html lang="en" xmlns="https://www.w3.org/1999/xhtml" xmlns:o="urn:schemas-microsoft-com:office:office">
35
+ <head>
36
+ <meta charset="UTF-8"/>
37
+ <meta name="viewport" content="width=device-width,initial-scale=1">
38
+ </head>
39
+ <body>
43
40
  <b>From:&nbsp</b>${options.from}<br/>
44
41
  <b>To:&nbsp;</b>${options.to}<br/>
45
42
  <b>Cc:&nbsp;</b>${options.cc}<br/>
@@ -49,16 +46,14 @@ const openInBrowser = (options) => {
49
46
  <b>subject:&nbsp;</b>${options.subject}<br/>
50
47
  <b>attachments:&nbsp;</b>${(options.attachments || []).map(buildLink).join(',&nbsp;')}<br/>
51
48
  <hr/>
52
- ${(options.html || options.text).replace(/(\r\n|\n|\r)/gm, '<br/>')}
53
- `;
54
- writeFile(filename, content, (err, filePath) => {
55
- if (err) {
56
- logger.error(err);
57
- return;
58
- }
59
- logger.verbose('unchained:platform -> Mailman detected an outgoing email');
60
- open(filePath);
61
- });
49
+ ${messageBody}
50
+ </body>
51
+ </html>`;
52
+
53
+ const folder = await mkdtemp(join(tmpdir(), 'email-'));
54
+ const fileName = `${folder}/${filename}`;
55
+ await writeFile(fileName, content);
56
+ return open(fileName);
62
57
  };
63
58
 
64
59
  const EmailWorkerPlugin: IWorkerAdapter<
@@ -98,7 +93,8 @@ const EmailWorkerPlugin: IWorkerAdapter<
98
93
  ...rest,
99
94
  };
100
95
  if (checkEmailInterceptionEnabled()) {
101
- openInBrowser(sendMailOptions);
96
+ logger.verbose('unchained:platform -> Mailman detected an outgoing email');
97
+ await openInBrowser(sendMailOptions);
102
98
  return { success: true, result: { intercepted: true } };
103
99
  }
104
100
  if (!process.env.MAIL_URL) {
@@ -1 +0,0 @@
1
- {"version":3,"file":"stripe.js","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