@abtnode/blocklet-services 1.16.8-beta-b3039c78 → 1.16.8-beta-56e84f3c
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/api/emails/components/asset.js +4 -1
- package/api/emails/components/attachments.js +3 -3
- package/api/emails/components/footer.js +1 -0
- package/api/emails/components/header.js +1 -1
- package/api/emails/components/layout.js +2 -2
- package/api/emails/components/token.js +5 -2
- package/api/emails/components/transaction.js +4 -8
- package/api/emails/libs/chain.js +15 -0
- package/api/emails/libs/highlight.js +3 -3
- package/api/emails/pages/notification.js +4 -4
- package/api/libs/connect/session.js +7 -3
- package/api/libs/email.js +24 -7
- package/api/services/auth/connect/login.js +2 -2
- package/api/services/auth/connect/switch-passport.js +2 -1
- package/api/services/studio/index.js +12 -2
- package/api/socket/channel/did.js +14 -5
- package/build/asset-manifest.json +5 -5
- package/build/index.html +1 -1
- package/build/static/js/343.4fd3d628.chunk.js +2 -0
- package/build/static/js/main.3b0044ad.js +3 -0
- package/package.json +35 -35
- package/api/emails/test.js +0 -166
- package/api/emails/types.js +0 -2
- package/build/static/js/343.6fc2089d.chunk.js +0 -2
- package/build/static/js/main.94c49b7d.js +0 -3
- /package/build/static/js/{main.94c49b7d.js.LICENSE.txt → main.3b0044ad.js.LICENSE.txt} +0 -0
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
4
|
const components_1 = require("@react-email/components");
|
|
5
|
+
const chain_1 = require("../libs/chain");
|
|
5
6
|
function Asset({ locale, data, }) {
|
|
6
7
|
const title = { zh: '接收', en: 'Received' }[locale] || 'Received';
|
|
7
|
-
|
|
8
|
+
const chainHost = data.chainHost || (0, chain_1.getChainHost)(data.chainId);
|
|
9
|
+
const url = `https://${chainHost}/explorer/assets/${data.did}`;
|
|
10
|
+
return ((0, jsx_runtime_1.jsxs)("a", Object.assign({ href: url, target: "_blank", style: Object.assign(Object.assign({}, assetStyle), { margin: '1em 0', textDecoration: 'none', color: 'initial', display: 'block' }) }, { children: [(0, jsx_runtime_1.jsxs)(components_1.Row, Object.assign({ style: titleStyle }, { children: [(0, jsx_runtime_1.jsx)(components_1.Column, { children: title }), (0, jsx_runtime_1.jsx)(components_1.Column, Object.assign({ align: "right", style: summaryStyle }, { children: "+1 Asset" }))] })), (0, jsx_runtime_1.jsx)(components_1.Text, Object.assign({ style: remarkStyle }, { children: data.did }))] })));
|
|
8
11
|
}
|
|
9
12
|
exports.default = Asset;
|
|
10
13
|
const assetStyle = {
|
|
@@ -32,10 +32,10 @@ function Attachments({ locale, severity = 'normal', attachments = [], }) {
|
|
|
32
32
|
case 'divider':
|
|
33
33
|
return (0, jsx_runtime_1.jsx)(components_1.Hr, {});
|
|
34
34
|
// case 'vc':
|
|
35
|
-
case '
|
|
36
|
-
return (0, jsx_runtime_1.jsx)(asset_1.default, { data:
|
|
35
|
+
case 'asset':
|
|
36
|
+
return (0, jsx_runtime_1.jsx)(asset_1.default, { data: item.data, locale: locale });
|
|
37
37
|
case 'section':
|
|
38
|
-
return (0, jsx_runtime_1.jsx)(compose_1.default, { data: item.
|
|
38
|
+
return (0, jsx_runtime_1.jsx)(compose_1.default, { data: item.fields });
|
|
39
39
|
default:
|
|
40
40
|
return null;
|
|
41
41
|
}
|
|
@@ -15,6 +15,7 @@ const footer = {
|
|
|
15
15
|
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif",
|
|
16
16
|
fontSize: '12px',
|
|
17
17
|
lineHeight: '22px',
|
|
18
|
+
margin: 0,
|
|
18
19
|
};
|
|
19
20
|
const link = {
|
|
20
21
|
color: '#2754C5',
|
|
@@ -15,6 +15,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
15
15
|
const components_1 = require("@react-email/components");
|
|
16
16
|
function Header(_a) {
|
|
17
17
|
var { appInfo } = _a, props = __rest(_a, ["appInfo"]);
|
|
18
|
-
return ((0, jsx_runtime_1.jsx)(components_1.Section, Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(components_1.Img, { src: appInfo.logo, height: "
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(components_1.Section, Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(components_1.Img, { src: appInfo.logo, height: "50", alt: appInfo.title }) })));
|
|
19
19
|
}
|
|
20
20
|
exports.default = Header;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
4
|
const components_1 = require("@react-email/components");
|
|
5
|
-
function Layout({ children, mainStyle = {}, containerStyle = {}, }) {
|
|
6
|
-
return ((0, jsx_runtime_1.jsxs)(components_1.Html, { children: [(0, jsx_runtime_1.jsx)(components_1.Head, { children: (0, jsx_runtime_1.jsx)("title", { children:
|
|
5
|
+
function Layout({ children, mainStyle = {}, containerStyle = {}, subject, }) {
|
|
6
|
+
return ((0, jsx_runtime_1.jsxs)(components_1.Html, { children: [(0, jsx_runtime_1.jsx)(components_1.Head, { children: subject && (0, jsx_runtime_1.jsx)("title", { children: subject }) }), (0, jsx_runtime_1.jsx)(components_1.Body, Object.assign({ style: Object.assign(Object.assign({}, main), mainStyle) }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ style: Object.assign(Object.assign({}, main), mainStyle) }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ style: { padding: '30px 20px' } }, { children: (0, jsx_runtime_1.jsx)(components_1.Container, Object.assign({ style: Object.assign(Object.assign({}, container), containerStyle) }, { children: (0, jsx_runtime_1.jsx)("div", { children: children }) })) })) })) }))] }));
|
|
7
7
|
}
|
|
8
8
|
exports.default = Layout;
|
|
9
9
|
const main = {
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
4
|
const components_1 = require("@react-email/components");
|
|
5
|
+
const chain_1 = require("../libs/chain");
|
|
5
6
|
function Token({ locale, data, }) {
|
|
6
7
|
const showAddress = data.address.slice(0, 4) + '...' + data.address.slice(-4);
|
|
8
|
+
const from = { zh: '来自', en: 'from' }[locale] || 'from';
|
|
7
9
|
const title = { zh: '接收', en: 'Received' }[locale] || 'Received';
|
|
8
|
-
|
|
10
|
+
const chainHost = data.chainHost || (0, chain_1.getChainHost)(data.chainId);
|
|
11
|
+
const url = `https://${chainHost}/explorer/tokens/${data.address}/tx`;
|
|
12
|
+
return ((0, jsx_runtime_1.jsxs)("a", Object.assign({ href: url, target: "_blank", style: Object.assign(Object.assign({}, assetStyle), { margin: '1em 0', textDecoration: 'none', color: 'initial', display: 'block' }) }, { children: [(0, jsx_runtime_1.jsxs)(components_1.Row, Object.assign({ style: titleStyle }, { children: [(0, jsx_runtime_1.jsx)(components_1.Column, { children: title }), (0, jsx_runtime_1.jsxs)(components_1.Column, Object.assign({ align: "right", style: summaryStyle }, { children: ["+", data.amount, " ", data.symbol] }))] })), (0, jsx_runtime_1.jsxs)(components_1.Text, Object.assign({ style: remarkStyle }, { children: [from, " ", showAddress] }))] })));
|
|
9
13
|
}
|
|
10
14
|
exports.default = Token;
|
|
11
15
|
const assetStyle = {
|
|
@@ -24,7 +28,6 @@ const remarkStyle = {
|
|
|
24
28
|
};
|
|
25
29
|
const summaryStyle = {
|
|
26
30
|
color: '#49c3ad',
|
|
27
|
-
// float: 'right',
|
|
28
31
|
};
|
|
29
32
|
const titleStyle = {
|
|
30
33
|
marginBottom: '6px',
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const chain_1 = require("../libs/chain");
|
|
4
5
|
function Transaction({ locale, data, }) {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
main: 'main.abtnetwork.io',
|
|
8
|
-
};
|
|
9
|
-
const host = 'explorer.arcblockio.cn';
|
|
10
|
-
const chianHost = chainMap[data.chainId] || host;
|
|
11
|
-
const url = `https://${chianHost}/explorer/txs/${data.hash}`;
|
|
6
|
+
const chainHost = (0, chain_1.getChainHost)(data.chainId);
|
|
7
|
+
const url = `https://${chainHost}/explorer/txs/${data.hash}`;
|
|
12
8
|
const title = { zh: '交易详情', en: 'Transaction Details' }[locale] || 'Transaction Details';
|
|
13
9
|
const subTitle = { zh: '交易哈希', en: 'Transaction Hash' }[locale] || 'Transaction Hash';
|
|
14
|
-
return ((0, jsx_runtime_1.jsxs)("a", Object.assign({ href: url, target: "_blank", style: { margin: '1em 0', textDecoration: 'none', color: 'initial' } }, { children: [(0, jsx_runtime_1.jsx)("h6", Object.assign({ style: { color: '#a5a5a5', margin: 0 } }, { children:
|
|
10
|
+
return ((0, jsx_runtime_1.jsxs)("a", Object.assign({ href: url, target: "_blank", style: { margin: '1em 0', textDecoration: 'none', color: 'initial' } }, { children: [(0, jsx_runtime_1.jsx)("h6", Object.assign({ style: { color: '#a5a5a5', margin: 0 } }, { children: chainHost })), (0, jsx_runtime_1.jsx)("p", Object.assign({ style: { color: '#4598fa', margin: '6px 0' } }, { children: title })), (0, jsx_runtime_1.jsxs)("div", { children: [subTitle, ": ", data.hash] })] })));
|
|
15
11
|
}
|
|
16
12
|
exports.default = Transaction;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChainHost = void 0;
|
|
4
|
+
function getChainHost(chainId) {
|
|
5
|
+
const defaultHost = 'explorer.arcblockio.cn';
|
|
6
|
+
if (!chainId)
|
|
7
|
+
return defaultHost;
|
|
8
|
+
const chainMap = {
|
|
9
|
+
beta: 'beta.abtnetwork.io',
|
|
10
|
+
main: 'main.abtnetwork.io',
|
|
11
|
+
};
|
|
12
|
+
const chainHost = chainMap[chainId] || defaultHost;
|
|
13
|
+
return chainHost;
|
|
14
|
+
}
|
|
15
|
+
exports.getChainHost = getChainHost;
|
|
@@ -42,13 +42,13 @@ const toClickableSpan = (str, isHighLight = true) => {
|
|
|
42
42
|
}
|
|
43
43
|
// HACK: 邮件中无法支持 dapp 的展示,缺少 dapp 链接,只能作为加粗展示
|
|
44
44
|
if ((0, func_1.isSameAddr)(type, 'dapp')) {
|
|
45
|
-
return `<em data-type="${type}" data-chain-id="${chainId}" data-did="${did}">${item.text}</em>`;
|
|
45
|
+
return `<em style="font-weight:bold;" data-type="${type}" data-chain-id="${chainId}" data-did="${did}">${item.text}</em>`;
|
|
46
46
|
}
|
|
47
47
|
if (url) {
|
|
48
|
-
return `<a target="_blank" href="${url}">${item.text}</a>`;
|
|
48
|
+
return `<a target="_blank" style="color:#4598fa;font-weight:bold;" href="${url}">${item.text}</a>`;
|
|
49
49
|
}
|
|
50
50
|
// 默认展示为加粗
|
|
51
|
-
return `<em data-type="${type}" data-chain-id="${chainId}" data-did="${did}">${item.text}</em>`;
|
|
51
|
+
return `<em style="font-weight:bold;" data-type="${type}" data-chain-id="${chainId}" data-did="${did}">${item.text}</em>`;
|
|
52
52
|
}
|
|
53
53
|
return item.text;
|
|
54
54
|
}
|
|
@@ -10,8 +10,8 @@ const footer_1 = __importDefault(require("../components/footer"));
|
|
|
10
10
|
const content_1 = __importDefault(require("../components/content"));
|
|
11
11
|
const layout_1 = __importDefault(require("../components/layout"));
|
|
12
12
|
const header_1 = __importDefault(require("../components/header"));
|
|
13
|
-
const NotificationEmail = ({ title, body = '', attachments = [], actions = [], appInfo, locale = 'en', }) => {
|
|
14
|
-
return ((0, jsx_runtime_1.jsxs)(layout_1.default, Object.assign({ mainStyle: main }, { children: [(0, jsx_runtime_1.jsx)(components_1.Preview, { children:
|
|
13
|
+
const NotificationEmail = ({ title, body = '', subject, attachments = [], actions = [], appInfo, locale = 'en', }) => {
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)(layout_1.default, Object.assign({ mainStyle: main, subject: subject }, { children: [(0, jsx_runtime_1.jsx)(components_1.Preview, { children: subject }), (0, jsx_runtime_1.jsx)(header_1.default, { appInfo: appInfo }), (0, jsx_runtime_1.jsx)(content_1.default, { style: container, title: title, content: body, attachments: attachments, actions: actions, locale: locale }), (0, jsx_runtime_1.jsx)(footer_1.default, { showCopyright: false, showBlocklet: true, appInfo: appInfo })] })));
|
|
15
15
|
};
|
|
16
16
|
exports.NotificationEmail = NotificationEmail;
|
|
17
17
|
exports.default = exports.NotificationEmail;
|
|
@@ -20,7 +20,7 @@ const main = {
|
|
|
20
20
|
fontFamily,
|
|
21
21
|
};
|
|
22
22
|
const container = {
|
|
23
|
-
margin: '
|
|
23
|
+
margin: '20px auto',
|
|
24
24
|
backgroundColor: '#ffffff',
|
|
25
|
-
padding: '5px 50px
|
|
25
|
+
padding: '5px 50px 30px 60px',
|
|
26
26
|
};
|
|
@@ -30,6 +30,7 @@ const {
|
|
|
30
30
|
createPassportVC,
|
|
31
31
|
createPassport,
|
|
32
32
|
upsertToPassports,
|
|
33
|
+
getPassportClaimUrl,
|
|
33
34
|
} = require('@abtnode/auth/lib/passport');
|
|
34
35
|
const { getKeyPairClaim, getAuthPrincipalForMigrateAppToV2 } = require('@abtnode/auth/lib/server');
|
|
35
36
|
const merge = require('lodash/merge');
|
|
@@ -131,7 +132,7 @@ const checkAppOwner = ({ role, blocklet, userDid, locale = 'en' }) => {
|
|
|
131
132
|
|
|
132
133
|
module.exports = {
|
|
133
134
|
login: {
|
|
134
|
-
onConnect: async ({ node, request, userDid, locale, passportId = '', componentId, action }) => {
|
|
135
|
+
onConnect: async ({ node, request, userDid, locale, passportId = '', componentId, action, baseUrl }) => {
|
|
135
136
|
const blocklet = await request.getBlocklet();
|
|
136
137
|
const config = await request.getServiceConfig(NODE_SERVICES.AUTH, { componentId });
|
|
137
138
|
const { did: teamDid, wallet: blockletWallet } = await request.getBlockletInfo();
|
|
@@ -155,6 +156,7 @@ module.exports = {
|
|
|
155
156
|
item: vcTypes,
|
|
156
157
|
trustedIssuers,
|
|
157
158
|
optional: !invitedUserOnly,
|
|
159
|
+
claimUrl: getPassportClaimUrl(baseUrl),
|
|
158
160
|
};
|
|
159
161
|
if (passportId) {
|
|
160
162
|
claims.verifiableCredential.target = passportId;
|
|
@@ -513,7 +515,7 @@ module.exports = {
|
|
|
513
515
|
},
|
|
514
516
|
|
|
515
517
|
switchPassport: {
|
|
516
|
-
onConnect: async ({ node, request, locale, userDid, previousUserDid, componentId }) => {
|
|
518
|
+
onConnect: async ({ node, request, locale, userDid, previousUserDid, componentId, baseUrl }) => {
|
|
517
519
|
if (userDid && previousUserDid && userDid !== previousUserDid) {
|
|
518
520
|
throw new Error(messages.userMismatch[locale]);
|
|
519
521
|
}
|
|
@@ -553,6 +555,7 @@ module.exports = {
|
|
|
553
555
|
item: vcTypes,
|
|
554
556
|
trustedIssuers,
|
|
555
557
|
optional: !invitedUserOnly,
|
|
558
|
+
claimUrl: getPassportClaimUrl(baseUrl),
|
|
556
559
|
},
|
|
557
560
|
};
|
|
558
561
|
},
|
|
@@ -870,7 +873,7 @@ module.exports = {
|
|
|
870
873
|
authPrincipal: getAuthPrincipalForMigrateAppToV2(node),
|
|
871
874
|
},
|
|
872
875
|
{
|
|
873
|
-
verifiableCredential: async ({ extraParams: { locale }, context: { request } }) => {
|
|
876
|
+
verifiableCredential: async ({ extraParams: { locale }, context: { request, baseUrl } }) => {
|
|
874
877
|
const blocklet = await request.getBlocklet();
|
|
875
878
|
const { wallet } = await request.getBlockletInfo();
|
|
876
879
|
|
|
@@ -883,6 +886,7 @@ module.exports = {
|
|
|
883
886
|
item: vcTypes,
|
|
884
887
|
trustedIssuers,
|
|
885
888
|
optional: false,
|
|
889
|
+
claimUrl: getPassportClaimUrl(baseUrl),
|
|
886
890
|
};
|
|
887
891
|
},
|
|
888
892
|
keyPair: getKeyPairClaim(node, { declare: false }),
|
package/api/libs/email.js
CHANGED
|
@@ -3,6 +3,8 @@ const { render } = require('@react-email/components');
|
|
|
3
3
|
const { getSafeEnv } = require('@abtnode/core/lib/util');
|
|
4
4
|
const { getRuntimeEnvironments } = require('@abtnode/core/lib/util/blocklet');
|
|
5
5
|
const { emailConfigSchema } = require('@blocklet/sdk/lib/validators/email');
|
|
6
|
+
const logger = require('@abtnode/logger')('blocklet-services:notification');
|
|
7
|
+
const omit = require('lodash/omit');
|
|
6
8
|
|
|
7
9
|
const { NotificationEmail } = require('../emails/pages/notification');
|
|
8
10
|
const cache = require('../cache');
|
|
@@ -11,7 +13,7 @@ const schemaEmail = Joi.string().email().required();
|
|
|
11
13
|
|
|
12
14
|
const validateEmail = schemaEmail.validateAsync.bind(schemaEmail);
|
|
13
15
|
|
|
14
|
-
async function sendEmail(receiver, notification, { teamDid, node }) {
|
|
16
|
+
async function sendEmail(receiver, notification, { teamDid, node, locale }) {
|
|
15
17
|
if (!receiver) {
|
|
16
18
|
throw new Error('receiver is required');
|
|
17
19
|
}
|
|
@@ -20,16 +22,18 @@ async function sendEmail(receiver, notification, { teamDid, node }) {
|
|
|
20
22
|
throw new Error('notification is required');
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
const blocklet = await node.getBlocklet({ did: teamDid,
|
|
24
|
-
|
|
25
|
+
const blocklet = await node.getBlocklet({ did: teamDid, useCache: true });
|
|
26
|
+
if (!blocklet) {
|
|
27
|
+
logger.warn(`Failed to get blocklet: ${teamDid}`);
|
|
28
|
+
}
|
|
29
|
+
const config = blocklet?.settings?.notification?.email || {};
|
|
25
30
|
|
|
26
31
|
if (!config.enabled) {
|
|
27
32
|
// skip send email
|
|
28
33
|
return;
|
|
29
34
|
}
|
|
30
|
-
delete config.enabled;
|
|
31
35
|
|
|
32
|
-
const { error, value: emailConfig } = emailConfigSchema.validate(config);
|
|
36
|
+
const { error, value: emailConfig } = emailConfigSchema.validate(omit(config, 'enabled'));
|
|
33
37
|
if (error) {
|
|
34
38
|
throw new Error(error.message);
|
|
35
39
|
}
|
|
@@ -50,12 +54,25 @@ async function sendEmail(receiver, notification, { teamDid, node }) {
|
|
|
50
54
|
url,
|
|
51
55
|
};
|
|
52
56
|
|
|
53
|
-
const
|
|
57
|
+
const subject = `[${appInfo.title}] ${
|
|
58
|
+
notification.title ||
|
|
59
|
+
{ zh: '您收到了一个通知', en: 'You have received a notification' }[locale] ||
|
|
60
|
+
'You have received a notification'
|
|
61
|
+
}`;
|
|
62
|
+
|
|
63
|
+
const html = render(
|
|
64
|
+
NotificationEmail({
|
|
65
|
+
subject,
|
|
66
|
+
...notification,
|
|
67
|
+
appInfo,
|
|
68
|
+
locale,
|
|
69
|
+
})
|
|
70
|
+
);
|
|
54
71
|
const emailData = {
|
|
55
72
|
from: emailConfig.from,
|
|
56
73
|
to: receiver,
|
|
57
74
|
title: notification.title,
|
|
58
|
-
subject
|
|
75
|
+
subject,
|
|
59
76
|
html,
|
|
60
77
|
};
|
|
61
78
|
const transporter = cache.getTransport({ did: teamDid, config: emailConfig });
|
|
@@ -7,8 +7,8 @@ const { onConnect, onApprove } = login;
|
|
|
7
7
|
module.exports = function createRoutes(node, authenticator, createSessionToken) {
|
|
8
8
|
return {
|
|
9
9
|
action: 'login',
|
|
10
|
-
onConnect: async ({ req, userDid, extraParams: { locale, passportId = '', componentId } }) => {
|
|
11
|
-
return onConnect({ node, request: req, userDid, locale, passportId, componentId, action: 'login' });
|
|
10
|
+
onConnect: async ({ req, userDid, extraParams: { locale, passportId = '', componentId }, baseUrl }) => {
|
|
11
|
+
return onConnect({ node, request: req, userDid, locale, passportId, componentId, action: 'login', baseUrl });
|
|
12
12
|
},
|
|
13
13
|
|
|
14
14
|
onAuth: async ({
|
|
@@ -5,13 +5,14 @@ const { onConnect, onApprove } = switchPassport;
|
|
|
5
5
|
module.exports = function createRoutes(node, authenticator, createSessionToken) {
|
|
6
6
|
return {
|
|
7
7
|
action: 'switch-passport',
|
|
8
|
-
onConnect: async ({ req, userDid, extraParams: { locale, connectedDid } }) => {
|
|
8
|
+
onConnect: async ({ req, userDid, baseUrl, extraParams: { locale, connectedDid } }) => {
|
|
9
9
|
return onConnect({
|
|
10
10
|
node,
|
|
11
11
|
request: req,
|
|
12
12
|
locale,
|
|
13
13
|
userDid,
|
|
14
14
|
previousUserDid: connectedDid,
|
|
15
|
+
baseUrl,
|
|
15
16
|
});
|
|
16
17
|
},
|
|
17
18
|
|
|
@@ -22,7 +22,12 @@ module.exports = {
|
|
|
22
22
|
return res.status(400).json({ error: 'Blocklet Studio can only be used for blocklets in development mode' });
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const
|
|
25
|
+
const component = blocklet.children.find((c) => c.meta.name === blocklet.meta.name);
|
|
26
|
+
if (!component || !component.deployedFrom) {
|
|
27
|
+
return res.status(400).json({ error: 'Can not find current component' });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const schemaFile = path.join(component.deployedFrom, BLOCKLET_PREFERENCE_FILE);
|
|
26
31
|
if (fs.existsSync(schemaFile)) {
|
|
27
32
|
try {
|
|
28
33
|
const schema = JSON.parse(fs.readFileSync(schemaFile, 'utf8'));
|
|
@@ -41,7 +46,12 @@ module.exports = {
|
|
|
41
46
|
return res.status(400).json({ error: 'Blocklet Studio can only be used for blocklets in development mode' });
|
|
42
47
|
}
|
|
43
48
|
|
|
44
|
-
const
|
|
49
|
+
const component = blocklet.children.find((c) => c.meta.name === blocklet.meta.name);
|
|
50
|
+
if (!component || !component.deployedFrom) {
|
|
51
|
+
return res.status(400).json({ error: 'Can not find current component' });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const schemaFile = path.join(component.deployedFrom, BLOCKLET_PREFERENCE_FILE);
|
|
45
55
|
fs.writeFileSync(schemaFile, JSON.stringify(req.body, null, 2));
|
|
46
56
|
return res.json(req.body);
|
|
47
57
|
});
|
|
@@ -2,6 +2,7 @@ const {
|
|
|
2
2
|
validateReceiver,
|
|
3
3
|
validateNotification,
|
|
4
4
|
validateMessage,
|
|
5
|
+
NOTIFICATION_TYPES,
|
|
5
6
|
} = require('@blocklet/sdk/lib/validators/notification');
|
|
6
7
|
const { NODE_MODES } = require('@abtnode/constant');
|
|
7
8
|
const { getWalletDid } = require('@blocklet/sdk/lib/did');
|
|
@@ -57,7 +58,10 @@ const sendToDid = async ({ sender, receiver: rawDid, notification, options, node
|
|
|
57
58
|
if (receiverEmail) {
|
|
58
59
|
try {
|
|
59
60
|
await validateEmail(receiverEmail);
|
|
60
|
-
receiverEmailList.push(
|
|
61
|
+
receiverEmailList.push({
|
|
62
|
+
email: receiverEmail,
|
|
63
|
+
locale: userInfoItem?.locale || 'en',
|
|
64
|
+
});
|
|
61
65
|
} catch {
|
|
62
66
|
/* empty */
|
|
63
67
|
}
|
|
@@ -90,10 +94,15 @@ const sendToDid = async ({ sender, receiver: rawDid, notification, options, node
|
|
|
90
94
|
}
|
|
91
95
|
});
|
|
92
96
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
// NOTICE: 目前只有 notification 的通知能够发送邮件,并且 type 可能为 undefined
|
|
98
|
+
if ([undefined, NOTIFICATION_TYPES.NOTIFICATION].includes(data.type)) {
|
|
99
|
+
for (const receiverEmail of receiverEmailList) {
|
|
100
|
+
sendEmail(receiverEmail.email, data, { teamDid: sender.appDid, node, locale: receiverEmail.locale }).catch(
|
|
101
|
+
(error) => {
|
|
102
|
+
logger.error('Failed to send email', { error });
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
97
106
|
}
|
|
98
107
|
});
|
|
99
108
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
3
|
"main.css": "/.blocklet/proxy/blocklet-service/static/css/main.632501d5.css",
|
|
4
|
-
"main.js": "/.blocklet/proxy/blocklet-service/static/js/main.
|
|
4
|
+
"main.js": "/.blocklet/proxy/blocklet-service/static/js/main.3b0044ad.js",
|
|
5
5
|
"static/js/716.0d2a2d32.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/716.0d2a2d32.chunk.js",
|
|
6
6
|
"static/js/359.c47779c2.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/359.c47779c2.chunk.js",
|
|
7
7
|
"static/js/255.279b1bca.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/255.279b1bca.chunk.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"static/js/460.df719a3e.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/460.df719a3e.chunk.js",
|
|
11
11
|
"static/js/868.ac8df3a0.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/868.ac8df3a0.chunk.js",
|
|
12
12
|
"static/js/547.03d5d719.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/547.03d5d719.chunk.js",
|
|
13
|
-
"static/js/343.
|
|
13
|
+
"static/js/343.4fd3d628.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/343.4fd3d628.chunk.js",
|
|
14
14
|
"static/js/682.a8bf723a.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/682.a8bf723a.chunk.js",
|
|
15
15
|
"static/js/711.56427a24.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/711.56427a24.chunk.js",
|
|
16
16
|
"static/js/437.075e8453.chunk.js": "/.blocklet/proxy/blocklet-service/static/js/437.075e8453.chunk.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"router-template-styles/styles.css": "/.blocklet/proxy/blocklet-service/router-template-styles/styles.css",
|
|
46
46
|
"index.html": "/.blocklet/proxy/blocklet-service/index.html",
|
|
47
47
|
"main.632501d5.css.map": "/.blocklet/proxy/blocklet-service/static/css/main.632501d5.css.map",
|
|
48
|
-
"main.
|
|
48
|
+
"main.3b0044ad.js.map": "/.blocklet/proxy/blocklet-service/static/js/main.3b0044ad.js.map",
|
|
49
49
|
"716.0d2a2d32.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/716.0d2a2d32.chunk.js.map",
|
|
50
50
|
"359.c47779c2.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/359.c47779c2.chunk.js.map",
|
|
51
51
|
"255.279b1bca.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/255.279b1bca.chunk.js.map",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"460.df719a3e.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/460.df719a3e.chunk.js.map",
|
|
55
55
|
"868.ac8df3a0.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/868.ac8df3a0.chunk.js.map",
|
|
56
56
|
"547.03d5d719.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/547.03d5d719.chunk.js.map",
|
|
57
|
-
"343.
|
|
57
|
+
"343.4fd3d628.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/343.4fd3d628.chunk.js.map",
|
|
58
58
|
"682.a8bf723a.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/682.a8bf723a.chunk.js.map",
|
|
59
59
|
"711.56427a24.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/711.56427a24.chunk.js.map",
|
|
60
60
|
"437.075e8453.chunk.js.map": "/.blocklet/proxy/blocklet-service/static/js/437.075e8453.chunk.js.map",
|
|
@@ -70,6 +70,6 @@
|
|
|
70
70
|
},
|
|
71
71
|
"entrypoints": [
|
|
72
72
|
"static/css/main.632501d5.css",
|
|
73
|
-
"static/js/main.
|
|
73
|
+
"static/js/main.3b0044ad.js"
|
|
74
74
|
]
|
|
75
75
|
}
|
package/build/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"/><meta name="theme-color" content="#000000"/><title>Blocklet Service</title><script src=".well-known/service/api/env"></script><script src="/__blocklet__.js"></script><script defer="defer" src="/.blocklet/proxy/blocklet-service/static/js/main.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"/><meta name="theme-color" content="#000000"/><title>Blocklet Service</title><script src=".well-known/service/api/env"></script><script src="/__blocklet__.js"></script><script defer="defer" src="/.blocklet/proxy/blocklet-service/static/js/main.3b0044ad.js"></script><link href="/.blocklet/proxy/blocklet-service/static/css/main.632501d5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|