@abtnode/blocklet-services 1.16.38-beta-20250123-083218-c7ea9693 → 1.16.38-beta-20250126-132712-f36c6a8b
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/index.js +116 -19
- package/api/services/dashboard/index.js +10 -0
- package/api/services/notification/index.js +32 -1
- package/api/socket/channel/did.js +386 -53
- package/dist/assets/{Add-CbZXB9BN.js → Add-0_yO_NcD.js} +1 -1
- package/dist/assets/{ArrowDropDown-CCP1plk6.js → ArrowDropDown-CSe7vdhu.js} +1 -1
- package/dist/assets/{CheckCircle-DhGEqk47.js → CheckCircle-C20J4AX-.js} +1 -1
- package/dist/assets/{ChevronLeft-md-2eRHz.js → ChevronLeft-CYpg5M_K.js} +1 -1
- package/dist/assets/{ChevronRight-DAi6_yC8.js → ChevronRight-DORpkdoL.js} +1 -1
- package/dist/assets/{DeleteOutline-mNy4Y7aW.js → DeleteOutline-BaOxCgo3.js} +1 -1
- package/dist/assets/{Done-BW0pdQ5b.js → Done-Bsd0QwkQ.js} +1 -1
- package/dist/assets/{Download-Dn7Gxwef.js → Download-BF8ec3kS.js} +1 -1
- package/dist/assets/{EditIcon-BKaoBwhT.js → EditIcon-D6Lk4OxD.js} +1 -1
- package/dist/assets/{Error-bTFr7mrN.js → Error-CmnuwZkD.js} +1 -1
- package/dist/assets/{Google-Df86UadJ.js → Google-F1HiAjHW.js} +1 -1
- package/dist/assets/{InfoOutlined-CD_kKD1R.js → InfoOutlined-DZAeG3v-.js} +1 -1
- package/dist/assets/{Launch-C4oayzSh.js → Launch-DNY7Ut_B.js} +1 -1
- package/dist/assets/{LaunchOutlined-o-scAjX1.js → LaunchOutlined-BUOyH9Rv.js} +1 -1
- package/dist/assets/{LockIcon-CJS2b0V1.js → LockIcon-BITD3hjp.js} +1 -1
- package/dist/assets/{Loop-CgXdPi-b.js → Loop-gZ2g1v3i.js} +1 -1
- package/dist/assets/{MoreHoriz-CE_TiTTu.js → MoreHoriz-CwoKs0Gg.js} +1 -1
- package/dist/assets/{PlayArrow-CNURzidt.js → PlayArrow-C6dXJHO6.js} +1 -1
- package/dist/assets/{QuestionMarkCircle-yIKrKrCO.js → QuestionMarkCircle-SCPzvU7T.js} +1 -1
- package/dist/assets/{ServerLogo-BtnYTJe2.js → ServerLogo-DRTZsm8x.js} +1 -1
- package/dist/assets/{ViewList-BK6mc3zl.js → ViewList-DfGpYdZ-.js} +1 -1
- package/dist/assets/{access-control-C_TECevI.js → access-control-DWS7Lowo.js} +1 -1
- package/dist/assets/{actions-DQhRPM_-.js → actions-BvtS-2sJ.js} +1 -1
- package/dist/assets/{add-component-core-ZKcNoEdg.js → add-component-core-DZPE4BRe.js} +1 -1
- package/dist/assets/{add-resource-DeyN_YP2.js → add-resource-CYNZTaOG.js} +1 -1
- package/dist/assets/{addon-BQVku5Pw.js → addon-CDVN9YCj.js} +1 -1
- package/dist/assets/analytics-0lVXNyXs.js +11 -0
- package/dist/assets/api-K65cLqol.js +1 -0
- package/dist/assets/ar-DV4YJwQy.js +3 -0
- package/dist/assets/{audit-logs-DfI45rXd.js → audit-logs-CJvI5okV.js} +1 -1
- package/dist/assets/{base32-DwpD8kXz.js → base32-Bl4ek2bl.js} +1 -1
- package/dist/assets/{branding-B9FP7-vo.js → branding-CfeUWBA7.js} +2 -2
- package/dist/assets/{bundle-avatar-Fs8xar2D.js → bundle-avatar-TEUPlhi2.js} +1 -1
- package/dist/assets/button-CzSgwkGN.js +1 -0
- package/dist/assets/{click-to-copy-BK1KcsDP.js → click-to-copy-Ck4RKrL7.js} +1 -1
- package/dist/assets/{cloneDeep-gFMzIJP-.js → cloneDeep-BRiLvZjr.js} +1 -1
- package/dist/assets/{complete-C8dsbaZL.js → complete-CPnz5QUF.js} +1 -1
- package/dist/assets/{component-CY2siZu6.js → component-Srk2_SVH.js} +38 -38
- package/dist/assets/{config-DefjxKJo.js → config-Cp3L8D_L.js} +1 -1
- package/dist/assets/{config-oy6r1Urw.js → config-kJZsVZD6.js} +1 -1
- package/dist/assets/{config-navigation-D5ZGtEAj.js → config-navigation-a3GJWM1m.js} +3 -3
- package/dist/assets/{config-space-B3_Fcx4w.js → config-space-piVzY5c1.js} +1 -1
- package/dist/assets/{confirm-BoaULvDn.js → confirm-D7n9Rzfx.js} +1 -1
- package/dist/assets/connect-BZUv1d-6.js +1 -0
- package/dist/assets/{connect-BLZbqoZH.js → connect-rdXbvbmJ.js} +1 -1
- package/dist/assets/connect-to-BzfmK9yx.js +1 -0
- package/dist/assets/{content-layout-DAGIv17a.js → content-layout-CzrxMNjA.js} +1 -1
- package/dist/assets/dashboard-B_hsqmQK.js +86 -0
- package/dist/assets/de-C2Y_05d1.js +3 -0
- package/dist/assets/{did-address-lZEH-yVL.js → did-address-CLeqbWiu.js} +1 -1
- package/dist/assets/{domain-CL1k3ZX_.js → domain-DgPzyf2N.js} +2 -2
- package/dist/assets/domain-list-BiYGOOY3.js +15 -0
- package/dist/assets/{email-BEAIuGC5.js → email-5azpRba_.js} +1 -1
- package/dist/assets/es-DPVOSPPn.js +3 -0
- package/dist/assets/{exchange-passport-mOSW3xXw.js → exchange-passport-Cus1rYsJ.js} +1 -1
- package/dist/assets/{form-text-input-CKzsC-YU.js → form-text-input-Cf1j6PeI.js} +1 -1
- package/dist/assets/fr-C8dIIOc9.js +3 -0
- package/dist/assets/{fuel-e3tdVb--.js → fuel-BaqDy7AE.js} +1 -1
- package/dist/assets/{fullpage-CkKHaYU0.js → fullpage-Dx8PYbvz.js} +1 -1
- package/dist/assets/{get-safe-url-C4tgGDKq.js → get-safe-url-BF9qL1PD.js} +1 -1
- package/dist/assets/{get-safe-url-C_f_ODLw.js → get-safe-url-BsKINLVF.js} +1 -1
- package/dist/assets/hi-C5r4WQDs.js +1 -0
- package/dist/assets/{home-BNIXkVh5.js → home-D42zu2I_.js} +1 -1
- package/dist/assets/id-BQK45J6o.js +3 -0
- package/dist/assets/{iframe-SU3hkiQZ.js → iframe-Cn--d9nR.js} +1 -1
- package/dist/assets/{index-CbOZ5xd2.js → index-6oQLUjq6.js} +1 -1
- package/dist/assets/{index-XcirhJQa.js → index-BDfZ8xEV.js} +22 -22
- package/dist/assets/{index-CV6rNC-Y.js → index-BWKYj-2X.js} +9 -9
- package/dist/assets/{index-jQnnlRfC.js → index-BgGF6utP.js} +2 -2
- package/dist/assets/{index-CzV3SmGK.js → index-BvLMNAG0.js} +1 -1
- package/dist/assets/{index-DwFu84UU.js → index-C0uUrAqS.js} +1 -1
- package/dist/assets/{index-Dkwa_Vhl.js → index-C2fPoxDR.js} +1 -1
- package/dist/assets/{index-BDDBFVc2.js → index-CEbjBHHi.js} +1 -1
- package/dist/assets/{index-D3LlfacS.js → index-CFT-L0SZ.js} +1 -1
- package/dist/assets/{index-B1LvzL9_.js → index-CKsz_iVM.js} +1 -1
- package/dist/assets/{index-HmBDrYyO.js → index-CSkA6M4K.js} +1 -1
- package/dist/assets/{index-96CXu6nL.js → index-CXVY5UoP.js} +7 -7
- package/dist/assets/index-D5mFr1eo.js +1 -0
- package/dist/assets/{index-DvtOujRp.js → index-DE_r-gh_.js} +1 -1
- package/dist/assets/{index-Dh7hy74S.js → index-DTzPwoh8.js} +1 -1
- package/dist/assets/index-DpNGP1ih.js +291 -0
- package/dist/assets/{index-B2Tt5B_m.js → index-DpOEjWGx.js} +1 -1
- package/dist/assets/index-fel1gHRy.js +61 -0
- package/dist/assets/index-kk2gduJr.js +5 -0
- package/dist/assets/{index-CV9CYyTl.js → index-uosYiNLl.js} +36 -36
- package/dist/assets/{invitation-B0m5kk5c.js → invitation-DpOgzXor.js} +1 -1
- package/dist/assets/{invite-RA9kQH1W.js → invite-DmpCzOPN.js} +1 -1
- package/dist/assets/{issue-passport-DHpO_ACu.js → issue-passport--83QQUn2.js} +1 -1
- package/dist/assets/{item-BieIEWMb.js → item-7Z8_UB5K.js} +1 -1
- package/dist/assets/ja-DsJERrpD.js +3 -0
- package/dist/assets/ko-t760ZSCl.js +3 -0
- package/dist/assets/{launch-result-message-CeThGm85.js → launch-result-message-C_UhVRcl.js} +1 -1
- package/dist/assets/{layout-BG2jsdXo.js → layout-Dv_7-Fpq.js} +1 -1
- package/dist/assets/{list-header-CiUgmzBx.js → list-header-CfBPZZEw.js} +1 -1
- package/dist/assets/list-yjVo8vxH.js +160 -0
- package/dist/assets/localization-CRwVeETn.js +1 -0
- package/dist/assets/{log-C6bNY6ja.js → log-CNjGA-yl.js} +1 -1
- package/dist/assets/{login-Cvj7T07b.js → login-DWrSz67b.js} +1 -1
- package/dist/assets/{login-oauth-callback-Di8KYSE_.js → login-oauth-callback-VNeZxFH0.js} +1 -1
- package/dist/assets/{logo-uploader-CdOV1A5h.js → logo-uploader-DZm2nb0s.js} +3 -3
- package/dist/assets/{lost-passport-DUSDA_sN.js → lost-passport-DFh2B6Gl.js} +1 -1
- package/dist/assets/{open-window-DF6F9kh-.js → open-window-BvyLumiN.js} +1 -1
- package/dist/assets/{overview-16UWFtH0.js → overview-DNQZ-tgj.js} +1 -1
- package/dist/assets/{page-header-D0CahNv0.js → page-header-CJHCTtBc.js} +1 -1
- package/dist/assets/{permission-CKZlVSQ7.js → permission-B0xKCybj.js} +1 -1
- package/dist/assets/{preferences-DHuTV8VO.js → preferences-BMgF6Djl.js} +1 -1
- package/dist/assets/pt-BkjUa7uv.js +1 -0
- package/dist/assets/publish-resource-B_OOg2Om.js +1 -0
- package/dist/assets/{react-beautiful-dnd.esm-CfBtdMfF.js → react-beautiful-dnd.esm-DY38RjFx.js} +1 -1
- package/dist/assets/{relative-time-BMfPIJBi.js → relative-time-C36uWHLw.js} +1 -1
- package/dist/assets/ru-1WsQFvuL.js +1 -0
- package/dist/assets/sdk-VtyRZZVE.js +1 -0
- package/dist/assets/session-DutPZhUI.js +1 -0
- package/dist/assets/{setup-bES2Uf5W.js → setup-lHrzljce.js} +3 -3
- package/dist/assets/{shorten-label-B08EnqgB.js → shorten-label-CYJeMT7h.js} +1 -1
- package/dist/assets/{simple-select-mThFfFp5.js → simple-select-CAyDBkK6.js} +1 -1
- package/dist/assets/{slicedToArray-Ct1Y7NnY.js → slicedToArray-CV571vyX.js} +2 -2
- package/dist/assets/{start-MoamILfR.js → start-DNIWxyMi.js} +1 -1
- package/dist/assets/{step-actions-CuwaxH_E.js → step-actions-BYFwIhu4.js} +1 -1
- package/dist/assets/{studio-CO68-4Oq.js → studio-DBfgF1ck.js} +1 -1
- package/dist/assets/{switch-control-BpWvMK7z.js → switch-control-B8wYzo2_.js} +1 -1
- package/dist/assets/th-CecKmVWf.js +1 -0
- package/dist/assets/traffic-1TtyUzFO.js +37 -0
- package/dist/assets/{transfer-DzCBkPdX.js → transfer-Bh7VQuKL.js} +1 -1
- package/dist/assets/{unsubscribe-DnKJ4RoU.js → unsubscribe-C_eX2N6S.js} +1 -1
- package/dist/assets/{use-mobile-DoeLOxx6.js → use-mobile-Bk8quGt9.js} +1 -1
- package/dist/assets/{useAsync-DCGc7Pdb.js → useAsync-Ua5iss51.js} +1 -1
- package/dist/assets/{useAsyncRetry-0k7mm5ej.js → useAsyncRetry-EMRT9Ldq.js} +1 -1
- package/dist/assets/{useLocalStorage-BGtJBKln.js → useLocalStorage-tmIJr51I.js} +1 -1
- package/dist/assets/user-center-pv7oyGUu.js +71 -0
- package/dist/assets/util-BY6uUuCk.js +1 -0
- package/dist/assets/{util-DQVMHOUo.js → util-CtKeCk_N.js} +1 -1
- package/dist/assets/vendor-arcblock-Bf7AGBSd.js +3506 -0
- package/dist/assets/{vendor-hooks-DWAhU9cy.js → vendor-hooks-BKxTDk_P.js} +1 -1
- package/dist/assets/{vendor-mui-core-jh6OMVvU.js → vendor-mui-core-CCMNKHtm.js} +1 -1
- package/dist/assets/{vendor-mui-x-BRRfPRl8.js → vendor-mui-x-DmPVvZFJ.js} +1 -1
- package/dist/assets/vendor-utils-5TjOM6td.js +11 -0
- package/dist/assets/vi-CDrTp7No.js +1 -0
- package/dist/assets/wrap-locale-BjJvyHQM.js +1 -0
- package/dist/assets/zh-Bqr2c2To.js +4 -0
- package/dist/assets/zh-tw-CUyoe2CD.js +3 -0
- package/dist/index.html +5 -5
- package/dist/service-worker.js +1 -1
- package/dist/share/shared-service-worker.js +1 -123
- package/package.json +44 -44
- package/dist/assets/analytics-CABOV3VR.js +0 -47
- package/dist/assets/api-hLQrqHOJ.js +0 -1
- package/dist/assets/ar-D1VagXPW.js +0 -3
- package/dist/assets/button-DkniumtB.js +0 -1
- package/dist/assets/connect-o0-zMzhz.js +0 -1
- package/dist/assets/connect-to-CLRCxFvc.js +0 -1
- package/dist/assets/dashboard-BsuKKhWa.js +0 -86
- package/dist/assets/de-CvDV7d-6.js +0 -3
- package/dist/assets/domain-list-Hq4lMkF7.js +0 -15
- package/dist/assets/es-DGK_gDT-.js +0 -3
- package/dist/assets/fr-BuGbCF-_.js +0 -3
- package/dist/assets/hi-w7-Xo0pj.js +0 -1
- package/dist/assets/id-DfsK8869.js +0 -3
- package/dist/assets/index-ChG5I_m-.js +0 -1
- package/dist/assets/index-DZkcShk4.js +0 -2
- package/dist/assets/index-Dg_5HpPS.js +0 -5
- package/dist/assets/index-Dyaz7ZHB.js +0 -291
- package/dist/assets/ja-CQJHpvK1.js +0 -3
- package/dist/assets/ko-9oNzTJow.js +0 -3
- package/dist/assets/localization-BhAxNGA4.js +0 -1
- package/dist/assets/pt-DMLN8oh9.js +0 -1
- package/dist/assets/publish-resource-CAkJ3GaW.js +0 -1
- package/dist/assets/ru-CGG1vu9C.js +0 -1
- package/dist/assets/sdk-CBXPdpcP.js +0 -1
- package/dist/assets/session-BTTqSeVf.js +0 -1
- package/dist/assets/th-D-lApkQp.js +0 -1
- package/dist/assets/user-center-BkJieuxf.js +0 -232
- package/dist/assets/vendor-arcblock-CwZ35cSm.js +0 -3509
- package/dist/assets/vendor-utils-u2ViqIqX.js +0 -11
- package/dist/assets/vi-D45dg9B_.js +0 -1
- package/dist/assets/wrap-locale-DTfWnUqX.js +0 -1
- package/dist/assets/zh-CcLxBIl6.js +0 -4
- package/dist/assets/zh-tw-Bqy7j8qE.js +0 -3
package/api/index.js
CHANGED
|
@@ -25,8 +25,8 @@ const normalizePathPrefix = require('@abtnode/util/lib/normalize-path-prefix');
|
|
|
25
25
|
const createInvite = require('@abtnode/auth/lib/invitation');
|
|
26
26
|
const { getStatusFromError } = require('@abtnode/util/lib/custom-error');
|
|
27
27
|
const { withQuery, joinURL, withTrailingSlash } = require('ufo');
|
|
28
|
-
const { createProxyMiddleware } = require('http-proxy-middleware');
|
|
29
|
-
const { findComponentByIdV2 } = require('@blocklet/meta/lib/util');
|
|
28
|
+
const { createProxyMiddleware, responseInterceptor } = require('http-proxy-middleware');
|
|
29
|
+
const { findComponentByIdV2, getMountPoints } = require('@blocklet/meta/lib/util');
|
|
30
30
|
const {
|
|
31
31
|
patchResponseHeader,
|
|
32
32
|
DEFAULT_HELMET_CONFIG,
|
|
@@ -344,24 +344,119 @@ module.exports = function createServer(node, serverOptions = {}) {
|
|
|
344
344
|
});
|
|
345
345
|
|
|
346
346
|
// 提供统一的 service-worker 注册入口,优先采用 service 自己提供的逻辑,尽量不依赖 Nginx 配置
|
|
347
|
-
server.use(
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
347
|
+
server.use(
|
|
348
|
+
[
|
|
349
|
+
// DEPRECATED: @zhanghan 后续统一使用 __sw__ 地址
|
|
350
|
+
/.*\/__service-worker__\.js$/,
|
|
351
|
+
/.*\/__sw__\.js$/,
|
|
352
|
+
],
|
|
353
|
+
ensureBlocklet(),
|
|
354
|
+
(req, res, next) => {
|
|
355
|
+
const { blocklet } = req;
|
|
356
|
+
const componentId = req.headers['x-blocklet-component-id'];
|
|
357
|
+
if (!componentId) {
|
|
358
|
+
logger.warn('Missing x-blocklet-component-id header', { url: req.url });
|
|
359
|
+
res.type('js').send('');
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const componentDid = componentId.split('/').pop();
|
|
363
|
+
const appUrl = blocklet.environmentObj?.BLOCKLET_APP_URL;
|
|
364
|
+
const component = findComponentByIdV2(blocklet, componentId);
|
|
365
|
+
res.set('Service-Worker-Allowed', withTrailingSlash(component.mountPoint));
|
|
366
|
+
const realSwUrl = withQuery(joinURL('/.blocklet/proxy', componentDid, 'service-worker.js'), {
|
|
367
|
+
// 确保获取到的 sw 是最新的
|
|
368
|
+
d: Date.now(),
|
|
369
|
+
});
|
|
370
|
+
const scope = withTrailingSlash(component.mountPoint);
|
|
362
371
|
|
|
363
|
-
|
|
364
|
-
|
|
372
|
+
const componentMountPoints = getMountPoints(blocklet);
|
|
373
|
+
const sharedComponents = (blocklet?.children || []).filter((child) => {
|
|
374
|
+
const enabledShared = child?.configs?.find((x) => {
|
|
375
|
+
if (x.key === 'SERVICE_WORKER_SHARING_ENABLED' && x.value === 'true') {
|
|
376
|
+
return true;
|
|
377
|
+
}
|
|
378
|
+
return false;
|
|
379
|
+
});
|
|
380
|
+
return !!enabledShared;
|
|
381
|
+
});
|
|
382
|
+
const mountPoints = componentMountPoints.map((x) => withTrailingSlash(x.mountPoint));
|
|
383
|
+
const sharedMountPoints = sharedComponents.map((x) => withTrailingSlash(x.mountPoint));
|
|
384
|
+
const customContent = `importScripts('/.well-known/service/static/share/workbox-v7.3.0/workbox-sw.js');
|
|
385
|
+
workbox.setConfig({
|
|
386
|
+
modulePathPrefix: '/.well-known/service/static/share/workbox-v7.3.0/',
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
self.blocklet = {
|
|
390
|
+
workbox,
|
|
391
|
+
did: '${componentDid}',
|
|
392
|
+
prefix: '${scope}',
|
|
393
|
+
mountPoints: ${JSON.stringify(mountPoints)},
|
|
394
|
+
sharedMountPoints: ${JSON.stringify(sharedMountPoints)},
|
|
395
|
+
whiteList: [
|
|
396
|
+
'/favicon.ico',
|
|
397
|
+
'/.well-known/service/blocklet/logo',
|
|
398
|
+
'/.well-known/service/blocklet/logo-favicon',
|
|
399
|
+
'/.well-known/service/blocklet/logo-rect',
|
|
400
|
+
'/.well-known/service/blocklet/splash/portrait',
|
|
401
|
+
'/.well-known/service/blocklet/splash/landscape',
|
|
402
|
+
'/.well-known/service/openembed.json',
|
|
403
|
+
'/.well-known/service/openembed.yaml',
|
|
404
|
+
],
|
|
405
|
+
canCache({ url }) {
|
|
406
|
+
const pathname = url.pathname;
|
|
407
|
+
if (pathname.startsWith('/.well-known/analytics')) {
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
if (
|
|
411
|
+
pathname.startsWith('/.well-known/service/static/share/') ||
|
|
412
|
+
pathname.startsWith('/.blocklet/proxy/'+self.blocklet.did) ||
|
|
413
|
+
self.blocklet.whiteList.some((x) => x === url.pathname)
|
|
414
|
+
) {
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
if (self.blocklet.sharedMountPoints.some((x) => pathname.startsWith(x))) {
|
|
419
|
+
return true;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
const otherMountPoints = self.blocklet.mountPoints.filter((item) => item !== self.blocklet.prefix);
|
|
423
|
+
if (self.blocklet.prefix === '/') {
|
|
424
|
+
if (!otherMountPoints.some((x) => pathname.startsWith(x)) && !pathname.startsWith('/.well-known/service/')) {
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
if (pathname.startsWith(self.blocklet.prefix)) {
|
|
430
|
+
return true;
|
|
431
|
+
}
|
|
432
|
+
return false;
|
|
433
|
+
},
|
|
434
|
+
fixRouteUrl(route) {
|
|
435
|
+
return {
|
|
436
|
+
...route,
|
|
437
|
+
url: '/.blocklet/proxy/'+self.blocklet.did+'/'+route.url,
|
|
438
|
+
};
|
|
439
|
+
},
|
|
440
|
+
};`;
|
|
441
|
+
const proxySw = createProxyMiddleware({
|
|
442
|
+
target: appUrl,
|
|
443
|
+
pathRewrite: () => realSwUrl,
|
|
444
|
+
changeOrigin: true,
|
|
445
|
+
selfHandleResponse: true,
|
|
446
|
+
on: {
|
|
447
|
+
proxyRes: responseInterceptor((responseBuffer) => {
|
|
448
|
+
if (!responseBuffer) {
|
|
449
|
+
return customContent;
|
|
450
|
+
}
|
|
451
|
+
const response = responseBuffer.toString('utf8');
|
|
452
|
+
return [customContent, response].join('\n');
|
|
453
|
+
}),
|
|
454
|
+
},
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
proxySw(req, res, next);
|
|
458
|
+
}
|
|
459
|
+
);
|
|
365
460
|
|
|
366
461
|
// 此处逻辑会为 service 和 blocklet 都增加安全相关的 header 配置
|
|
367
462
|
server.use(async (req, res, next) => {
|
|
@@ -404,6 +499,8 @@ module.exports = function createServer(node, serverOptions = {}) {
|
|
|
404
499
|
notificationService.sendToUser.attach(server);
|
|
405
500
|
notificationService.sendToMail.attach(server);
|
|
406
501
|
notificationService.sendToPush.attach(server);
|
|
502
|
+
notificationService.sendToApp.attach(server);
|
|
503
|
+
notificationService.sendToWebhook.attach(server);
|
|
407
504
|
notificationService.sendToAppChannel.attach(server);
|
|
408
505
|
relayService.sendToRelay.attach(server);
|
|
409
506
|
|
|
@@ -123,6 +123,15 @@ function createWebsocketServer(node, ensureWsUser) {
|
|
|
123
123
|
}
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
+
// 发送给 admin
|
|
127
|
+
eventHub.on(EVENTS.NOTIFICATION_BLOCKLET_CREATE, (data) => {
|
|
128
|
+
if (data?.entityType === 'blocklet' && data.entityId) {
|
|
129
|
+
const did = data.entityId;
|
|
130
|
+
const eventName = `${did}/${EVENTS.NOTIFICATION_BLOCKLET_CREATE}`;
|
|
131
|
+
wsServer.broadcast(eventName, eventName, data, { noCluster: true });
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
126
135
|
const streamLogManager = commonListen(wsServer, node);
|
|
127
136
|
|
|
128
137
|
eventHub.on(BlockletEvents.removed, (data) => {
|
|
@@ -184,6 +193,7 @@ function createNotificationWebsocketServer(node, ensureWsUser) {
|
|
|
184
193
|
},
|
|
185
194
|
});
|
|
186
195
|
|
|
196
|
+
// 发送给用户
|
|
187
197
|
eventHub.on(EVENTS.NOTIFICATION_BLOCKLET_CREATE, (data) => {
|
|
188
198
|
if (data?.entityType === 'blocklet' && data.entityId) {
|
|
189
199
|
const did = data.entityId;
|
|
@@ -8,7 +8,7 @@ const states = require('../../state');
|
|
|
8
8
|
const logger = require('../../libs/logger')('notification');
|
|
9
9
|
const { sendToAppChannel } = require('../../socket/channel/app');
|
|
10
10
|
const { sendToAppComponents } = require('../../socket/channel/component');
|
|
11
|
-
const { sendToUserDid, sendToAppDid, sendToMail, sendToPush } = require('../../socket/channel/did');
|
|
11
|
+
const { sendToUserDid, sendToAppDid, sendToMail, sendToPush, sendToWebhook } = require('../../socket/channel/did');
|
|
12
12
|
const getHooksByChannel = require('../../socket/channel/hooks');
|
|
13
13
|
const { getTokenInfo } = require('../../socket/util');
|
|
14
14
|
|
|
@@ -143,6 +143,28 @@ const init = ({ node }) => {
|
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
145
|
|
|
146
|
+
const onSendToWebhook = async (req, res) => {
|
|
147
|
+
try {
|
|
148
|
+
const results = await sendToWebhook({ ...req.body.data, node });
|
|
149
|
+
res.status(200).json(results);
|
|
150
|
+
} catch (error) {
|
|
151
|
+
logger.error('Send webhook failed', { error });
|
|
152
|
+
res.statusMessage = error.message;
|
|
153
|
+
res.status(400).send(error.message);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const onSendToWallet = async (req, res) => {
|
|
158
|
+
try {
|
|
159
|
+
await sendToAppDid({ ...req.body.data, node, wsServer });
|
|
160
|
+
res.status(200).send('');
|
|
161
|
+
} catch (error) {
|
|
162
|
+
logger.error('Send message to app channel failed', { error });
|
|
163
|
+
res.statusMessage = error.message;
|
|
164
|
+
res.status(400).send(error.message);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
146
168
|
const onSendToAppChannel = async (req, res) => {
|
|
147
169
|
try {
|
|
148
170
|
await sendToAppChannel({ ...req.body.data, node, wsServer });
|
|
@@ -177,7 +199,16 @@ const init = ({ node }) => {
|
|
|
177
199
|
exec: (data) => sendToMail({ ...data, node, wsServer }),
|
|
178
200
|
},
|
|
179
201
|
|
|
202
|
+
sendToWebhook: {
|
|
203
|
+
attach: (app) => {
|
|
204
|
+
app.post(`${WELLKNOWN_SERVICE_PATH_PREFIX}/api/send-to-webhook`, onSendToWebhook);
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
|
|
180
208
|
sendToApp: {
|
|
209
|
+
attach: (app) => {
|
|
210
|
+
app.post(`${WELLKNOWN_SERVICE_PATH_PREFIX}/api/send-to-wallet`, onSendToWallet);
|
|
211
|
+
},
|
|
181
212
|
exec: ({ event, appDid, data }) => sendToAppDid({ event, appDid, data, node, wsServer }),
|
|
182
213
|
},
|
|
183
214
|
|