@abtnode/blocklet-services 1.16.38-beta-20250123-083218-c7ea9693 → 1.16.38-beta-20250125-130409-89d4849d
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-B2yJ7-eq.js} +1 -1
- package/dist/assets/{ArrowDropDown-CCP1plk6.js → ArrowDropDown-D34En9iv.js} +1 -1
- package/dist/assets/{CheckCircle-DhGEqk47.js → CheckCircle-BFXaMcKG.js} +1 -1
- package/dist/assets/{ChevronLeft-md-2eRHz.js → ChevronLeft-BXNAWRN5.js} +1 -1
- package/dist/assets/{ChevronRight-DAi6_yC8.js → ChevronRight-bqoO4ITE.js} +1 -1
- package/dist/assets/{DeleteOutline-mNy4Y7aW.js → DeleteOutline-_fdI9SLO.js} +1 -1
- package/dist/assets/{Done-BW0pdQ5b.js → Done-BegjCX44.js} +1 -1
- package/dist/assets/{Download-Dn7Gxwef.js → Download-ynxZ21_h.js} +1 -1
- package/dist/assets/{EditIcon-BKaoBwhT.js → EditIcon-D6Lk4OxD.js} +1 -1
- package/dist/assets/{Error-bTFr7mrN.js → Error-Dy9JDlUO.js} +1 -1
- package/dist/assets/{Google-Df86UadJ.js → Google-oUsdET4E.js} +1 -1
- package/dist/assets/{InfoOutlined-CD_kKD1R.js → InfoOutlined-CNFvZjEE.js} +1 -1
- package/dist/assets/{Launch-C4oayzSh.js → Launch-DrBfpSUO.js} +1 -1
- package/dist/assets/{LaunchOutlined-o-scAjX1.js → LaunchOutlined-BstP_JKj.js} +1 -1
- package/dist/assets/{LockIcon-CJS2b0V1.js → LockIcon-BITD3hjp.js} +1 -1
- package/dist/assets/{Loop-CgXdPi-b.js → Loop-CuBUpP_g.js} +1 -1
- package/dist/assets/{MoreHoriz-CE_TiTTu.js → MoreHoriz-jduVqLUc.js} +1 -1
- package/dist/assets/{PlayArrow-CNURzidt.js → PlayArrow-CauLC4o_.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-CePklU1n.js} +1 -1
- package/dist/assets/{access-control-C_TECevI.js → access-control-DMs8KTjf.js} +1 -1
- package/dist/assets/{actions-DQhRPM_-.js → actions-B31e80dT.js} +1 -1
- package/dist/assets/{add-component-core-ZKcNoEdg.js → add-component-core-BRZ3frb6.js} +1 -1
- package/dist/assets/{add-resource-DeyN_YP2.js → add-resource-CpU17Psd.js} +1 -1
- package/dist/assets/{addon-BQVku5Pw.js → addon-DTkR7c7s.js} +1 -1
- package/dist/assets/analytics-BdRFij_g.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-B5tzv9w6.js} +1 -1
- package/dist/assets/{base32-DwpD8kXz.js → base32-Bxy_Ng3r.js} +1 -1
- package/dist/assets/{branding-B9FP7-vo.js → branding-DEsr5kE0.js} +2 -2
- package/dist/assets/{bundle-avatar-Fs8xar2D.js → bundle-avatar-BSrkMwWG.js} +1 -1
- package/dist/assets/button-CT_SqdC_.js +1 -0
- package/dist/assets/{click-to-copy-BK1KcsDP.js → click-to-copy-DG6oCsDy.js} +1 -1
- package/dist/assets/{cloneDeep-gFMzIJP-.js → cloneDeep-BRiLvZjr.js} +1 -1
- package/dist/assets/{complete-C8dsbaZL.js → complete-B7fQAviW.js} +1 -1
- package/dist/assets/{component-CY2siZu6.js → component-L5_5YcjO.js} +38 -38
- package/dist/assets/{config-DefjxKJo.js → config-Bi4mtKrp.js} +1 -1
- package/dist/assets/{config-oy6r1Urw.js → config-DfNCVYae.js} +1 -1
- package/dist/assets/{config-navigation-D5ZGtEAj.js → config-navigation-BEXQaINe.js} +3 -3
- package/dist/assets/{config-space-B3_Fcx4w.js → config-space-C1WFdLmf.js} +1 -1
- package/dist/assets/{confirm-BoaULvDn.js → confirm-Cbx82b25.js} +1 -1
- package/dist/assets/connect-Cp12hGV2.js +1 -0
- package/dist/assets/{connect-BLZbqoZH.js → connect-kW-GMUG3.js} +1 -1
- package/dist/assets/connect-to-D5VZBQsq.js +1 -0
- package/dist/assets/{content-layout-DAGIv17a.js → content-layout-CzrxMNjA.js} +1 -1
- package/dist/assets/dashboard-uG_G13IR.js +86 -0
- package/dist/assets/de-C2Y_05d1.js +3 -0
- package/dist/assets/{did-address-lZEH-yVL.js → did-address-DhC4Z1Ef.js} +1 -1
- package/dist/assets/{domain-CL1k3ZX_.js → domain-DvrEWdQ8.js} +2 -2
- package/dist/assets/domain-list-B1J4C6ST.js +15 -0
- package/dist/assets/{email-BEAIuGC5.js → email-Cs87G5pr.js} +1 -1
- package/dist/assets/es-DPVOSPPn.js +3 -0
- package/dist/assets/{exchange-passport-mOSW3xXw.js → exchange-passport-Crhw_vMf.js} +1 -1
- package/dist/assets/{form-text-input-CKzsC-YU.js → form-text-input-COijwVFy.js} +1 -1
- package/dist/assets/fr-C8dIIOc9.js +3 -0
- package/dist/assets/{fuel-e3tdVb--.js → fuel-DxcT-75B.js} +1 -1
- package/dist/assets/{fullpage-CkKHaYU0.js → fullpage-CAAXK4pO.js} +1 -1
- package/dist/assets/{get-safe-url-C4tgGDKq.js → get-safe-url-CJIsC1HE.js} +1 -1
- package/dist/assets/{get-safe-url-C_f_ODLw.js → get-safe-url-jf8X-XpV.js} +1 -1
- package/dist/assets/hi-C5r4WQDs.js +1 -0
- package/dist/assets/{home-BNIXkVh5.js → home-Ckf42YJd.js} +1 -1
- package/dist/assets/id-BQK45J6o.js +3 -0
- package/dist/assets/{iframe-SU3hkiQZ.js → iframe-BYvZHXU-.js} +1 -1
- package/dist/assets/{index-HmBDrYyO.js → index-2NCgoG1i.js} +1 -1
- package/dist/assets/{index-B1LvzL9_.js → index-3PobA81m.js} +1 -1
- package/dist/assets/{index-D3LlfacS.js → index-B86l7aCe.js} +1 -1
- package/dist/assets/{index-XcirhJQa.js → index-BJpEKQ4d.js} +12 -12
- package/dist/assets/{index-CbOZ5xd2.js → index-BNCJw59G.js} +1 -1
- package/dist/assets/index-BUstrRo5.js +61 -0
- package/dist/assets/{index-CzV3SmGK.js → index-BvLMNAG0.js} +1 -1
- package/dist/assets/{index-Dh7hy74S.js → index-Bw3pdP7q.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-C7s7t2aN.js +5 -0
- package/dist/assets/{index-CV6rNC-Y.js → index-CRaD-3s4.js} +9 -9
- package/dist/assets/index-D5mFr1eo.js +1 -0
- package/dist/assets/{index-B2Tt5B_m.js → index-DBxnR425.js} +1 -1
- package/dist/assets/{index-DvtOujRp.js → index-DE_r-gh_.js} +1 -1
- package/dist/assets/{index-BDDBFVc2.js → index-Dnxf7bfY.js} +1 -1
- package/dist/assets/{index-96CXu6nL.js → index-KhsqOaMW.js} +7 -7
- package/dist/assets/{index-CV9CYyTl.js → index-PxlbAHCL.js} +36 -36
- package/dist/assets/{index-jQnnlRfC.js → index-Xsfh2QSh.js} +2 -2
- package/dist/assets/index-_ph5477y.js +291 -0
- package/dist/assets/{invitation-B0m5kk5c.js → invitation-DbGm8k25.js} +1 -1
- package/dist/assets/{invite-RA9kQH1W.js → invite-6nyN-oEv.js} +1 -1
- package/dist/assets/{issue-passport-DHpO_ACu.js → issue-passport-YNIanHYf.js} +1 -1
- package/dist/assets/{item-BieIEWMb.js → item-DvkqLmAe.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-BVSGD29L.js} +1 -1
- package/dist/assets/list-DrMoP89n.js +160 -0
- package/dist/assets/{list-header-CiUgmzBx.js → list-header-Br_UsG2e.js} +1 -1
- package/dist/assets/localization-V7oQS6wL.js +1 -0
- package/dist/assets/{log-C6bNY6ja.js → log-DCaMhKsI.js} +1 -1
- package/dist/assets/{login-Cvj7T07b.js → login-CHKXy0wB.js} +1 -1
- package/dist/assets/{login-oauth-callback-Di8KYSE_.js → login-oauth-callback-BSX9wejc.js} +1 -1
- package/dist/assets/{logo-uploader-CdOV1A5h.js → logo-uploader-D3pYQBpx.js} +3 -3
- package/dist/assets/{lost-passport-DUSDA_sN.js → lost-passport-BDU3b7Z_.js} +1 -1
- package/dist/assets/{open-window-DF6F9kh-.js → open-window-DrK6iGmf.js} +1 -1
- package/dist/assets/{overview-16UWFtH0.js → overview-BdW7-A5w.js} +1 -1
- package/dist/assets/{page-header-D0CahNv0.js → page-header-JASV_XcR.js} +1 -1
- package/dist/assets/{permission-CKZlVSQ7.js → permission-BkijBCin.js} +1 -1
- package/dist/assets/{preferences-DHuTV8VO.js → preferences-CtlqLrD7.js} +1 -1
- package/dist/assets/pt-BkjUa7uv.js +1 -0
- package/dist/assets/publish-resource-CsuZRYMx.js +1 -0
- package/dist/assets/{react-beautiful-dnd.esm-CfBtdMfF.js → react-beautiful-dnd.esm-C5Uq3rbJ.js} +1 -1
- package/dist/assets/{relative-time-BMfPIJBi.js → relative-time-CQ0hJZC_.js} +1 -1
- package/dist/assets/ru-1WsQFvuL.js +1 -0
- package/dist/assets/sdk-CncrP2i9.js +1 -0
- package/dist/assets/session-ClC5u_ou.js +1 -0
- package/dist/assets/{setup-bES2Uf5W.js → setup-DdTSQTvr.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-Byudzjg5.js} +1 -1
- package/dist/assets/{step-actions-CuwaxH_E.js → step-actions-Zk6bKoYE.js} +1 -1
- package/dist/assets/{studio-CO68-4Oq.js → studio-BGgRA_ZI.js} +1 -1
- package/dist/assets/{switch-control-BpWvMK7z.js → switch-control-BmI39UF6.js} +1 -1
- package/dist/assets/th-CecKmVWf.js +1 -0
- package/dist/assets/traffic-B70zlTcA.js +37 -0
- package/dist/assets/{transfer-DzCBkPdX.js → transfer-C-8HxdfL.js} +1 -1
- package/dist/assets/{unsubscribe-DnKJ4RoU.js → unsubscribe-CrmlZkSk.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-CTToOZ4l.js} +1 -1
- package/dist/assets/user-center-BB2CLc7Q.js +71 -0
- package/dist/assets/{util-DQVMHOUo.js → util-BnCdSUGw.js} +1 -1
- package/dist/assets/util-DowdN-NO.js +1 -0
- package/dist/assets/vendor-arcblock-CVRRnBv2.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-CNuv_qkt.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 +43 -43
- 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
|
|