@unchainedshop/plugins 2.5.6 → 2.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/payment/cryptopay/module/configureCryptopayModule.js +7 -7
- package/lib/payment/cryptopay/module/configureCryptopayModule.js.map +1 -1
- package/lib/payment/cryptopay/plugin.js +2 -2
- package/lib/payment/cryptopay/plugin.js.map +1 -1
- package/lib/worker/email.js +20 -26
- package/lib/worker/email.js.map +1 -1
- package/package.json +23 -23
- package/src/payment/cryptopay/module/configureCryptopayModule.ts +7 -7
- package/src/payment/cryptopay/plugin.ts +2 -2
- package/src/worker/email.ts +21 -25
|
@@ -3,7 +3,7 @@ import { CryptopayTransactionsCollection } from '../db/CryptopayTransactions.js'
|
|
|
3
3
|
export const configureCryptopayModule = ({ db }) => {
|
|
4
4
|
const CryptoTransactions = CryptopayTransactionsCollection(db);
|
|
5
5
|
const getWalletAddress = async (addressId) => {
|
|
6
|
-
return CryptoTransactions.findOne({ _id: addressId });
|
|
6
|
+
return CryptoTransactions.findOne({ _id: addressId.toLowerCase() });
|
|
7
7
|
};
|
|
8
8
|
const updateMostRecentBlock = async (currency, blockHeight) => {
|
|
9
9
|
await CryptoTransactions.updateMany({
|
|
@@ -16,10 +16,10 @@ export const configureCryptopayModule = ({ db }) => {
|
|
|
16
16
|
};
|
|
17
17
|
const mapOrderPaymentToWalletAddress = async ({ addressId, contract, currency, orderPaymentId, }) => {
|
|
18
18
|
await CryptoTransactions.updateOne({
|
|
19
|
-
_id: addressId,
|
|
19
|
+
_id: addressId.toLowerCase(),
|
|
20
20
|
}, {
|
|
21
21
|
$setOnInsert: {
|
|
22
|
-
_id: addressId,
|
|
22
|
+
_id: addressId.toLowerCase(),
|
|
23
23
|
contract,
|
|
24
24
|
currency,
|
|
25
25
|
decimals: null,
|
|
@@ -33,7 +33,7 @@ export const configureCryptopayModule = ({ db }) => {
|
|
|
33
33
|
updated: new Date(),
|
|
34
34
|
},
|
|
35
35
|
}, { upsert: true });
|
|
36
|
-
return CryptoTransactions.findOne({ _id: addressId });
|
|
36
|
+
return CryptoTransactions.findOne({ _id: addressId.toLowerCase() });
|
|
37
37
|
};
|
|
38
38
|
const getNextDerivationNumber = async (currency) => {
|
|
39
39
|
return (await CryptoTransactions.countDocuments({ currency })) + 1;
|
|
@@ -45,10 +45,10 @@ export const configureCryptopayModule = ({ db }) => {
|
|
|
45
45
|
};
|
|
46
46
|
const updateWalletAddress = async ({ addressId, blockHeight, amount, contract, currency, decimals, }) => {
|
|
47
47
|
await CryptoTransactions.updateOne({
|
|
48
|
-
_id: addressId,
|
|
48
|
+
_id: addressId.toLowerCase(),
|
|
49
49
|
}, {
|
|
50
50
|
$setOnInsert: {
|
|
51
|
-
_id: addressId,
|
|
51
|
+
_id: addressId.toLowerCase(),
|
|
52
52
|
currency,
|
|
53
53
|
contract,
|
|
54
54
|
created: new Date(),
|
|
@@ -61,7 +61,7 @@ export const configureCryptopayModule = ({ db }) => {
|
|
|
61
61
|
updated: new Date(),
|
|
62
62
|
},
|
|
63
63
|
}, { upsert: true });
|
|
64
|
-
return CryptoTransactions.findOne({ _id: addressId });
|
|
64
|
+
return CryptoTransactions.findOne({ _id: addressId.toLowerCase() });
|
|
65
65
|
};
|
|
66
66
|
return {
|
|
67
67
|
getWalletAddress,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureCryptopayModule.js","sourceRoot":"","sources":["../../../../src/payment/cryptopay/module/configureCryptopayModule.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAwB,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAuBvG,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EAAE,EAAE,EAAc,EAAmB,EAAE;IAC9E,MAAM,kBAAkB,GAAG,+BAA+B,CAAC,EAAE,CAAC,CAAC;IAE/D,MAAM,gBAAgB,GAAwC,KAAK,EAAE,SAAS,EAAE,EAAE;QAChF,OAAO,kBAAkB,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"configureCryptopayModule.js","sourceRoot":"","sources":["../../../../src/payment/cryptopay/module/configureCryptopayModule.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAwB,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAuBvG,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EAAE,EAAE,EAAc,EAAmB,EAAE;IAC9E,MAAM,kBAAkB,GAAG,+BAA+B,CAAC,EAAE,CAAC,CAAC;IAE/D,MAAM,gBAAgB,GAAwC,KAAK,EAAE,SAAS,EAAE,EAAE;QAChF,OAAO,kBAAkB,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC;IAEF,MAAM,qBAAqB,GAA6C,KAAK,EAC3E,QAAQ,EACR,WAAW,EACX,EAAE;QACF,MAAM,kBAAkB,CAAC,UAAU,CACjC;YACE,QAAQ;SACT,EACD;YACE,IAAI,EAAE;gBACJ,qBAAqB,EAAE,WAAW;aACnC;SACF,CACF,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,8BAA8B,GAAsD,KAAK,EAAE,EAC/F,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,cAAc,GACf,EAAE,EAAE;QACH,MAAM,kBAAkB,CAAC,SAAS,CAChC;YACE,GAAG,EAAE,SAAS,CAAC,WAAW,EAAE;SAC7B,EACD;YACE,YAAY,EAAE;gBACZ,GAAG,EAAE,SAAS,CAAC,WAAW,EAAE;gBAC5B,QAAQ;gBACR,QAAQ;gBACR,QAAQ,EAAE,IAAI;gBACd,qBAAqB,EAAE,CAAC;gBACxB,WAAW,EAAE,CAAC;gBACd,MAAM,EAAE,UAAU,CAAC,UAAU,CAA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OAAO,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC;IAEF,OAAO;QACL,gBAAgB;QAChB,qBAAqB;QACrB,mBAAmB;QACnB,8BAA8B;QAC9B,uBAAuB;QACvB,kCAAkC;KACnC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -40,7 +40,7 @@ const Cryptopay = {
|
|
|
40
40
|
const targetCurrencyObj = await modules.currencies.findCurrency({
|
|
41
41
|
isoCode: addressData.currency,
|
|
42
42
|
});
|
|
43
|
-
if (!targetCurrencyObj
|
|
43
|
+
if (!targetCurrencyObj?.isActive)
|
|
44
44
|
return null;
|
|
45
45
|
const rateData = await modules.products.prices.rates.getRate(originCurrencyObj, targetCurrencyObj);
|
|
46
46
|
return {
|
|
@@ -120,7 +120,7 @@ const Cryptopay = {
|
|
|
120
120
|
// we neuter for security reasons, it's still quite complicated for most ethereum clients to show an appropriate
|
|
121
121
|
// xpub, that's why
|
|
122
122
|
const hdWallet = ethers.HDNodeWallet.fromExtendedKey(CRYPTOPAY_ETH_XPUB);
|
|
123
|
-
const hardenedMaster = hdWallet
|
|
123
|
+
const hardenedMaster = 'neuter' in hdWallet ? hdWallet.neuter() : hdWallet;
|
|
124
124
|
const ethDerivationNumber = await modules.cryptopay.getNextDerivationNumber(CryptopayCurrencies.ETH);
|
|
125
125
|
const derivationPath = getDerivationPath(CryptopayCurrencies.ETH, ethDerivationNumber);
|
|
126
126
|
const cleanedForHD = derivationPath.split('/').slice(-2).join('/');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/payment/cryptopay/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EAAkC,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,OAA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T,4BAA4B,qBAAqB,CAAC,GAAG,2BAA2B,eAAe,MAAM,WAAW,EAAE,CACnH,CAAC;iBACH;gBAED,MAAM,CAAC,IAAI,CACT,8DACE,KAAK,CAAC,QACR,kBAAkB,IAAI,CAAC,SAAS,CAAC,wBAAwB,CAAC,EAAE,CAC7D,CAAC;gBAEF;;;;;;;;;;;;;;;;;kBAiBE;gBAEF,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;QAEF,OAAO,cAAc,CAAC;IACxB,CAAC;CACF,CAAC;AAEF,eAAe,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;AAE3C,eAAe,SAAS,CAAC"}
|
package/lib/worker/email.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { mkdtemp, writeFile } from 'fs/promises';
|
|
2
2
|
import { join, isAbsolute } from 'path';
|
|
3
|
-
import
|
|
3
|
+
import { tmpdir } from 'os';
|
|
4
4
|
import { WorkerDirector, WorkerAdapter } from '@unchainedshop/core-worker';
|
|
5
5
|
import { createLogger } from '@unchainedshop/logger';
|
|
6
6
|
import open from 'open';
|
|
@@ -21,21 +21,17 @@ const buildLink = ({ filename, content, href, contentType, encoding, path }) =>
|
|
|
21
21
|
}
|
|
22
22
|
return '';
|
|
23
23
|
};
|
|
24
|
-
|
|
25
|
-
fs.mkdtemp(join(os.tmpdir(), 'email-'), (err1, folder) => {
|
|
26
|
-
if (err1)
|
|
27
|
-
return done(err1);
|
|
28
|
-
const temporaryFolderPath = `${folder}/${filename}`;
|
|
29
|
-
return fs.writeFile(temporaryFolderPath, data, (err2) => {
|
|
30
|
-
if (err2)
|
|
31
|
-
return done(err2);
|
|
32
|
-
return done(null, temporaryFolderPath);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
const openInBrowser = (options) => {
|
|
24
|
+
const openInBrowser = async (options) => {
|
|
37
25
|
const filename = `${Date.now()}.html`;
|
|
26
|
+
const messageBody = options.html || options.text.replace(/(\r\n|\n|\r)/gm, '<br/>');
|
|
38
27
|
const content = `
|
|
28
|
+
<!DOCTYPE html>
|
|
29
|
+
<html lang="en" xmlns="https://www.w3.org/1999/xhtml" xmlns:o="urn:schemas-microsoft-com:office:office">
|
|
30
|
+
<head>
|
|
31
|
+
<meta charset="UTF-8"/>
|
|
32
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
33
|
+
</head>
|
|
34
|
+
<body>
|
|
39
35
|
<b>From: </b>${options.from}<br/>
|
|
40
36
|
<b>To: </b>${options.to}<br/>
|
|
41
37
|
<b>Cc: </b>${options.cc}<br/>
|
|
@@ -45,16 +41,13 @@ const openInBrowser = (options) => {
|
|
|
45
41
|
<b>subject: </b>${options.subject}<br/>
|
|
46
42
|
<b>attachments: </b>${(options.attachments || []).map(buildLink).join(', ')}<br/>
|
|
47
43
|
<hr/>
|
|
48
|
-
${
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
logger.verbose('unchained:platform -> Mailman detected an outgoing email');
|
|
56
|
-
open(filePath);
|
|
57
|
-
});
|
|
44
|
+
${messageBody}
|
|
45
|
+
</body>
|
|
46
|
+
</html>`;
|
|
47
|
+
const folder = await mkdtemp(join(tmpdir(), 'email-'));
|
|
48
|
+
const fileName = `${folder}/${filename}`;
|
|
49
|
+
await writeFile(fileName, content);
|
|
50
|
+
return open(fileName);
|
|
58
51
|
};
|
|
59
52
|
const EmailWorkerPlugin = {
|
|
60
53
|
...WorkerAdapter,
|
|
@@ -81,7 +74,8 @@ const EmailWorkerPlugin = {
|
|
|
81
74
|
...rest,
|
|
82
75
|
};
|
|
83
76
|
if (checkEmailInterceptionEnabled()) {
|
|
84
|
-
|
|
77
|
+
logger.verbose('unchained:platform -> Mailman detected an outgoing email');
|
|
78
|
+
await openInBrowser(sendMailOptions);
|
|
85
79
|
return { success: true, result: { intercepted: true } };
|
|
86
80
|
}
|
|
87
81
|
if (!process.env.MAIL_URL) {
|
package/lib/worker/email.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../src/worker/email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../src/worker/email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,MAAM,MAAM,GAAG,YAAY,CAAC,gCAAgC,CAAC,CAAC;AAE9D,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,EAAE;IAChD,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC;AACpG,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE;IAC7E,IAAI,IAAI,EAAE;QACR,OAAO,YAAY,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,KAAK,QAAQ,MAAM,CAAC;KAC3F;IACD,IAAI,IAAI,EAAE;QACR,OAAO,YAAY,IAAI,KAAK,QAAQ,MAAM,CAAC;KAC5C;IACD,IAAI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ACF,CAAC;SACH;IACH,CAAC;CACF,CAAC;AAEF,cAAc,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/plugins",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.8",
|
|
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.
|
|
78
|
+
"ethers": "^6.8.1",
|
|
79
79
|
"express": "^4.18.2",
|
|
80
80
|
"mongodb": "^5.9.0",
|
|
81
81
|
"postfinancecheckout": "^4.1.1",
|
|
82
|
-
"stripe": "^13.
|
|
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.
|
|
89
|
-
"@unchainedshop/api": "^2.5.
|
|
90
|
-
"@unchainedshop/core-delivery": "^2.5.
|
|
91
|
-
"@unchainedshop/core-enrollments": "^2.5.
|
|
92
|
-
"@unchainedshop/core-filters": "^2.5.
|
|
93
|
-
"@unchainedshop/core-messaging": "^2.5.
|
|
94
|
-
"@unchainedshop/core-orders": "^2.5.
|
|
95
|
-
"@unchainedshop/core-payment": "^2.5.
|
|
96
|
-
"@unchainedshop/core-products": "^2.5.
|
|
97
|
-
"@unchainedshop/core-quotations": "^2.5.
|
|
98
|
-
"@unchainedshop/core-warehousing": "^2.5.
|
|
99
|
-
"@unchainedshop/core-worker": "^2.5.
|
|
100
|
-
"@unchainedshop/events": "^2.5.
|
|
101
|
-
"@unchainedshop/file-upload": "^2.5.
|
|
102
|
-
"@unchainedshop/logger": "^2.5.
|
|
103
|
-
"@unchainedshop/types": "^2.5.
|
|
104
|
-
"@unchainedshop/utils": "^2.5.
|
|
88
|
+
"@types/node": "^18.18.8",
|
|
89
|
+
"@unchainedshop/api": "^2.5.8",
|
|
90
|
+
"@unchainedshop/core-delivery": "^2.5.8",
|
|
91
|
+
"@unchainedshop/core-enrollments": "^2.5.8",
|
|
92
|
+
"@unchainedshop/core-filters": "^2.5.8",
|
|
93
|
+
"@unchainedshop/core-messaging": "^2.5.8",
|
|
94
|
+
"@unchainedshop/core-orders": "^2.5.8",
|
|
95
|
+
"@unchainedshop/core-payment": "^2.5.8",
|
|
96
|
+
"@unchainedshop/core-products": "^2.5.8",
|
|
97
|
+
"@unchainedshop/core-quotations": "^2.5.8",
|
|
98
|
+
"@unchainedshop/core-warehousing": "^2.5.8",
|
|
99
|
+
"@unchainedshop/core-worker": "^2.5.8",
|
|
100
|
+
"@unchainedshop/events": "^2.5.8",
|
|
101
|
+
"@unchainedshop/file-upload": "^2.5.8",
|
|
102
|
+
"@unchainedshop/logger": "^2.5.8",
|
|
103
|
+
"@unchainedshop/types": "^2.5.8",
|
|
104
|
+
"@unchainedshop/utils": "^2.5.8",
|
|
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.
|
|
111
|
+
"mongodb": "^5.9.1",
|
|
112
112
|
"node-sheets": "^1.2.0",
|
|
113
|
-
"nodemailer": "^6.9.
|
|
113
|
+
"nodemailer": "^6.9.7",
|
|
114
114
|
"open": "^9.1.0",
|
|
115
|
-
"postfinancecheckout": "^4.
|
|
115
|
+
"postfinancecheckout": "^4.2.0",
|
|
116
116
|
"request": "^2.88.2",
|
|
117
117
|
"ts-jest": "^29.1.1",
|
|
118
118
|
"typescript": "^5.2.2",
|
|
@@ -27,7 +27,7 @@ export const configureCryptopayModule = ({ db }: { db: Db }): CryptopayModule =>
|
|
|
27
27
|
const CryptoTransactions = CryptopayTransactionsCollection(db);
|
|
28
28
|
|
|
29
29
|
const getWalletAddress: CryptopayModule['getWalletAddress'] = async (addressId) => {
|
|
30
|
-
return CryptoTransactions.findOne({ _id: addressId });
|
|
30
|
+
return CryptoTransactions.findOne({ _id: addressId.toLowerCase() });
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
const updateMostRecentBlock: CryptopayModule['updateMostRecentBlock'] = async (
|
|
@@ -54,11 +54,11 @@ export const configureCryptopayModule = ({ db }: { db: Db }): CryptopayModule =>
|
|
|
54
54
|
}) => {
|
|
55
55
|
await CryptoTransactions.updateOne(
|
|
56
56
|
{
|
|
57
|
-
_id: addressId,
|
|
57
|
+
_id: addressId.toLowerCase(),
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
$setOnInsert: {
|
|
61
|
-
_id: addressId,
|
|
61
|
+
_id: addressId.toLowerCase(),
|
|
62
62
|
contract,
|
|
63
63
|
currency,
|
|
64
64
|
decimals: null,
|
|
@@ -75,7 +75,7 @@ export const configureCryptopayModule = ({ db }: { db: Db }): CryptopayModule =>
|
|
|
75
75
|
{ upsert: true },
|
|
76
76
|
);
|
|
77
77
|
|
|
78
|
-
return CryptoTransactions.findOne({ _id: addressId });
|
|
78
|
+
return CryptoTransactions.findOne({ _id: addressId.toLowerCase() });
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
const getNextDerivationNumber: CryptopayModule['getNextDerivationNumber'] = async (currency) => {
|
|
@@ -99,11 +99,11 @@ export const configureCryptopayModule = ({ db }: { db: Db }): CryptopayModule =>
|
|
|
99
99
|
}) => {
|
|
100
100
|
await CryptoTransactions.updateOne(
|
|
101
101
|
{
|
|
102
|
-
_id: addressId,
|
|
102
|
+
_id: addressId.toLowerCase(),
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
$setOnInsert: {
|
|
106
|
-
_id: addressId,
|
|
106
|
+
_id: addressId.toLowerCase(),
|
|
107
107
|
currency,
|
|
108
108
|
contract,
|
|
109
109
|
created: new Date(),
|
|
@@ -119,7 +119,7 @@ export const configureCryptopayModule = ({ db }: { db: Db }): CryptopayModule =>
|
|
|
119
119
|
{ upsert: true },
|
|
120
120
|
);
|
|
121
121
|
|
|
122
|
-
return CryptoTransactions.findOne({ _id: addressId });
|
|
122
|
+
return CryptoTransactions.findOne({ _id: addressId.toLowerCase() });
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
return {
|
|
@@ -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
|
|
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 =
|
|
174
|
+
const hardenedMaster = 'neuter' in hdWallet ? hdWallet.neuter() : hdWallet;
|
|
175
175
|
|
|
176
176
|
const ethDerivationNumber = await modules.cryptopay.getNextDerivationNumber(
|
|
177
177
|
CryptopayCurrencies.ETH,
|
package/src/worker/email.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { mkdtemp, writeFile } from 'fs/promises';
|
|
2
2
|
import { join, isAbsolute } from 'path';
|
|
3
|
-
import
|
|
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
|
-
|
|
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: </b>${options.from}<br/>
|
|
44
41
|
<b>To: </b>${options.to}<br/>
|
|
45
42
|
<b>Cc: </b>${options.cc}<br/>
|
|
@@ -49,16 +46,14 @@ const openInBrowser = (options) => {
|
|
|
49
46
|
<b>subject: </b>${options.subject}<br/>
|
|
50
47
|
<b>attachments: </b>${(options.attachments || []).map(buildLink).join(', ')}<br/>
|
|
51
48
|
<hr/>
|
|
52
|
-
${
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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) {
|