@abtnode/blocklet-services 1.16.47-beta-20250731-014139-e860268f → 1.16.47-beta-20250805-095401-14eb156b
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/libs/image.js +131 -77
- package/api/routes/blocklet.js +47 -32
- package/api/routes/csp-proxy.js +8 -8
- package/api/routes/user.js +6 -2
- package/api/services/auth/connect/verify-destroy.js +24 -2
- package/api/services/auth/session.js +6 -2
- package/api/services/image/index.js +6 -1
- package/dist/assets/AdapterDayjs-D8zlc0TS.js +3 -0
- package/dist/assets/{Google-JeDCA1Ra.js → Google-DxcTyhFe.js} +1 -1
- package/dist/assets/{access-control-CqcbwJmg.js → access-control-jFR93SsS.js} +1 -1
- package/dist/assets/{actions-CJMVMPKl.js → actions-B0rWiAuM.js} +1 -1
- package/dist/assets/{add-component-core-DycwSgX5.js → add-component-core-DfrJCl4a.js} +1 -1
- package/dist/assets/{add-resource-B2NC98Ho.js → add-resource-Ch4SZAWK.js} +1 -1
- package/dist/assets/{addon-BaoB37xg.js → addon-B-vtdIPn.js} +1 -1
- package/dist/assets/{advanced-D8HEmDva.js → advanced-B92lyz70.js} +1 -1
- package/dist/assets/aigne-BDdYezR9.js +10 -0
- package/dist/assets/api-Rnh95Dt4.js +1 -0
- package/dist/assets/{appearance-B497VXFd.js → appearance-C1k2L_bA.js} +1 -1
- package/dist/assets/{ar-DKohTs5n.js → ar-DDlrXmSt.js} +1 -1
- package/dist/assets/{ar-DxMZhab8.js → ar-cWkdH-wM.js} +1 -1
- package/dist/assets/{arrow-down.svg-CVjG1TNQ.js → arrow-down.svg-BnKvb8st.js} +1 -1
- package/dist/assets/{audit-logs-Dl8A9oRq.js → audit-logs-OO0l4GnY.js} +1 -1
- package/dist/assets/{authorize-Dq_NLQNa.js → authorize-BU6KP5W6.js} +1 -1
- package/dist/assets/{base-chart-Bq5ougoU.js → base-chart-B1XQ7Ytj.js} +1 -1
- package/dist/assets/{base32-DdRv86ir.js → base32-BeRPpTcK.js} +1 -1
- package/dist/assets/{branding-DGrOIsAX.js → branding-CEu-c8uQ.js} +1 -1
- package/dist/assets/{branding-BoSGCdxD.js → branding-D1JmhF3p.js} +2 -2
- package/dist/assets/{bundle-avatar-CbWsxcdV.js → bundle-avatar-BZQ_lZxy.js} +1 -1
- package/dist/assets/button-VEuIVOxr.js +1 -0
- package/dist/assets/{click-to-copy-D2vDgDFL.js → click-to-copy-EOhAhdSS.js} +1 -1
- package/dist/assets/{cloneDeep-Bp5oPxU3.js → cloneDeep-DwV-xVQF.js} +1 -1
- package/dist/assets/{collapse-C3V-lD7M.js → collapse-wumRocfe.js} +1 -1
- package/dist/assets/{complete-cbrNEz02.js → complete-DwaBuF4K.js} +1 -1
- package/dist/assets/{component-Cpwp1opW.js → component-D31UJpJQ.js} +3 -3
- package/dist/assets/{config-G8speQtC.js → config-AgncsJiw.js} +1 -1
- package/dist/assets/config-C6pSSzan.js +46 -0
- package/dist/assets/{config-BVstS2Nm.js → config-Df0dxvZZ.js} +1 -1
- package/dist/assets/{config-navigation-C1cOMpGw.js → config-navigation-JJehoQAV.js} +3 -3
- package/dist/assets/{config-space-DkL2gOSr.js → config-space-CrH2JnlQ.js} +1 -1
- package/dist/assets/{confirm-CRV2RKnN.js → confirm-Cx2owMMo.js} +1 -1
- package/dist/assets/{connect-B1rcOd6B.js → connect-BD9OoHaD.js} +1 -1
- package/dist/assets/{connect-DeAtTJ1r.js → connect-C7C7ILA6.js} +1 -1
- package/dist/assets/{connect-to-B8zygJqK.js → connect-to-nCPxtJH1.js} +1 -1
- package/dist/assets/{content-layout-CT98QJfh.js → content-layout-BZKNdb6s.js} +1 -1
- package/dist/assets/{createClass-D_MAnszY.js → createClass-BTaIsrxM.js} +1 -1
- package/dist/assets/dashboard-CDjptZox.js +106 -0
- package/dist/assets/{de-2FhiIZmh.js → de-CKHR0Dxi.js} +1 -1
- package/dist/assets/{de-CYm7FmiN.js → de-DSALrqI8.js} +1 -1
- package/dist/assets/{delete-confirm-za4gd8zO.js → delete-confirm-Wa3xVOUM.js} +1 -1
- package/dist/assets/{did-address-DM13r0GC.js → did-address-C7IHZs6x.js} +1 -1
- package/dist/assets/{domain-nJ5cWvRr.js → domain-DV7cdOEy.js} +1 -1
- package/dist/assets/{domain-action-card-Dt77CLty.js → domain-action-card-CnvZTstr.js} +1 -1
- package/dist/assets/domains-BpVmxPqY.js +1 -0
- package/dist/assets/{dot-BD1gx_6x.js → dot-CE8yAFCN.js} +1 -1
- package/dist/assets/{email-CvXCF8HC.js → email-DQnz-4Bc.js} +1 -1
- package/dist/assets/{empty-spinner-BMuZ6jkU.js → empty-spinner-DCdg-gxP.js} +1 -1
- package/dist/assets/engine-BD3-KjxK.js +1 -0
- package/dist/assets/{es-C2M40LGE.js → es-2tKCVVW6.js} +1 -1
- package/dist/assets/{es-5zob_8Of.js → es-DQvY5fGr.js} +1 -1
- package/dist/assets/{exchange-passport-T_o_EXW7.js → exchange-passport-D9HZFZwF.js} +1 -1
- package/dist/assets/{form-CXNMlv2k.js → form-D52FUB8q.js} +1 -1
- package/dist/assets/{form-text-input-CFrnnbRX.js → form-text-input-DanXI___.js} +1 -1
- package/dist/assets/{form-wrapper-CpayHdi1.js → form-wrapper-DgFURo9t.js} +1 -1
- package/dist/assets/{fr-GNzEzJIo.js → fr-BgvhEJ06.js} +1 -1
- package/dist/assets/{fr-_u2KT8VW.js → fr-C2hgGsGq.js} +1 -1
- package/dist/assets/{fuel-LAjBSdqB.js → fuel-DEa3ECY8.js} +1 -1
- package/dist/assets/{gen-access-key-BTl89uBT.js → gen-access-key-DrTcGDFb.js} +1 -1
- package/dist/assets/{gen-simple-access-key-CSNG83XC.js → gen-simple-access-key-DiDRmpFf.js} +1 -1
- package/dist/assets/get-safe-url-DOmcOTEp.js +1 -0
- package/dist/assets/{hi-D8HkmVe6.js → hi-DLl5_Grb.js} +1 -1
- package/dist/assets/hi-DtMqBGN3.js +5 -0
- package/dist/assets/{home-77gIsxv7.js → home-B7OWEVsn.js} +1 -1
- package/dist/assets/{id-BW7FB2Vj.js → id-BEDDZnYa.js} +1 -1
- package/dist/assets/{id-CbyxMpli.js → id-DfDk8Cxy.js} +1 -1
- package/dist/assets/{iframe-DUz4pKvd.js → iframe-CqwYISrF.js} +1 -1
- package/dist/assets/{index-BaofAoCa.js → index-296hnpGF.js} +1 -1
- package/dist/assets/{index-BVknf90c.js → index-78a5Cdpe.js} +1 -1
- package/dist/assets/{index-C9-vpsBs.js → index-AK4Fi3I2.js} +1 -1
- package/dist/assets/{index-D1UfZ73T.js → index-AbdeuSeu.js} +2 -2
- package/dist/assets/{index-CSX4LtVd.js → index-B-WiXXyt.js} +1 -1
- package/dist/assets/{index-BRrSUEyB.js → index-B-k9otcQ.js} +1 -1
- package/dist/assets/{index-BlUiIWvp.js → index-B0GLaTiX.js} +1 -1
- package/dist/assets/{index-CbB58MZZ.js → index-B4OZ6pVW.js} +1 -1
- package/dist/assets/{index-Vc0vthSd.js → index-BBIMESWU.js} +1 -1
- package/dist/assets/index-BDu1k7Fv.js +1 -0
- package/dist/assets/{index-9VirX3lP.js → index-BEmLxB7B.js} +1 -1
- package/dist/assets/{index-DL139d1R.js → index-BFOTYlfC.js} +3 -3
- package/dist/assets/{index-CLLf5x5M.js → index-Bbcgo0GF.js} +1 -1
- package/dist/assets/{index--zSWr4mJ.js → index-BetmKk0p.js} +1 -1
- package/dist/assets/{index-Bk_pomLR.js → index-C0mn0MnL.js} +2 -2
- package/dist/assets/{index-odXYgVVs.js → index-C4hly8RC.js} +1 -1
- package/dist/assets/index-CKesQXQW.js +1 -0
- package/dist/assets/{index-CGzwVlpv.js → index-Cbf4geph.js} +64 -64
- package/dist/assets/{index-GX1AZaVf.js → index-ChbREcnK.js} +1 -1
- package/dist/assets/{index-D1JnavLU.js → index-CiL_9BYm.js} +10 -10
- package/dist/assets/{index-BeEecuCm.js → index-CiW-jlCS.js} +1 -1
- package/dist/assets/{index-DFQY861i.js → index-Cylfu8Kg.js} +9 -9
- package/dist/assets/{index-BeaB_cKh.js → index-DLDRrQJH.js} +1 -1
- package/dist/assets/{index-BacwgICr.js → index-DSNvDaKK.js} +1 -1
- package/dist/assets/{index-DE4S7LPJ.js → index-Dj0TETp9.js} +1 -1
- package/dist/assets/{index-CdPVeM40.js → index-DlaHLSvf.js} +3 -3
- package/dist/assets/{index-Cvrw3K0w.js → index-DtuUsb1T.js} +1 -1
- package/dist/assets/{index-GX7JwwIf.js → index-LdkiJabL.js} +1 -1
- package/dist/assets/{index-Drthk0Vc.js → index-Nd6gD7eY.js} +1 -1
- package/dist/assets/{index-EQBtWV25.js → index-Yow2d7gN.js} +1 -1
- package/dist/assets/{index-DwQuzZ6W.js → index-diQW5vdJ.js} +1 -1
- package/dist/assets/{index-D7bQ7LFj.js → index-uY6moYTs.js} +1 -1
- package/dist/assets/{invitation-CxN6bhPz.js → invitation-D8IFGbTf.js} +6 -6
- package/dist/assets/{invite-heDOi1Gk.js → invite-bBNbkUJu.js} +1 -1
- package/dist/assets/{isURL-TswwHw1T.js → isURL-By2TdRfN.js} +1 -1
- package/dist/assets/{issue-passport-Bw40L4Ic.js → issue-passport-DaQDVQ7Y.js} +1 -1
- package/dist/assets/{item-ouNpV3tA.js → item-BhrhnieT.js} +1 -1
- package/dist/assets/{ja-CU32a4z_.js → ja-BXpHGJqS.js} +1 -1
- package/dist/assets/{ja-BPCCKkW4.js → ja-GXo4l4Hp.js} +1 -1
- package/dist/assets/{ko-Wbe93sio.js → ko-1dMP3P8A.js} +1 -1
- package/dist/assets/{ko-i76UFj1A.js → ko-CwVxJk3S.js} +1 -1
- package/dist/assets/{landing-page-DYuzaUFl.js → landing-page-k9p91AEv.js} +1 -1
- package/dist/assets/{launch-result-message-DDqxU5ge.js → launch-result-message-BTMFIbUm.js} +1 -1
- package/dist/assets/{layout-SbmsTmT-.js → layout-zg5WZEdp.js} +1 -1
- package/dist/assets/{list-9fyAFvMO.js → list-C6CNPBAR.js} +1 -1
- package/dist/assets/{list-DtmR-6Z4.js → list-CYJEZSon.js} +2 -2
- package/dist/assets/{list-header-BDPLDqO-.js → list-header-B8ZTLjYf.js} +1 -1
- package/dist/assets/localization-DFWXvHpl.js +1 -0
- package/dist/assets/{log-DvCqrgCp.js → log-ssfC90VX.js} +1 -1
- package/dist/assets/logger-D5kKPkv7.js +1 -0
- package/dist/assets/{login-BVFzm3Co.js → login-aFsf6-QM.js} +1 -1
- package/dist/assets/{login-oauth-callback-CMSYGfid.js → login-oauth-callback-dKBg8IoH.js} +1 -1
- package/dist/assets/{logo-uploader-BshflYAa.js → logo-uploader-D0Gz6YoY.js} +2 -2
- package/dist/assets/{lost-passport-CaPo9QEu.js → lost-passport-Bo6am6th.js} +1 -1
- package/dist/assets/{observability-C5Y6fafw.js → observability-Cfy3MVZa.js} +1 -1
- package/dist/assets/{omit-DDVAqzZq.js → omit-8QDODHip.js} +1 -1
- package/dist/assets/{open-window-BH5dHcbl.js → open-window-DBhAlL9B.js} +1 -1
- package/dist/assets/{over-due-invoice-payment-BA9fs62q.js → over-due-invoice-payment-D89GCKNm.js} +1 -1
- package/dist/assets/{overview-CHn4eBUK.js → overview-Xs3x6yXg.js} +1 -1
- package/dist/assets/{page-header-B9Q5ZOnJ.js → page-header-18voA300.js} +1 -1
- package/dist/assets/{passport-item-CqfuHfH-.js → passport-item-D-B7gJms.js} +1 -1
- package/dist/assets/{permission-BVTxHNeQ.js → permission-DqaOkW_Z.js} +1 -1
- package/dist/assets/{playground-DUuQxqZF.js → playground-CC7NZ-_A.js} +1 -1
- package/dist/assets/preferences-5iBfUn8N.js +1 -0
- package/dist/assets/profile-embed-MOxF7ggV.js +1 -0
- package/dist/assets/pt-5iS1WU13.js +5 -0
- package/dist/assets/{pt-CxrYVS03.js → pt-DM9_sWXT.js} +1 -1
- package/dist/assets/publish-resource-BBnSOgDd.js +1 -0
- package/dist/assets/{react-beautiful-dnd.esm-DY5UIQEa.js → react-beautiful-dnd.esm-DkLcR42r.js} +1 -1
- package/dist/assets/{react-stripe.esm-DlCFj5cL.js → react-stripe.esm-BqogJv7y.js} +1 -1
- package/dist/assets/{required-mwCee7dE.js → required-Df9AZf0R.js} +1 -1
- package/dist/assets/ru-DpIRvFxj.js +5 -0
- package/dist/assets/{ru-DRqpALK7.js → ru-DvP9XKXg.js} +1 -1
- package/dist/assets/runtime-DjILMoeT.js +1 -0
- package/dist/assets/{sanitize-d0BswqQy.js → sanitize-BSjwjSMl.js} +1 -1
- package/dist/assets/sdk-B-MwbsI_.js +1 -0
- package/dist/assets/{section-DkbgrVvQ.js → section-X04H4Q-a.js} +1 -1
- package/dist/assets/{security-D5f09NAi.js → security-BXhgiheS.js} +1 -1
- package/dist/assets/{session-CJYcrokL.js → session-89Q1nGxB.js} +1 -1
- package/dist/assets/setup-Da3ReRWd.js +30 -0
- package/dist/assets/{shorten-label-CzJmma8P.js → shorten-label-CdBn9U0H.js} +1 -1
- package/dist/assets/{simple-select-WHx-v2hU.js → simple-select-BkbgqOQi.js} +1 -1
- package/dist/assets/{spaces-B0VryU-h.js → spaces-BJeg7L1z.js} +1 -1
- package/dist/assets/{start-DdQSLbG1.js → start-CLueiUKJ.js} +1 -1
- package/dist/assets/{starting-progress-BOAJA87-.js → starting-progress-DWesZE5w.js} +1 -1
- package/dist/assets/{status-3ePg3iDr.js → status-DheLJdlM.js} +1 -1
- package/dist/assets/{step-actions-JxTPDo-C.js → step-actions-DmraEWCH.js} +1 -1
- package/dist/assets/{studio-BpropsaK.js → studio-C4flChud.js} +1 -1
- package/dist/assets/{switch-control-C3A7Bzd7.js → switch-control-BbRt1rRM.js} +1 -1
- package/dist/assets/{table-tips-BqAxYXjm.js → table-tips-73VcKMz1.js} +1 -1
- package/dist/assets/{team-DL-1lYRh.js → team-ZJuYy81P.js} +1 -1
- package/dist/assets/th-BjX3AJzF.js +5 -0
- package/dist/assets/{th-B1dDJjWM.js → th-DyGOy3ap.js} +1 -1
- package/dist/assets/{traffic-TO0gOocP.js → traffic-CMI1Sbrr.js} +1 -1
- package/dist/assets/{transfer-y-ql-f3C.js → transfer-CW4yMg3K.js} +1 -1
- package/dist/assets/{unsubscribe-ysldRIx6.js → unsubscribe-D3ZXIJIb.js} +1 -1
- package/dist/assets/{use-mobile-D0T_V7RQ.js → use-mobile-BDciCFXT.js} +1 -1
- package/dist/assets/{use-mobile-IWOBvgsY.js → use-mobile-BlpLWscF.js} +1 -1
- package/dist/assets/{use-promise-window-open-C5suxy-U.js → use-promise-window-open-u0untujg.js} +1 -1
- package/dist/assets/{use-server-logo-CUO3ZK3W.js → use-server-logo-lZp3Hq92.js} +1 -1
- package/dist/assets/{use-window-close-RhOoosk-.js → use-window-close-wo9PxrTe.js} +1 -1
- package/dist/assets/{useAsync-CQhKDImp.js → useAsync-BdgUavMa.js} +1 -1
- package/dist/assets/{useAsync-VHQLt8EO.js → useAsync-DgPr_To1.js} +1 -1
- package/dist/assets/{useLocalStorage-DIjnXt7A.js → useLocalStorage-B_thopuV.js} +1 -1
- package/dist/assets/{user-center-B-cbZnEv.js → user-center-D6gs6-WZ.js} +3 -3
- package/dist/assets/{user-sessions-0TRZeeJ5.js → user-sessions-B56a-4tA.js} +1 -1
- package/dist/assets/{util-h89lj_Gk.js → util-DQF9oPrf.js} +1 -1
- package/dist/assets/{util-CZwlQQjD.js → util-Dcj6HCP7.js} +1 -1
- package/dist/assets/{vendor-arcblock-CY7eM47O.js → vendor-arcblock--zSibe1w.js} +1 -1
- package/dist/assets/{vendor-hooks-B2bT6Nqf.js → vendor-hooks-DTeIFVkk.js} +1 -1
- package/dist/assets/{vendor-mui-core-Bw-IjQ9m.js → vendor-mui-core-BOHKtf8y.js} +1 -1
- package/dist/assets/{vendor-mui-x-tGuaJHw_.js → vendor-mui-x-16EG-AFj.js} +4 -4
- package/dist/assets/{vendor-utils-B4mliPf7.js → vendor-utils-BOkrEpKO.js} +1 -1
- package/dist/assets/{vendor-ux-e4SIahY6.js → vendor-ux-Cra9XTth.js} +2 -2
- package/dist/assets/vi-0Dtw7069.js +5 -0
- package/dist/assets/{vi-C5hdDVgc.js → vi-BWy1Jg4e.js} +1 -1
- package/dist/assets/{wait-connect-DrZC6ybw.js → wait-connect-CqwL_aoj.js} +1 -1
- package/dist/assets/wrap-locale-DAzAra4f.js +1 -0
- package/dist/assets/{zh-ZjW3xV_P.js → zh-BoO0jdid.js} +2 -2
- package/dist/assets/{zh-B8FiZw5R.js → zh-D_lJZbI3.js} +1 -1
- package/dist/assets/{zh-mA44AG8z.js → zh-DxCg9Pae.js} +1 -1
- package/dist/assets/{zh-tw-DPJ5sxST.js → zh-tw-CfWhHTHL.js} +1 -1
- package/dist/assets/{zh-tw-BuqwZI-0.js → zh-tw-D4_7lUjD.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/service-worker.js +1 -1
- package/package.json +37 -37
- package/dist/assets/AdapterDayjs-Dx6irzR8.js +0 -3
- package/dist/assets/aigne-B7-KeQ-z.js +0 -10
- package/dist/assets/api-B6VBwg-Z.js +0 -1
- package/dist/assets/button-NakGdoSQ.js +0 -1
- package/dist/assets/config-W238rhTW.js +0 -263
- package/dist/assets/dashboard-BDI5arRX.js +0 -106
- package/dist/assets/domains-BZ81E9og.js +0 -1
- package/dist/assets/engine-B2vjFFt9.js +0 -1
- package/dist/assets/get-safe-url-BSYF437j.js +0 -1
- package/dist/assets/hi-BMaS53lF.js +0 -5
- package/dist/assets/index-2oWhjD-V.js +0 -1
- package/dist/assets/index-DnYdLG8x.js +0 -1
- package/dist/assets/localization-Bi90G6aS.js +0 -1
- package/dist/assets/logger-DoOuw4D6.js +0 -1
- package/dist/assets/preferences--2YETF2t.js +0 -1
- package/dist/assets/profile-embed-BPQR6Tpe.js +0 -1
- package/dist/assets/pt-C1fHGXQk.js +0 -5
- package/dist/assets/publish-resource-qtIS1W3s.js +0 -1
- package/dist/assets/ru-DJ3aNml8.js +0 -5
- package/dist/assets/runtime-WLtCIkiy.js +0 -1
- package/dist/assets/sdk-CrmCUSu6.js +0 -1
- package/dist/assets/setup-chjxGOpx.js +0 -30
- package/dist/assets/th-C22KCFdo.js +0 -5
- package/dist/assets/vi-D_AWh4Q3.js +0 -5
- package/dist/assets/wrap-locale-vvkgV_w9.js +0 -1
package/api/libs/image.js
CHANGED
|
@@ -108,7 +108,8 @@ const getCacheFilePath = (dataDir, fileName) => {
|
|
|
108
108
|
return result;
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
// NOTICE: 如果传入了 fileName,则优先使用 fileName 的 extension,否则使用 req.path 的 extension
|
|
112
|
+
const isImageRequest = (req, fileName) => {
|
|
112
113
|
if (req.method !== 'GET') {
|
|
113
114
|
return false;
|
|
114
115
|
}
|
|
@@ -122,7 +123,8 @@ const isImageRequest = (req) => {
|
|
|
122
123
|
if (!req.query.imageFilter) {
|
|
123
124
|
return false;
|
|
124
125
|
}
|
|
125
|
-
const extension = toLower(path.extname(req.path).slice(1));
|
|
126
|
+
const extension = toLower(path.extname(fileName || req.path).slice(1));
|
|
127
|
+
|
|
126
128
|
if (extension && !FORMATS.includes(EXTENSIONS[extension])) {
|
|
127
129
|
return false;
|
|
128
130
|
}
|
|
@@ -138,95 +140,136 @@ const isImageRequest = (req) => {
|
|
|
138
140
|
|
|
139
141
|
const getImageContentType = (extension) => (extension === 'svg' ? 'image/svg+xml' : `image/${extension}`);
|
|
140
142
|
|
|
141
|
-
const processImage = (
|
|
143
|
+
const processImage = (srcStream, { extension, destPath, srcPath }, filterParams = {}) => {
|
|
142
144
|
return new Promise((resolve, reject) => {
|
|
143
145
|
// output stream
|
|
144
|
-
const out = fs.createWriteStream(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
const out = fs.createWriteStream(destPath);
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
// 这里是双重保障, /.blocklet/service/blocklet/logo 已经在 isImageRequest 中可以过滤掉了
|
|
150
|
+
// 此处只是为了增加健壮性,一般情况下不会到这里
|
|
151
|
+
if (extension && !FORMATS.includes(EXTENSIONS[extension])) {
|
|
152
|
+
// 如果是不支持的 extension,则将源文件直接写入目标地址
|
|
153
|
+
srcStream.pipe(out);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
148
156
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
157
|
+
out.on('close', () => {
|
|
158
|
+
resolve(destPath);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
out.on('error', (err) => {
|
|
162
|
+
reject(err);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const {
|
|
166
|
+
imageFilter,
|
|
167
|
+
w: width,
|
|
168
|
+
h: height,
|
|
169
|
+
t: top,
|
|
170
|
+
l: left,
|
|
171
|
+
q: quality,
|
|
172
|
+
f: format,
|
|
173
|
+
m: mode,
|
|
174
|
+
r: rotate,
|
|
175
|
+
p: progressive,
|
|
176
|
+
g: greyscale,
|
|
177
|
+
b: blur,
|
|
178
|
+
a: transparency,
|
|
179
|
+
n: negative,
|
|
180
|
+
s: sharpen,
|
|
181
|
+
} = filterParams;
|
|
182
|
+
|
|
183
|
+
const dimensions = { top, left };
|
|
184
|
+
if (width) {
|
|
185
|
+
dimensions.width = width;
|
|
186
|
+
}
|
|
187
|
+
if (height) {
|
|
188
|
+
dimensions.height = height;
|
|
189
|
+
}
|
|
152
190
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
} = params;
|
|
170
|
-
|
|
171
|
-
const dimensions = { top, left };
|
|
172
|
-
if (width) {
|
|
173
|
-
dimensions.width = width;
|
|
174
|
-
}
|
|
175
|
-
if (height) {
|
|
176
|
-
dimensions.height = height;
|
|
177
|
-
}
|
|
191
|
+
const pipeline = sharp({ animated: true, limitInputPixels: 0 }).timeout({ seconds: 60 });
|
|
192
|
+
if (rotate) {
|
|
193
|
+
pipeline.rotate(rotate);
|
|
194
|
+
}
|
|
195
|
+
if (imageFilter === 'resize') {
|
|
196
|
+
if (!dimensions.width && !dimensions.height) {
|
|
197
|
+
reject(new CustomError(400, 'At least one of `w` or `h` must be provided to resize'));
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (dimensions.width || dimensions.height) {
|
|
202
|
+
pipeline.resize({ ...dimensions, fit: mode, withoutEnlargement: true });
|
|
203
|
+
}
|
|
204
|
+
if (imageFilter === 'crop') {
|
|
205
|
+
pipeline.extract(dimensions);
|
|
206
|
+
}
|
|
178
207
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
208
|
+
if (sharpen) {
|
|
209
|
+
pipeline.sharpen(sharpen);
|
|
210
|
+
}
|
|
211
|
+
if (blur) {
|
|
212
|
+
pipeline.blur(blur);
|
|
213
|
+
}
|
|
214
|
+
if (greyscale) {
|
|
215
|
+
pipeline.greyscale();
|
|
216
|
+
}
|
|
217
|
+
if (transparency) {
|
|
218
|
+
pipeline.ensureAlpha();
|
|
219
|
+
} else {
|
|
220
|
+
pipeline.removeAlpha();
|
|
221
|
+
}
|
|
222
|
+
if (negative) {
|
|
223
|
+
pipeline.negate();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const processFn = pipeline[format || EXTENSIONS[extension]];
|
|
227
|
+
// 如果 sharp 实例中不包含目标 extension 的转换方法,则将源文件直接写入目标地址
|
|
228
|
+
if (!processFn || processFn instanceof Function === false) {
|
|
229
|
+
srcStream.pipe(out);
|
|
186
230
|
return;
|
|
187
231
|
}
|
|
188
|
-
}
|
|
189
|
-
if (dimensions.width || dimensions.height) {
|
|
190
|
-
pipeline.resize({ ...dimensions, fit: mode, withoutEnlargement: true });
|
|
191
|
-
}
|
|
192
|
-
if (imageFilter === 'crop') {
|
|
193
|
-
pipeline.extract(dimensions);
|
|
194
|
-
}
|
|
195
232
|
|
|
196
|
-
|
|
197
|
-
pipeline
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
pipeline
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
233
|
+
// HACK: 这里不能使用 processFn 来替代,会导致图片处理出错(猜测是 this 指针的问题)
|
|
234
|
+
pipeline[format || EXTENSIONS[extension]]({ quality, progressive: !!progressive, dither: 0, force: true });
|
|
235
|
+
|
|
236
|
+
pipeline.on('error', (err) => {
|
|
237
|
+
reject(err);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// run the pipeline
|
|
241
|
+
srcStream.pipe(pipeline).pipe(out);
|
|
242
|
+
} catch (err) {
|
|
243
|
+
logger.error('image filter failed', {
|
|
244
|
+
error: err,
|
|
245
|
+
filterParams,
|
|
246
|
+
srcPath,
|
|
247
|
+
destPath,
|
|
248
|
+
extension,
|
|
249
|
+
});
|
|
250
|
+
srcStream.pipe(out);
|
|
209
251
|
}
|
|
210
|
-
if (negative) {
|
|
211
|
-
pipeline.negate();
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
pipeline[format || EXTENSIONS[extension]]({ quality, progressive: !!progressive, dither: 0, force: true });
|
|
215
|
-
|
|
216
|
-
pipeline.on('error', (err) => {
|
|
217
|
-
reject(err);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
// run the pipeline
|
|
221
|
-
src.pipe(pipeline).pipe(out);
|
|
222
252
|
}).catch((err) => {
|
|
223
|
-
rmSync(
|
|
253
|
+
rmSync(destPath, { force: true });
|
|
224
254
|
throw err;
|
|
225
255
|
});
|
|
226
256
|
};
|
|
227
257
|
|
|
228
258
|
const tasks = {};
|
|
229
|
-
const processAndRespond = (
|
|
259
|
+
const processAndRespond = (
|
|
260
|
+
req,
|
|
261
|
+
res,
|
|
262
|
+
{
|
|
263
|
+
srcPath,
|
|
264
|
+
cacheDir,
|
|
265
|
+
getSrc,
|
|
266
|
+
extension: ext,
|
|
267
|
+
sendOptions = {
|
|
268
|
+
maxAge: '356d',
|
|
269
|
+
immutable: true,
|
|
270
|
+
},
|
|
271
|
+
}
|
|
272
|
+
) => {
|
|
230
273
|
if (fs.existsSync(cacheDir) === false) {
|
|
231
274
|
fs.mkdirSync(cacheDir, { recursive: true });
|
|
232
275
|
}
|
|
@@ -255,6 +298,7 @@ const processAndRespond = (req, res, cacheDir, getSrc, ext, sendOptions = { maxA
|
|
|
255
298
|
|
|
256
299
|
const cacheKey = md5(stringify({ target: req.target, path: req.originalUrl, params }));
|
|
257
300
|
const destPath = getCacheFilePath(cacheDir, `${cacheKey}.${params.f || extension}`);
|
|
301
|
+
|
|
258
302
|
if (fs.existsSync(destPath)) {
|
|
259
303
|
res.header('Content-Type', getImageContentType(params.f || extension));
|
|
260
304
|
res.sendFile(destPath, sendOptions);
|
|
@@ -263,7 +307,17 @@ const processAndRespond = (req, res, cacheDir, getSrc, ext, sendOptions = { maxA
|
|
|
263
307
|
|
|
264
308
|
// do the convert
|
|
265
309
|
tasks[cacheKey] ??= getSrc(req)
|
|
266
|
-
.then(([src, _extension]) =>
|
|
310
|
+
.then(([src, _extension]) =>
|
|
311
|
+
processImage(
|
|
312
|
+
src,
|
|
313
|
+
{
|
|
314
|
+
extension: toLower(_extension),
|
|
315
|
+
destPath,
|
|
316
|
+
srcPath,
|
|
317
|
+
},
|
|
318
|
+
params
|
|
319
|
+
)
|
|
320
|
+
)
|
|
267
321
|
.finally(() => {
|
|
268
322
|
setTimeout(() => {
|
|
269
323
|
delete tasks[cacheKey];
|
package/api/routes/blocklet.js
CHANGED
|
@@ -74,17 +74,16 @@ module.exports = {
|
|
|
74
74
|
|
|
75
75
|
const attachSendLogoFn = (req, res, next) => {
|
|
76
76
|
res.sendLogoFile = (fileName, options) => {
|
|
77
|
-
if (isImageRequest(req)) {
|
|
77
|
+
if (isImageRequest(req, fileName)) {
|
|
78
78
|
logger.info('send logo with image service', { fileName, options });
|
|
79
79
|
const appDir = path.join(req.blocklet.env.cacheDir, '.services', 'image-filter');
|
|
80
|
-
processAndRespond(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
);
|
|
80
|
+
processAndRespond(req, res, {
|
|
81
|
+
srcPath: fileName,
|
|
82
|
+
cacheDir: appDir,
|
|
83
|
+
getSrc: () => Promise.resolve([fs.createReadStream(fileName), path.extname(fileName).slice(1)]),
|
|
84
|
+
extension: path.extname(fileName).slice(1),
|
|
85
|
+
sendOptions: req.sendOptions,
|
|
86
|
+
});
|
|
88
87
|
} else {
|
|
89
88
|
logger.info('send logo with file', { fileName, options });
|
|
90
89
|
res.sendFile(fileName, options);
|
|
@@ -165,20 +164,24 @@ module.exports = {
|
|
|
165
164
|
}
|
|
166
165
|
}
|
|
167
166
|
|
|
168
|
-
const
|
|
169
|
-
if (!fs.existsSync(
|
|
167
|
+
const avatarFilePath = getAvatarFile(dataDir, fileName);
|
|
168
|
+
if (!fs.existsSync(avatarFilePath)) {
|
|
170
169
|
res.status(404).send('Avatar Not Found');
|
|
171
170
|
return;
|
|
172
171
|
}
|
|
173
172
|
|
|
174
173
|
if (isImageAccepted(req) && isImageRequest(req)) {
|
|
175
174
|
const appDir = path.join(cacheDir, '.services', 'image-filter');
|
|
176
|
-
processAndRespond(req, res,
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
processAndRespond(req, res, {
|
|
176
|
+
srcPath: avatarFilePath,
|
|
177
|
+
cacheDir: appDir,
|
|
178
|
+
getSrc: () => {
|
|
179
|
+
stream = fs.createReadStream(avatarFilePath);
|
|
180
|
+
return Promise.resolve([stream, path.extname(avatarFilePath).slice(1)]);
|
|
181
|
+
},
|
|
179
182
|
});
|
|
180
183
|
} else {
|
|
181
|
-
res.sendFile(
|
|
184
|
+
res.sendFile(avatarFilePath, { maxAge: '365d', immutable: true });
|
|
182
185
|
}
|
|
183
186
|
} catch (err) {
|
|
184
187
|
stream?.destroy();
|
|
@@ -561,7 +564,7 @@ module.exports = {
|
|
|
561
564
|
info.ogImageHash = encodeURIComponent(ogImage.split('/').slice(-1)[0].slice(0, 7));
|
|
562
565
|
}
|
|
563
566
|
|
|
564
|
-
const
|
|
567
|
+
const sourceFilePath = await getOgImage({
|
|
565
568
|
input: req.query,
|
|
566
569
|
info,
|
|
567
570
|
format,
|
|
@@ -570,12 +573,16 @@ module.exports = {
|
|
|
570
573
|
});
|
|
571
574
|
if (format === 'png' && isImageAccepted(req) && isImageRequest(req)) {
|
|
572
575
|
const appDir = getAppImageCacheDir(blocklet.env.cacheDir);
|
|
573
|
-
processAndRespond(req, res,
|
|
574
|
-
|
|
575
|
-
|
|
576
|
+
processAndRespond(req, res, {
|
|
577
|
+
srcPath: sourceFilePath,
|
|
578
|
+
cacheDir: appDir,
|
|
579
|
+
getSrc: () => {
|
|
580
|
+
stream = fs.createReadStream(sourceFilePath);
|
|
581
|
+
return Promise.resolve([stream, path.extname(sourceFilePath).slice(1)]);
|
|
582
|
+
},
|
|
576
583
|
});
|
|
577
584
|
} else {
|
|
578
|
-
res.sendFile(
|
|
585
|
+
res.sendFile(sourceFilePath, cache ? { maxAge: '365d', immutable: true } : { maxAge: 0 });
|
|
579
586
|
}
|
|
580
587
|
} catch (err) {
|
|
581
588
|
stream?.destroy();
|
|
@@ -591,17 +598,21 @@ module.exports = {
|
|
|
591
598
|
const blocklet = await req.getBlocklet();
|
|
592
599
|
const appSplash = get(blocklet, `environmentObj.BLOCKLET_APP_SPLASH_${type.toUpperCase()}`);
|
|
593
600
|
if (appSplash) {
|
|
594
|
-
const
|
|
595
|
-
if (fs.existsSync(
|
|
601
|
+
const splashFilePath = path.join(get(blocklet, 'env.dataDir'), appSplash);
|
|
602
|
+
if (fs.existsSync(splashFilePath)) {
|
|
596
603
|
if (isImageRequest(req)) {
|
|
597
604
|
const appDir = getAppImageCacheDir(blocklet.env.cacheDir);
|
|
598
|
-
processAndRespond(req, res,
|
|
599
|
-
|
|
600
|
-
|
|
605
|
+
processAndRespond(req, res, {
|
|
606
|
+
srcPath: splashFilePath,
|
|
607
|
+
cacheDir: appDir,
|
|
608
|
+
getSrc: () => {
|
|
609
|
+
stream = fs.createReadStream(splashFilePath);
|
|
610
|
+
return Promise.resolve([stream, path.extname(splashFilePath).slice(1)]);
|
|
611
|
+
},
|
|
601
612
|
});
|
|
602
613
|
} else {
|
|
603
614
|
const cache = req.query.nocache !== '1';
|
|
604
|
-
res.sendFile(
|
|
615
|
+
res.sendFile(splashFilePath, cache ? { maxAge: '365d', immutable: true } : { maxAge: 0 });
|
|
605
616
|
}
|
|
606
617
|
} else {
|
|
607
618
|
res.sendFile(`/images/splash-${type}.png`, { root: staticDir, maxAge: '1h' });
|
|
@@ -622,17 +633,21 @@ module.exports = {
|
|
|
622
633
|
const blocklet = await req.getBlocklet();
|
|
623
634
|
const appOgImage = get(blocklet, 'environmentObj.BLOCKLET_APP_OG_IMAGE');
|
|
624
635
|
if (appOgImage) {
|
|
625
|
-
const
|
|
626
|
-
if (fs.existsSync(
|
|
636
|
+
const ogImageFilePath = path.join(get(blocklet, 'env.dataDir'), appOgImage);
|
|
637
|
+
if (fs.existsSync(ogImageFilePath)) {
|
|
627
638
|
if (isImageRequest(req)) {
|
|
628
639
|
const appDir = getAppImageCacheDir(blocklet.env.cacheDir);
|
|
629
|
-
processAndRespond(req, res,
|
|
630
|
-
|
|
631
|
-
|
|
640
|
+
processAndRespond(req, res, {
|
|
641
|
+
srcPath: ogImageFilePath,
|
|
642
|
+
cacheDir: appDir,
|
|
643
|
+
getSrc: () => {
|
|
644
|
+
stream = fs.createReadStream(ogImageFilePath);
|
|
645
|
+
return Promise.resolve([stream, path.extname(ogImageFilePath).slice(1)]);
|
|
646
|
+
},
|
|
632
647
|
});
|
|
633
648
|
} else {
|
|
634
649
|
const cache = req.query.nocache !== '1';
|
|
635
|
-
res.sendFile(
|
|
650
|
+
res.sendFile(ogImageFilePath, cache ? { maxAge: '365d', immutable: true } : { maxAge: 0 });
|
|
636
651
|
}
|
|
637
652
|
} else {
|
|
638
653
|
res.sendFile('/images/og-image.jpg', { root: staticDir, maxAge: '1h' });
|
package/api/routes/csp-proxy.js
CHANGED
|
@@ -55,36 +55,37 @@ module.exports = {
|
|
|
55
55
|
const { url } = req.query;
|
|
56
56
|
|
|
57
57
|
if (!url) {
|
|
58
|
-
res.status(400).send('
|
|
58
|
+
res.status(400).send('Invalid parameter');
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
if (!isUrl(url)) {
|
|
63
|
-
res.status(400).send('Invalid
|
|
63
|
+
res.status(400).send('Invalid parameter');
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// 检查referer来源
|
|
68
68
|
if (!checkReferer(req)) {
|
|
69
|
-
res.status(403).send('
|
|
69
|
+
res.status(403).send('Invalid parameter');
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
try {
|
|
74
74
|
const tmp = new URL(url);
|
|
75
75
|
if (tmp.protocol !== 'https:') {
|
|
76
|
-
res.status(400).send('
|
|
76
|
+
res.status(400).send('Invalid parameter');
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// 检查是否为内网地址,防止SSRF攻击
|
|
81
81
|
if (isPrivateIP(tmp.hostname)) {
|
|
82
|
-
res.status(400).send('
|
|
82
|
+
res.status(400).send('Invalid parameter');
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
// 配置axios请求,确保不传递用户的cookie等认证信息
|
|
87
87
|
const requestConfig = {
|
|
88
|
+
maxRedirects: 0,
|
|
88
89
|
headers: {
|
|
89
90
|
'User-Agent': 'BlockletServer-CSP-Proxy/1.0',
|
|
90
91
|
},
|
|
@@ -94,7 +95,6 @@ module.exports = {
|
|
|
94
95
|
const response = await axios.get(url, {
|
|
95
96
|
...requestConfig,
|
|
96
97
|
responseType: 'stream',
|
|
97
|
-
maxRedirects: 3,
|
|
98
98
|
});
|
|
99
99
|
|
|
100
100
|
// 立即检查响应的content-type
|
|
@@ -102,7 +102,7 @@ module.exports = {
|
|
|
102
102
|
if (!isAllowedContentType(contentType)) {
|
|
103
103
|
// 立即销毁stream并返回错误,避免继续下载
|
|
104
104
|
response.data.destroy();
|
|
105
|
-
res.status(400).send('
|
|
105
|
+
res.status(400).send('Invalid parameter');
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -173,7 +173,7 @@ module.exports = {
|
|
|
173
173
|
} else if (error.response && error.response.status) {
|
|
174
174
|
res.status(error.response.status).send(`Remote server error: ${error.response.status}`);
|
|
175
175
|
} else {
|
|
176
|
-
res.status(400).send('
|
|
176
|
+
res.status(400).send('Invalid parameter');
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
});
|
package/api/routes/user.js
CHANGED
|
@@ -988,12 +988,16 @@ module.exports = {
|
|
|
988
988
|
const { token } = req;
|
|
989
989
|
if (token) {
|
|
990
990
|
const sessionTtl = jwtDecode(token).exp * 1000 - Date.now();
|
|
991
|
-
|
|
991
|
+
if (sessionTtl > 0) {
|
|
992
|
+
await cache.sessionToken.set(md5(token), { block: true }, { ttl: sessionTtl });
|
|
993
|
+
}
|
|
992
994
|
}
|
|
993
995
|
// 兼容旧版本,API 不会携带 refreshToken 的情况
|
|
994
996
|
if (refreshToken) {
|
|
995
997
|
const refreshTtl = jwtDecode(refreshToken).exp * 1000 - Date.now();
|
|
996
|
-
|
|
998
|
+
if (refreshTtl > 0) {
|
|
999
|
+
await cache.refreshToken.set(md5(refreshToken), { block: true }, { ttl: refreshTtl });
|
|
1000
|
+
}
|
|
997
1001
|
}
|
|
998
1002
|
} catch (err) {
|
|
999
1003
|
logger.error('Failed to block session token & refresh token', { error: err });
|
|
@@ -11,7 +11,8 @@ const logger = require('../../../libs/logger')();
|
|
|
11
11
|
const { createTokenFn, getDidConnectVersion } = require('../../../util');
|
|
12
12
|
const { getTrustedIssuers } = require('../../../util/blocklet-utils');
|
|
13
13
|
|
|
14
|
-
const ALLOWED_ROLES = [ROLES.OWNER, ROLES.ADMIN, ROLES.MEMBER];
|
|
14
|
+
const ALLOWED_ROLES = [ROLES.OWNER, ROLES.ADMIN, ROLES.MEMBER, ROLES.GUEST];
|
|
15
|
+
const SKIP_VERIFY_ACTIONS = ['deleteAccessKey'];
|
|
15
16
|
|
|
16
17
|
// eslint-disable-next-line no-unused-vars
|
|
17
18
|
module.exports = function createRoutes(node, authenticator, createSessionToken) {
|
|
@@ -32,8 +33,20 @@ module.exports = function createRoutes(node, authenticator, createSessionToken)
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
const expected = validateVerifyDestroyRequest({ payload, roles, locale, allowedRoles: ALLOWED_ROLES });
|
|
36
|
+
const parsed = JSON.parse(fromBase64(payload).toString());
|
|
35
37
|
|
|
36
38
|
const sourceAppPid = getSourceAppPid(request);
|
|
39
|
+
if (!user.passports?.length && SKIP_VERIFY_ACTIONS.includes(parsed.action)) {
|
|
40
|
+
return {
|
|
41
|
+
verifiableCredential: {
|
|
42
|
+
type: 'verifiableCredential',
|
|
43
|
+
description: messages.requestPassport[locale],
|
|
44
|
+
optional: true,
|
|
45
|
+
trustedIssuers: await getTrustedIssuers(blocklet, { sourceAppPid }),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
37
50
|
return {
|
|
38
51
|
verifiableCredential: getVerifyAccessClaims({
|
|
39
52
|
node,
|
|
@@ -50,6 +63,16 @@ module.exports = function createRoutes(node, authenticator, createSessionToken)
|
|
|
50
63
|
const { locale, payload } = extraParams;
|
|
51
64
|
const sourceAppPid = getSourceAppPid(request);
|
|
52
65
|
const [blocklet, blockletInfo] = await Promise.all([request.getBlocklet(), request.getBlockletInfo()]);
|
|
66
|
+
const userInfo = await node.getUser({
|
|
67
|
+
teamDid: blocklet.appPid,
|
|
68
|
+
user: { did: userDid },
|
|
69
|
+
options: { enableConnectedAccount: true },
|
|
70
|
+
});
|
|
71
|
+
const parsed = JSON.parse(fromBase64(payload).toString());
|
|
72
|
+
|
|
73
|
+
if (!userInfo.passports?.length && SKIP_VERIFY_ACTIONS.includes(parsed.action)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
53
76
|
|
|
54
77
|
const { role, user, passport } = await authenticateByVc({
|
|
55
78
|
node,
|
|
@@ -84,7 +107,6 @@ module.exports = function createRoutes(node, authenticator, createSessionToken)
|
|
|
84
107
|
);
|
|
85
108
|
}
|
|
86
109
|
|
|
87
|
-
const parsed = JSON.parse(fromBase64(payload).toString());
|
|
88
110
|
const session = await node.startSession({ data: { ...parsed, type: 'destroy', operator: userDid } });
|
|
89
111
|
|
|
90
112
|
logger.info('DestroySession.start', { sessionId: session.id, parsed, userDid, role });
|
|
@@ -441,11 +441,15 @@ module.exports = {
|
|
|
441
441
|
});
|
|
442
442
|
if (requestSessionToken) {
|
|
443
443
|
const sessionTtl = jwtDecode(requestSessionToken).exp * 1000 - Date.now();
|
|
444
|
-
|
|
444
|
+
if (sessionTtl > 0) {
|
|
445
|
+
await cache.sessionToken.set(md5(requestSessionToken), { block: true }, { ttl: sessionTtl });
|
|
446
|
+
}
|
|
445
447
|
}
|
|
446
448
|
if (req.refreshToken) {
|
|
447
449
|
const refreshTtl = jwtDecode(req.refreshToken).exp * 1000 - Date.now();
|
|
448
|
-
|
|
450
|
+
if (refreshTtl > 0) {
|
|
451
|
+
await cache.refreshToken.set(md5(req.refreshToken), { block: true }, { ttl: refreshTtl });
|
|
452
|
+
}
|
|
449
453
|
}
|
|
450
454
|
|
|
451
455
|
res.json(
|
|
@@ -55,7 +55,12 @@ const createImageService = ({ node }) => {
|
|
|
55
55
|
|
|
56
56
|
const processImage = (req, res) => {
|
|
57
57
|
const appDir = getAppImageCacheDir(path.join(node.dataDirs.cache, req.getBlockletDid()));
|
|
58
|
-
|
|
58
|
+
const upstreamUrl = new URL(req.originalUrl, req.target);
|
|
59
|
+
processAndRespond(req, res, {
|
|
60
|
+
srcPath: upstreamUrl.href,
|
|
61
|
+
cacheDir: appDir,
|
|
62
|
+
getSrc: getUpstreamImage,
|
|
63
|
+
});
|
|
59
64
|
};
|
|
60
65
|
|
|
61
66
|
return {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{_ as lt}from"./vendor-mui-core-BOHKtf8y.js";import{d as c}from"./vendor-hooks-DTeIFVkk.js";import{g as G}from"./vendor-react-Dvs43sk9.js";import{a1 as yt}from"./vendor-ux-Cra9XTth.js";var b={exports:{}},pt=b.exports,rt;function Mt(){return rt||(rt=1,function(Y,z){(function(m,t){Y.exports=t()})(pt,function(){var m="week",t="year";return function(e,i,a){var r=i.prototype;r.week=function(s){if(s===void 0&&(s=null),s!==null)return this.add(7*(s-this.week()),"day");var u=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var h=a(this).startOf(t).add(1,t).date(u),l=a(this).endOf(m);if(h.isBefore(l))return 1}var O=a(this).startOf(t).date(u).startOf(m).subtract(1,"millisecond"),$=this.diff(O,m,!0);return $<0?a(this).startOf("week").week():Math.ceil($)},r.weeks=function(s){return s===void 0&&(s=null),this.week(s)}}})}(b)),b.exports}var Tt=Mt();const gt=G(Tt);var I={exports:{}},Dt=I.exports,st;function wt(){return st||(st=1,function(Y,z){(function(m,t){Y.exports=t()})(Dt,function(){var m={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,e=/\d/,i=/\d\d/,a=/\d\d?/,r=/\d*[^-_:/,()\s\d]+/,s={},u=function(n){return(n=+n)+(n>68?1900:2e3)},h=function(n){return function(o){this[n]=+o}},l=[/[+-]\d\d:?(\d\d)?|Z/,function(n){(this.zone||(this.zone={})).offset=function(o){if(!o||o==="Z")return 0;var f=o.match(/([+-]|\d\d)/g),d=60*f[1]+(+f[2]||0);return d===0?0:f[0]==="+"?-d:d}(n)}],O=function(n){var o=s[n];return o&&(o.indexOf?o:o.s.concat(o.f))},$=function(n,o){var f,d=s.meridiem;if(d){for(var T=1;T<=24;T+=1)if(n.indexOf(d(T,0,o))>-1){f=T>12;break}}else f=n===(o?"pm":"PM");return f},ot={A:[r,function(n){this.afternoon=$(n,!1)}],a:[r,function(n){this.afternoon=$(n,!0)}],Q:[e,function(n){this.month=3*(n-1)+1}],S:[e,function(n){this.milliseconds=100*+n}],SS:[i,function(n){this.milliseconds=10*+n}],SSS:[/\d{3}/,function(n){this.milliseconds=+n}],s:[a,h("seconds")],ss:[a,h("seconds")],m:[a,h("minutes")],mm:[a,h("minutes")],H:[a,h("hours")],h:[a,h("hours")],HH:[a,h("hours")],hh:[a,h("hours")],D:[a,h("day")],DD:[i,h("day")],Do:[r,function(n){var o=s.ordinal,f=n.match(/\d+/);if(this.day=f[0],o)for(var d=1;d<=31;d+=1)o(d).replace(/\[|\]/g,"")===n&&(this.day=d)}],w:[a,h("week")],ww:[i,h("week")],M:[a,h("month")],MM:[i,h("month")],MMM:[r,function(n){var o=O("months"),f=(O("monthsShort")||o.map(function(d){return d.slice(0,3)})).indexOf(n)+1;if(f<1)throw new Error;this.month=f%12||f}],MMMM:[r,function(n){var o=O("months").indexOf(n)+1;if(o<1)throw new Error;this.month=o%12||o}],Y:[/[+-]?\d+/,h("year")],YY:[i,function(n){this.year=u(n)}],YYYY:[/\d{4}/,h("year")],Z:l,ZZ:l};function ht(n){var o,f;o=n,f=s&&s.formats;for(var d=(n=o.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(C,x,M){var p=M&&M.toUpperCase();return x||f[M]||m[M]||f[p].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(k,L,j){return L||j.slice(1)})})).match(t),T=d.length,g=0;g<T;g+=1){var U=d[g],S=ot[U],D=S&&S[0],w=S&&S[1];d[g]=w?{regex:D,parser:w}:U.replace(/^\[|\]$/g,"")}return function(C){for(var x={},M=0,p=0;M<T;M+=1){var k=d[M];if(typeof k=="string")p+=k.length;else{var L=k.regex,j=k.parser,A=C.slice(p),v=L.exec(A)[0];j.call(x,v),C=C.replace(v,"")}}return function(P){var F=P.afternoon;if(F!==void 0){var y=P.hours;F?y<12&&(P.hours+=12):y===12&&(P.hours=0),delete P.afternoon}}(x),x}}return function(n,o,f){f.p.customParseFormat=!0,n&&n.parseTwoDigitYear&&(u=n.parseTwoDigitYear);var d=o.prototype,T=d.parse;d.parse=function(g){var U=g.date,S=g.utc,D=g.args;this.$u=S;var w=D[1];if(typeof w=="string"){var C=D[2]===!0,x=D[3]===!0,M=C||x,p=D[2];x&&(p=D[2]),s=this.$locale(),!C&&p&&(s=f.Ls[p]),this.$d=function(A,v,P,F){try{if(["x","X"].indexOf(v)>-1)return new Date((v==="X"?1e3:1)*A);var y=ht(v)(A),Z=y.year,W=y.month,ut=y.day,ft=y.hours,dt=y.minutes,ct=y.seconds,mt=y.milliseconds,tt=y.zone,et=y.week,N=new Date,_=ut||(Z||W?1:N.getDate()),q=Z||N.getFullYear(),H=0;Z&&!W||(H=W>0?W-1:N.getMonth());var B,R=ft||0,Q=dt||0,X=ct||0,J=mt||0;return tt?new Date(Date.UTC(q,H,_,R,Q,X,J+60*tt.offset*1e3)):P?new Date(Date.UTC(q,H,_,R,Q,X,J)):(B=new Date(q,H,_,R,Q,X,J),et&&(B=F(B).week(et).toDate()),B)}catch{return new Date("")}}(U,w,S,f),this.init(),p&&p!==!0&&(this.$L=this.locale(p).$L),M&&U!=this.format(w)&&(this.$d=new Date("")),s={}}else if(w instanceof Array)for(var k=w.length,L=1;L<=k;L+=1){D[1]=w[L-1];var j=f.apply(this,D);if(j.isValid()){this.$d=j.$d,this.$L=j.$L,this.init();break}L===k&&(this.$d=new Date(""))}else T.call(this,g)}}})}(I)),I.exports}var Yt=wt();const Ot=G(Yt);var E={exports:{}},xt=E.exports,nt;function kt(){return nt||(nt=1,function(Y,z){(function(m,t){Y.exports=t()})(xt,function(){return function(m,t,e){t.prototype.isBetween=function(i,a,r,s){var u=e(i),h=e(a),l=(s=s||"()")[0]==="(",O=s[1]===")";return(l?this.isAfter(u,r):!this.isBefore(u,r))&&(O?this.isBefore(h,r):!this.isAfter(h,r))||(l?this.isBefore(u,r):!this.isAfter(u,r))&&(O?this.isAfter(h,r):!this.isBefore(h,r))}}})}(E)),E.exports}var Lt=kt();const zt=G(Lt);var V={exports:{}},St=V.exports,it;function Ct(){return it||(it=1,function(Y,z){(function(m,t){Y.exports=t()})(St,function(){return function(m,t){var e=t.prototype,i=e.format;e.format=function(a){var r=this,s=this.$locale();if(!this.isValid())return i.bind(this)(a);var u=this.$utils(),h=(a||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(l){switch(l){case"Q":return Math.ceil((r.$M+1)/3);case"Do":return s.ordinal(r.$D);case"gggg":return r.weekYear();case"GGGG":return r.isoWeekYear();case"wo":return s.ordinal(r.week(),"W");case"w":case"ww":return u.s(r.week(),l==="w"?1:2,"0");case"W":case"WW":return u.s(r.isoWeek(),l==="W"?1:2,"0");case"k":case"kk":return u.s(String(r.$H===0?24:r.$H),l==="k"?1:2,"0");case"X":return Math.floor(r.$d.getTime()/1e3);case"x":return r.$d.getTime();case"z":return"["+r.offsetName()+"]";case"zzz":return"["+r.offsetName("long")+"]";default:return l}});return i.bind(this)(h)}}})}(V)),V.exports}var jt=Ct();const Pt=G(jt);c.extend(yt);c.extend(gt);c.extend(zt);c.extend(Pt);const vt={YY:"year",YYYY:{sectionType:"year",contentType:"digit",maxLength:4},M:{sectionType:"month",contentType:"digit",maxLength:2},MM:"month",MMM:{sectionType:"month",contentType:"letter"},MMMM:{sectionType:"month",contentType:"letter"},D:{sectionType:"day",contentType:"digit",maxLength:2},DD:"day",Do:{sectionType:"day",contentType:"digit-with-letter"},d:{sectionType:"weekDay",contentType:"digit",maxLength:2},dd:{sectionType:"weekDay",contentType:"letter"},ddd:{sectionType:"weekDay",contentType:"letter"},dddd:{sectionType:"weekDay",contentType:"letter"},A:"meridiem",a:"meridiem",H:{sectionType:"hours",contentType:"digit",maxLength:2},HH:"hours",h:{sectionType:"hours",contentType:"digit",maxLength:2},hh:"hours",m:{sectionType:"minutes",contentType:"digit",maxLength:2},mm:"minutes",s:{sectionType:"seconds",contentType:"digit",maxLength:2},ss:"seconds"},$t={year:"YYYY",month:"MMMM",monthShort:"MMM",dayOfMonth:"D",dayOfMonthFull:"Do",weekday:"dddd",weekdayShort:"dd",hours24h:"HH",hours12h:"hh",meridiem:"A",minutes:"mm",seconds:"ss",fullDate:"ll",keyboardDate:"L",shortDate:"MMM D",normalDate:"D MMMM",normalDateWithWeekday:"ddd, MMM D",fullTime12h:"hh:mm A",fullTime24h:"HH:mm",keyboardDateTime12h:"L hh:mm A",keyboardDateTime24h:"L HH:mm"},K=["Missing UTC plugin","To be able to use UTC or timezones, you have to enable the `utc` plugin","Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-utc"].join(`
|
|
2
|
+
`),at=["Missing timezone plugin","To be able to use timezones, you have to enable both the `utc` and the `timezone` plugin","Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-timezone"].join(`
|
|
3
|
+
`);class Bt{constructor({locale:z,formats:m}={}){this.isMUIAdapter=!0,this.isTimezoneCompatible=!0,this.lib="dayjs",this.locale=void 0,this.formats=void 0,this.escapedCharacters={start:"[",end:"]"},this.formatTokenMap=vt,this.setLocaleToValue=t=>{const e=this.getCurrentLocaleCode();return e===t.locale()?t:t.locale(e)},this.hasUTCPlugin=()=>typeof c.utc<"u",this.hasTimezonePlugin=()=>typeof c.tz<"u",this.isSame=(t,e,i)=>{const a=this.setTimezone(e,this.getTimezone(t));return t.format(i)===a.format(i)},this.cleanTimezone=t=>{switch(t){case"default":return;case"system":return c.tz.guess();default:return t}},this.createSystemDate=t=>{let e;if(this.hasUTCPlugin()&&this.hasTimezonePlugin()){const i=c.tz.guess();i==="UTC"?e=c(t):e=c.tz(t,i)}else e=c(t);return this.setLocaleToValue(e)},this.createUTCDate=t=>{if(!this.hasUTCPlugin())throw new Error(K);return this.setLocaleToValue(c.utc(t))},this.createTZDate=(t,e)=>{if(!this.hasUTCPlugin())throw new Error(K);if(!this.hasTimezonePlugin())throw new Error(at);const i=t!==void 0&&!t.endsWith("Z");return this.setLocaleToValue(c(t).tz(this.cleanTimezone(e),i))},this.getLocaleFormats=()=>{const t=c.Ls,e=this.locale||"en";let i=t[e];return i===void 0&&(i=t.en),i.formats},this.adjustOffset=t=>{if(!this.hasTimezonePlugin())return t;const e=this.getTimezone(t);if(e!=="UTC"){const i=t.tz(this.cleanTimezone(e),!0);if(i.$offset===(t.$offset??0))return t;t.$offset=i.$offset}return t},this.date=(t,e="default")=>t===null?null:e==="UTC"?this.createUTCDate(t):e==="system"||e==="default"&&!this.hasTimezonePlugin()?this.createSystemDate(t):this.createTZDate(t,e),this.getInvalidDate=()=>c(new Date("Invalid date")),this.getTimezone=t=>{if(this.hasTimezonePlugin()){const e=t.$x?.$timezone;if(e)return e}return this.hasUTCPlugin()&&t.isUTC()?"UTC":"system"},this.setTimezone=(t,e)=>{if(this.getTimezone(t)===e)return t;if(e==="UTC"){if(!this.hasUTCPlugin())throw new Error(K);return t.utc()}if(e==="system")return t.local();if(!this.hasTimezonePlugin()){if(e==="default")return t;throw new Error(at)}return this.setLocaleToValue(c.tz(t,this.cleanTimezone(e)))},this.toJsDate=t=>t.toDate(),this.parse=(t,e)=>t===""?null:c(t,e,this.locale,!0),this.getCurrentLocaleCode=()=>this.locale||"en",this.is12HourCycleInCurrentLocale=()=>/A|a/.test(this.getLocaleFormats().LT||""),this.expandFormat=t=>{const e=this.getLocaleFormats(),i=a=>a.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(r,s,u)=>s||u.slice(1));return t.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(a,r,s)=>{const u=s&&s.toUpperCase();return r||e[s]||i(e[u])})},this.isValid=t=>t==null?!1:t.isValid(),this.format=(t,e)=>this.formatByString(t,this.formats[e]),this.formatByString=(t,e)=>this.setLocaleToValue(t).format(e),this.formatNumber=t=>t,this.isEqual=(t,e)=>t===null&&e===null?!0:t===null||e===null?!1:t.toDate().getTime()===e.toDate().getTime(),this.isSameYear=(t,e)=>this.isSame(t,e,"YYYY"),this.isSameMonth=(t,e)=>this.isSame(t,e,"YYYY-MM"),this.isSameDay=(t,e)=>this.isSame(t,e,"YYYY-MM-DD"),this.isSameHour=(t,e)=>t.isSame(e,"hour"),this.isAfter=(t,e)=>t>e,this.isAfterYear=(t,e)=>this.hasUTCPlugin()?!this.isSameYear(t,e)&&t.utc()>e.utc():t.isAfter(e,"year"),this.isAfterDay=(t,e)=>this.hasUTCPlugin()?!this.isSameDay(t,e)&&t.utc()>e.utc():t.isAfter(e,"day"),this.isBefore=(t,e)=>t<e,this.isBeforeYear=(t,e)=>this.hasUTCPlugin()?!this.isSameYear(t,e)&&t.utc()<e.utc():t.isBefore(e,"year"),this.isBeforeDay=(t,e)=>this.hasUTCPlugin()?!this.isSameDay(t,e)&&t.utc()<e.utc():t.isBefore(e,"day"),this.isWithinRange=(t,[e,i])=>t>=e&&t<=i,this.startOfYear=t=>this.adjustOffset(t.startOf("year")),this.startOfMonth=t=>this.adjustOffset(t.startOf("month")),this.startOfWeek=t=>this.adjustOffset(this.setLocaleToValue(t).startOf("week")),this.startOfDay=t=>this.adjustOffset(t.startOf("day")),this.endOfYear=t=>this.adjustOffset(t.endOf("year")),this.endOfMonth=t=>this.adjustOffset(t.endOf("month")),this.endOfWeek=t=>this.adjustOffset(this.setLocaleToValue(t).endOf("week")),this.endOfDay=t=>this.adjustOffset(t.endOf("day")),this.addYears=(t,e)=>this.adjustOffset(t.add(e,"year")),this.addMonths=(t,e)=>this.adjustOffset(t.add(e,"month")),this.addWeeks=(t,e)=>this.adjustOffset(t.add(e,"week")),this.addDays=(t,e)=>this.adjustOffset(t.add(e,"day")),this.addHours=(t,e)=>this.adjustOffset(t.add(e,"hour")),this.addMinutes=(t,e)=>this.adjustOffset(t.add(e,"minute")),this.addSeconds=(t,e)=>this.adjustOffset(t.add(e,"second")),this.getYear=t=>t.year(),this.getMonth=t=>t.month(),this.getDate=t=>t.date(),this.getHours=t=>t.hour(),this.getMinutes=t=>t.minute(),this.getSeconds=t=>t.second(),this.getMilliseconds=t=>t.millisecond(),this.setYear=(t,e)=>this.adjustOffset(t.set("year",e)),this.setMonth=(t,e)=>this.adjustOffset(t.set("month",e)),this.setDate=(t,e)=>this.adjustOffset(t.set("date",e)),this.setHours=(t,e)=>this.adjustOffset(t.set("hour",e)),this.setMinutes=(t,e)=>this.adjustOffset(t.set("minute",e)),this.setSeconds=(t,e)=>this.adjustOffset(t.set("second",e)),this.setMilliseconds=(t,e)=>this.adjustOffset(t.set("millisecond",e)),this.getDaysInMonth=t=>t.daysInMonth(),this.getWeekArray=t=>{const e=this.startOfWeek(this.startOfMonth(t)),i=this.endOfWeek(this.endOfMonth(t));let a=0,r=e;const s=[];for(;r<i;){const u=Math.floor(a/7);s[u]=s[u]||[],s[u].push(r),r=this.addDays(r,1),a+=1}return s},this.getWeekNumber=t=>t.week(),this.getYearRange=([t,e])=>{const i=this.startOfYear(t),a=this.endOfYear(e),r=[];let s=i;for(;this.isBefore(s,a);)r.push(s),s=this.addYears(s,1);return r},this.locale=z,this.formats=lt({},$t,m),c.extend(Ot)}getDayOfWeek(z){return z.day()+1}}export{Bt as A};
|