@abtnode/blocklet-services 1.16.26-beta-818ea1c5 → 1.16.26-beta-cca12425
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/auth/adapters/apple.js +78 -0
- package/api/libs/auth/adapters/auth0.js +56 -0
- package/api/libs/auth/adapters/facebook.js +34 -0
- package/api/libs/auth/adapters/github.js +75 -0
- package/api/libs/auth/adapters/google.js +66 -0
- package/api/libs/auth/adapters/twitter.js +22 -0
- package/api/libs/auth/index.js +170 -0
- package/api/routes/federated.js +23 -1
- package/api/routes/oauth.js +257 -102
- package/api/services/auth/connect/receive-transfer-app-owner.js +7 -1
- package/api/services/oauth/index.js +70 -0
- package/api/util/federated.js +2 -2
- package/dist/assets/{Add-DgrYlJHm.js → Add-B1KQFZbB.js} +1 -1
- package/dist/assets/{AddBox-Cqkk9Zb6.js → AddBox-C_rCPKut.js} +1 -1
- package/dist/assets/{Alert-CJmzHVEH.js → Alert-D7OuAtqq.js} +1 -1
- package/dist/assets/{ArrowDropDown-qzt62tXO.js → ArrowDropDown-DDSSUsgw.js} +1 -1
- package/dist/assets/{Avatar-VThXe6vp.js → Avatar-BKvod5qm.js} +1 -1
- package/dist/assets/{ButtonGroup-crNqYhpS.js → ButtonGroup-B93e6tqm.js} +1 -1
- package/dist/assets/{CheckCircle-hTa9NuuL.js → CheckCircle-DgHejmJm.js} +1 -1
- package/dist/assets/{ChevronRight-Zd4sj4Ik.js → ChevronRight-KVhjO69S.js} +1 -1
- package/dist/assets/{CloseOutlined-DzkxsEbx.js → CloseOutlined-BdzvaiT0.js} +1 -1
- package/dist/assets/{Delete-FPkQEM7j.js → Delete-Cmb6a-TW.js} +1 -1
- package/dist/assets/{DeleteOutline-BgceRLMI.js → DeleteOutline-C_JPQWoC.js} +1 -1
- package/dist/assets/{Done-Dw6uaCDC.js → Done-Cqcgj3XK.js} +1 -1
- package/dist/assets/{Download-D4aLfdYz.js → Download-DYDCm5jq.js} +1 -1
- package/dist/assets/{Edit-BQ8r9eYD.js → Edit-JQ58DRtF.js} +1 -1
- package/dist/assets/{EditIcon-DonYKsD8.js → EditIcon-BuHKvSX-.js} +1 -1
- package/dist/assets/Error-bprXV3Qz.js +1 -0
- package/dist/assets/{ExpandMore-BgRJle39.js → ExpandMore-CMOFmrRl.js} +1 -1
- package/dist/assets/{FilterList-Cr_Ge89T.js → FilterList-MfdHX_OT.js} +4 -4
- package/dist/assets/{FormControl-D-JqMY5K.js → FormControl-BrDVvV0w.js} +1 -1
- package/dist/assets/{FormControlLabel-CxQTOZJ1.js → FormControlLabel-Bj1raPoa.js} +1 -1
- package/dist/assets/{FormGroup-C-BEyape.js → FormGroup-CTmu8GWz.js} +1 -1
- package/dist/assets/{Google-DBpd-Csd.js → Google-B8EaETJY.js} +4 -4
- package/dist/assets/{Grid-BKo3Eu4m.js → Grid-BtGjPvuC.js} +1 -1
- package/dist/assets/{Hidden-BIcc-Ri_.js → Hidden-DWKJv_Ts.js} +1 -1
- package/dist/assets/{InfoOutlined-BAo9kLny.js → InfoOutlined-BItr8vqq.js} +1 -1
- package/dist/assets/{InputAdornment-eRc8XOzM.js → InputAdornment-CGuzdfXX.js} +1 -1
- package/dist/assets/{InputLabel-DIt1gEGj.js → InputLabel-DA3u5GP-.js} +1 -1
- package/dist/assets/{LastPage-DBc4oFoT.js → LastPage-DzK9EKF-.js} +1 -1
- package/dist/assets/{Launch-Cb7jRIVL.js → Launch-p5mGEt8g.js} +1 -1
- package/dist/assets/{LaunchOutlined-T5Mcb8X-.js → LaunchOutlined-BiGPJuP-.js} +1 -1
- package/dist/assets/{Link-BP6MkNEU.js → Link-C1R9I8T5.js} +1 -1
- package/dist/assets/{ListItemText-nUHfvFm4.js → ListItemText-9kG4LhTP.js} +1 -1
- package/dist/assets/{LockIcon-8lU2ELwJ.js → LockIcon-BYVTkf1W.js} +1 -1
- package/dist/assets/{Loop-BmbGUwLx.js → Loop-DoUT9kIB.js} +1 -1
- package/dist/assets/{MoreHoriz-Cr0ijI9A.js → MoreHoriz-B921hlWY.js} +1 -1
- package/dist/assets/{MoreVert-B1iH4_5V.js → MoreVert-C4XqRKE4.js} +1 -1
- package/dist/assets/{OpenInNew-CuPWiq3c.js → OpenInNew-DjHvMAdQ.js} +1 -1
- package/dist/assets/{Pagination-DcDob8Pn.js → Pagination-BlJxwbJW.js} +2 -2
- package/dist/assets/{PlayArrow-BMdF4bh0.js → PlayArrow-D4vxqsKR.js} +1 -1
- package/dist/assets/{RadioGroup-DjjhaMO1.js → RadioGroup-DFQHgpUl.js} +1 -1
- package/dist/assets/{Search-D5RGjNs-.js → Search-BuZJTzDq.js} +1 -1
- package/dist/assets/{Select-DCojKr5m.js → Select-0rvptrXH.js} +2 -2
- package/dist/assets/{ServerLogo-B8biNuwQ.js → ServerLogo-BS1tW7SN.js} +1 -1
- package/dist/assets/{Skeleton-D7s7WiMT.js → Skeleton-BQyN-0sJ.js} +3 -3
- package/dist/assets/{Slider-CQHQc72o.js → Slider-DaMMponj.js} +1 -1
- package/dist/assets/{Stepper-7vJEQecO.js → Stepper-ASzJY9Wh.js} +1 -1
- package/dist/assets/{TableRow-G7CkKHMa.js → TableRow-DQB9jM8W.js} +2 -2
- package/dist/assets/{TextField-BiWs3Roa.js → TextField-BHg3uTSC.js} +1 -1
- package/dist/assets/{Toolbar-BIHRXxj8.js → Toolbar-C3gbqZgN.js} +1 -1
- package/dist/assets/{ViewList-BlQf9CJF.js → ViewList-D9nsZOsI.js} +1 -1
- package/dist/assets/access-control-CZnhbObg.js +13 -0
- package/dist/assets/{actions-qRYQXtmd.js → actions-CFxlQnVb.js} +1 -1
- package/dist/assets/{add-component-core-Dk3cdqQl.js → add-component-core-CUisTrXt.js} +28 -28
- package/dist/assets/add-resource-Cg68DwqT.js +1 -0
- package/dist/assets/{addon-D37LISTV.js → addon-htB6vNOx.js} +1 -1
- package/dist/assets/{analytics-BVTyrWL4.js → analytics-D0Q9Rbgs.js} +8 -8
- package/dist/assets/api-DZcbXOwe.js +1 -0
- package/dist/assets/ar-B34f4HdK.js +1 -0
- package/dist/assets/ar-D80LEtfP.js +1 -0
- package/dist/assets/{audit-logs-DYpquiBv.js → audit-logs-DsHwARYT.js} +4 -4
- package/dist/assets/{button-8D8Sy6Jr.js → button-CtcdFik9.js} +1 -1
- package/dist/assets/{click-to-copy-BuvkZSYS.js → click-to-copy-DJVlTNr8.js} +1 -1
- package/dist/assets/{complete-C1W5A3f0.js → complete-CGMY06_W.js} +4 -4
- package/dist/assets/{component-D-wlgWPx.js → component-C8WremgG.js} +4 -4
- package/dist/assets/{config-BWOSsVWv.js → config-J8uHydLG.js} +2 -2
- package/dist/assets/{config-BBK_6yxt.js → config-ggazJABW.js} +1 -1
- package/dist/assets/{config-navigation-CCSF4RHD.js → config-navigation-COwAaVq0.js} +3 -3
- package/dist/assets/{config-space-DQlVUMKm.js → config-space-CPyb_eZ-.js} +1 -1
- package/dist/assets/confirm-BjHkE8rM.js +7 -0
- package/dist/assets/{connect-BkB_iVwc.js → connect-BbzlMR5b.js} +1 -1
- package/dist/assets/{connect-Cz-uMP2K.js → connect-BuLrPUuZ.js} +1 -1
- package/dist/assets/connect-to-BQINcy1q.js +54 -0
- package/dist/assets/{content-layout-BYCcnYXE.js → content-layout-af8Tk37j.js} +1 -1
- package/dist/assets/{dashboard-Bv2HZZCV.js → dashboard-CMs2secm.js} +8 -8
- package/dist/assets/de-CbWSpQPN.js +1 -0
- package/dist/assets/de-R8SpyfWD.js +1 -0
- package/dist/assets/{did-address-DZIM4xfX.js → did-address-BTH0hYaF.js} +1 -1
- package/dist/assets/domain-CMHk_z2Z.js +9 -0
- package/dist/assets/domain-list-DFffhAi2.js +12 -0
- package/dist/assets/es-D2WPMiOg.js +1 -0
- package/dist/assets/es-DQJXbL8c.js +1 -0
- package/dist/assets/exchange-passport-CQ4sTk73.js +1 -0
- package/dist/assets/{fallback-UK-V5wy0.js → fallback-BCzfpkx_.js} +1 -1
- package/dist/assets/fr-BU_67rSB.js +1 -0
- package/dist/assets/fr-ojA_joLk.js +1 -0
- package/dist/assets/{fuel-DYF8oUki.js → fuel-DAtablaD.js} +1 -1
- package/dist/assets/{fullpage-bvTUfN0w.js → fullpage-DY6OHAG0.js} +1 -1
- package/dist/assets/hi-BQAxHgmg.js +1 -0
- package/dist/assets/hi-D5wWKqkp.js +1 -0
- package/dist/assets/home-BfnWYBKb.js +1 -0
- package/dist/assets/id-BerMjI8d.js +1 -0
- package/dist/assets/id-Do44PG5N.js +1 -0
- package/dist/assets/iframe-Cet_1xjB.js +1 -0
- package/dist/assets/{index-CSYh4gtP.js → index-6HBsHgLl.js} +1 -1
- package/dist/assets/index-A5YVryx_.js +13 -0
- package/dist/assets/{index-BXhBzR7Q.js → index-BXCKXS5j.js} +7 -7
- package/dist/assets/index-BqsMd8kb.js +1290 -0
- package/dist/assets/{index-CCY6RJsj.js → index-Bt4rb2Bc.js} +1 -1
- package/dist/assets/index-BxJWfUoy.js +262 -0
- package/dist/assets/{index-Bw_Ej9Cn.js → index-ByPqHR4r.js} +9 -9
- package/dist/assets/{index-BdxvQHKQ.js → index-C5WzGzSj.js} +1 -1
- package/dist/assets/{index-C2vBcXqD.js → index-C9d9WjZ0.js} +1 -1
- package/dist/assets/index-CHX9AKKy.js +221 -0
- package/dist/assets/{index-B0WIUFz1.js → index-CKhzUQzq.js} +7 -7
- package/dist/assets/{index-XV3z9IXt.js → index-CZ9EO740.js} +7 -7
- package/dist/assets/{index-DMSZt2ZE.js → index-CgXB8tNh.js} +2 -2
- package/dist/assets/{index-DWCMi3WL.js → index-Cn1zzQRb.js} +1 -1
- package/dist/assets/{index-Ok0xRBbf.js → index-CnV_HSYC.js} +1 -1
- package/dist/assets/{index-DPLdk86R.js → index-D0TsVpOv.js} +1 -1
- package/dist/assets/{index-CNHAiDvM.js → index-DG2_Yw8Q.js} +1 -1
- package/dist/assets/index-DJI8p4CV.js +54 -0
- package/dist/assets/{index-C00VKsL6.js → index-DJvJ2Tmc.js} +1 -1
- package/dist/assets/{index-BgNMSa3N.js → index-DMPZsfun.js} +1 -1
- package/dist/assets/{index-BQaoZKI6.js → index-Dbqss1Fe.js} +8 -8
- package/dist/assets/index-DcHRVIKm.js +12 -0
- package/dist/assets/{index-DXjXo6f0.js → index-DtNxMhKO.js} +1 -1
- package/dist/assets/{index-BZzKaGvd.js → index-DthjsZ09.js} +1 -1
- package/dist/assets/{index-mNlCpV8P.js → index-Dylzk7Aa.js} +2 -2
- package/dist/assets/{index-dUNOHPzk.js → index-LSzcGKHj.js} +4 -4
- package/dist/assets/index-NdCq_QfL.js +234 -0
- package/dist/assets/{index-BKdL2tN6.js → index-e7NHyY1q.js} +15 -17
- package/dist/assets/{index-DuoMkzRH.js → index-o-Ihmjeu.js} +1 -1
- package/dist/assets/index-zxzrHJEP.js +11 -0
- package/dist/assets/{index.es-B_ckeqWW.js → index.es-BEaw1DFj.js} +3 -3
- package/dist/assets/index.esm-C9zb95qH.js +1 -0
- package/dist/assets/info-outline-rounded-BTpTFmEK.js +57 -0
- package/dist/assets/{invitation-DlUxWMm0.js → invitation-3r-X891j.js} +5 -5
- package/dist/assets/{invite-DVE8FTA3.js → invite-CrWjnaC0.js} +1 -1
- package/dist/assets/{issue-passport-DTrWwTY_.js → issue-passport-CCGBLWf8.js} +1 -1
- package/dist/assets/item-BNHxZM2p.js +1 -0
- package/dist/assets/ja-BO4aqMDb.js +1 -0
- package/dist/assets/ja-D8qblxbX.js +1 -0
- package/dist/assets/{jss-plugin-props-sort.esm-r4rT6imo.js → jss-plugin-props-sort.esm-CjzdPk2L.js} +4 -4
- package/dist/assets/ko-C8eR3MIF.js +1 -0
- package/dist/assets/ko-Cv-NiLYG.js +1 -0
- package/dist/assets/{launch-result-message-DKVZaiuQ.js → launch-result-message-D2CQfmUY.js} +1 -1
- package/dist/assets/{layout-r1uFQEiA.js → layout--pblhAfc.js} +2 -2
- package/dist/assets/{list-header-Bqj4L1f9.js → list-header-Br5YHewG.js} +1 -1
- package/dist/assets/localization-BwDw74Zq.js +1 -0
- package/dist/assets/{log-6WvRhIsI.js → log-BJjAfVl8.js} +1 -1
- package/dist/assets/{login-Cv7Mu9fV.js → login-BQQD6meW.js} +1 -1
- package/dist/assets/login-oauth-callback-Dmleuitf.js +1 -0
- package/dist/assets/logo-uploader-eDNDJkbn.js +127 -0
- package/dist/assets/{lost-passport-D1SohDZY.js → lost-passport-BWTuZR78.js} +3 -3
- package/dist/assets/{lottie-DGWD8Sx6.js → lottie-VJFQ68oA.js} +1 -1
- package/dist/assets/{notifications-B2-qZM1R.js → notifications-DwecRDR9.js} +2 -2
- package/dist/assets/overview-BMcMnUtN.js +12 -0
- package/dist/assets/{page-header-CNlMYlWe.js → page-header-EqcdM7n1.js} +1 -1
- package/dist/assets/{permission-rTeG4c6s.js → permission-D9TNO0kT.js} +1 -1
- package/dist/assets/{preferences-uQd05OUd.js → preferences-CN9EJ9NX.js} +1 -1
- package/dist/assets/pt-DfarVqto.js +1 -0
- package/dist/assets/pt-Dly5Myel.js +1 -0
- package/dist/assets/publish-resource-D7WXvm6u.js +1 -0
- package/dist/assets/{react-Cv1mxS7R.js → react-DP2ngoHF.js} +15 -15
- package/dist/assets/{redux-YC_VNDAW.js → redux-BpyOm6pS.js} +1 -1
- package/dist/assets/ru-C9Wh9IKf.js +1 -0
- package/dist/assets/ru-DeqfYyhe.js +1 -0
- package/dist/assets/{selector-UANcYMI5.js → selector-Dpt9nBq7.js} +3 -3
- package/dist/assets/session-DESbRLD5.js +1 -0
- package/dist/assets/setup-DFybTsc-.js +19 -0
- package/dist/assets/{slicedToArray-BDirS3b-.js → slicedToArray-SBrU6gJV.js} +2 -2
- package/dist/assets/spaces-DNtrZi8N.js +1 -0
- package/dist/assets/start-CgH7B6u8.js +186 -0
- package/dist/assets/{step-actions-DBbKtvUA.js → step-actions-BNn2aM9R.js} +1 -1
- package/dist/assets/{studio-DseQhKM-.js → studio-8gthozLh.js} +1 -1
- package/dist/assets/{switch-control-ChRbLafp.js → switch-control-DO3LxG2v.js} +1 -1
- package/dist/assets/th-B6Z2fc62.js +1 -0
- package/dist/assets/th-BEfUwHXu.js +1 -0
- package/dist/assets/{toUpper-aYHMIsgS.js → toUpper-C0A9jQTp.js} +1 -1
- package/dist/assets/transfer-Blq_vH7z.js +16 -0
- package/dist/assets/uniqBy-DN9WBw_C.js +1 -0
- package/dist/assets/{unsubscribe-CD5-lgl8.js → unsubscribe-CkiFEJUY.js} +1 -1
- package/dist/assets/{use-blocklet-info-for-connect-did-spaces-BZgwpcda.js → use-blocklet-info-for-connect-did-spaces-Car-GPAS.js} +1 -1
- package/dist/assets/useAsync-D0lrbkdE.js +1 -0
- package/dist/assets/{useFormControl-Dg1dn0q0.js → useFormControl-b_gcFCyO.js} +1 -1
- package/dist/assets/{useLocalStorage-Cz7o0KhC.js → useLocalStorage-Cvbq9kSP.js} +1 -1
- package/dist/assets/{useSetState-CabR74SD.js → useSetState-p_ztAK1J.js} +1 -1
- package/dist/assets/useSlot-MeMXV443.js +1 -0
- package/dist/assets/user-center-B0jK0JhV.js +1 -0
- package/dist/assets/user-sessions-gd1hKrWX.js +1 -0
- package/dist/assets/{util-nCKofCSa.js → util-BkBoAuZA.js} +1 -1
- package/dist/assets/vi-CVN1WwF4.js +1 -0
- package/dist/assets/vi-Di0ynKe6.js +1 -0
- package/dist/assets/wrap-locale-BONrbXck.js +1 -0
- package/dist/assets/{zh-BjdUZ9y0.js → zh-Bgfgr3pp.js} +2 -2
- package/dist/assets/zh-e04FR-Ps.js +1 -0
- package/dist/assets/zh-tw-DlepKNg6.js +1 -0
- package/dist/assets/zh-tw-kaMajsUI.js +1 -0
- package/dist/index.html +1 -1
- package/dist/service-worker.js +1 -1
- package/package.json +28 -27
- package/dist/assets/access-control-2ITAVZFE.js +0 -13
- package/dist/assets/add-resource-DXNOMO-U.js +0 -1
- package/dist/assets/api-DbKOEDhE.js +0 -1
- package/dist/assets/ar-CxvIl-Ji.js +0 -1
- package/dist/assets/ar-DkKlynAd.js +0 -1
- package/dist/assets/confirm-B_AqBUcU.js +0 -7
- package/dist/assets/connect-to-DY7ehzSR.js +0 -54
- package/dist/assets/de-3qOdEa6P.js +0 -1
- package/dist/assets/de-6SF_cfoR.js +0 -1
- package/dist/assets/domain-DhXcq2zb.js +0 -9
- package/dist/assets/domain-list-DgsYQNVw.js +0 -12
- package/dist/assets/es-7PLonVLT.js +0 -1
- package/dist/assets/es-Cgmj9Jck.js +0 -1
- package/dist/assets/exchange-passport-B9snHp27.js +0 -1
- package/dist/assets/fr-1I2E8gH_.js +0 -1
- package/dist/assets/fr-CEcEkJ0j.js +0 -1
- package/dist/assets/hi-B2Zih4k5.js +0 -1
- package/dist/assets/hi-O7fF0c9u.js +0 -1
- package/dist/assets/home-CU_IGJyv.js +0 -1
- package/dist/assets/id-BF9h-bev.js +0 -1
- package/dist/assets/id-Cvddby74.js +0 -1
- package/dist/assets/iframe-COW-8OqG.js +0 -1
- package/dist/assets/index-7_LDggGs.js +0 -11
- package/dist/assets/index-BiG0eNQl.js +0 -233
- package/dist/assets/index-Cqc114Nl.js +0 -54
- package/dist/assets/index-D04f13KU.js +0 -1304
- package/dist/assets/index-DGFV1Kbv.js +0 -13
- package/dist/assets/index-De-cDFqF.js +0 -262
- package/dist/assets/index-cOMrpLvw.js +0 -221
- package/dist/assets/index.esm-CymxS9uw.js +0 -1
- package/dist/assets/item-DJ0IfbAJ.js +0 -1
- package/dist/assets/ja-BRl6JgyC.js +0 -1
- package/dist/assets/ja-D-8llXBd.js +0 -1
- package/dist/assets/ko-BjJKFx_R.js +0 -1
- package/dist/assets/ko-wij13JCo.js +0 -1
- package/dist/assets/localization-CWTtfgBA.js +0 -1
- package/dist/assets/logo-uploader-Bd9nGCUT.js +0 -127
- package/dist/assets/overview--CbrsoGh.js +0 -12
- package/dist/assets/pt-CkaW7MUR.js +0 -1
- package/dist/assets/pt-DwFQV4Br.js +0 -1
- package/dist/assets/publish-resource-DOdKon0e.js +0 -1
- package/dist/assets/ru-1GZMliq9.js +0 -1
- package/dist/assets/ru-D1AQvTQo.js +0 -1
- package/dist/assets/session-CNTfeDhH.js +0 -1
- package/dist/assets/setup-Cv13s2jR.js +0 -19
- package/dist/assets/spaces-BRT7WRxg.js +0 -1
- package/dist/assets/start-Bcl56tnq.js +0 -186
- package/dist/assets/th-BXoQZNC4.js +0 -1
- package/dist/assets/th-Bc32gh20.js +0 -1
- package/dist/assets/transfer-DTM2UHnW.js +0 -16
- package/dist/assets/ua-parser-Ca9ZhtBr.js +0 -57
- package/dist/assets/uniqBy-BkV8rpNe.js +0 -1
- package/dist/assets/useAsync-COTc7rmY.js +0 -1
- package/dist/assets/useSlot-Ceul9GiJ.js +0 -1
- package/dist/assets/user-center-6Xre-wMU.js +0 -1
- package/dist/assets/user-sessions-B85QTl3T.js +0 -1
- package/dist/assets/vi-BnooUqta.js +0 -1
- package/dist/assets/vi-CRasBMRh.js +0 -1
- package/dist/assets/wrap-locale-bIxHxEdd.js +0 -1
- package/dist/assets/zh-B75pu7gp.js +0 -1
- package/dist/assets/zh-tw-BYDo5dcg.js +0 -1
- package/dist/assets/zh-tw-prJAtGne.js +0 -1
- /package/api/libs/auth/adapters/{auth0 → auth0-legacy}/authentication-client.js +0 -0
- /package/api/libs/auth/adapters/{auth0 → auth0-legacy}/index.js +0 -0
- /package/api/libs/auth/adapters/{auth0 → auth0-legacy}/management-client.js +0 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const jwt = require('jsonwebtoken');
|
|
2
|
+
// https://appleid.apple.com/.well-known/openid-configuration
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} AppleUserProfile
|
|
6
|
+
* @property {string} iss - issuer of oauth provider
|
|
7
|
+
* @property {string} aud
|
|
8
|
+
* @property {string} at_hash
|
|
9
|
+
* @property {string} iat
|
|
10
|
+
* @property {string} exp
|
|
11
|
+
* @property {string} sub - user's usb
|
|
12
|
+
* @property {string} email - user's email
|
|
13
|
+
* @property {boolean} email_verified - user's email is verified
|
|
14
|
+
* @property {boolean} is_private_email - user's email is verified
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
function Apple(options) {
|
|
18
|
+
return {
|
|
19
|
+
id: 'apple',
|
|
20
|
+
name: 'Apple',
|
|
21
|
+
type: 'oidc',
|
|
22
|
+
issuer: 'https://appleid.apple.com',
|
|
23
|
+
jwks_uri: 'https://appleid.apple.com/auth/keys',
|
|
24
|
+
token: 'https://appleid.apple.com/auth/token',
|
|
25
|
+
authorization: {
|
|
26
|
+
url: 'https://appleid.apple.com/auth/authorize',
|
|
27
|
+
params: {
|
|
28
|
+
scope: 'name email',
|
|
29
|
+
response_mode: 'form_post',
|
|
30
|
+
prompt: 'login',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* @param {AppleUserProfile} profile
|
|
35
|
+
* @returns {Object}
|
|
36
|
+
*/
|
|
37
|
+
profile(profile) {
|
|
38
|
+
return {
|
|
39
|
+
sub: `appleid|${profile.sub}`,
|
|
40
|
+
// HACK: apple 可能无法正确获得用户名,使用 email 做为兜底方案
|
|
41
|
+
name: profile.name || profile.email,
|
|
42
|
+
email: profile.email,
|
|
43
|
+
picture: null,
|
|
44
|
+
emailVerified: profile.email_verified,
|
|
45
|
+
extraData: {
|
|
46
|
+
isPrivateEmail: profile.is_private_email,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
getClientId() {
|
|
51
|
+
return options.serviceId;
|
|
52
|
+
},
|
|
53
|
+
getClientSecret() {
|
|
54
|
+
const headers = {
|
|
55
|
+
alg: 'ES256',
|
|
56
|
+
kid: options.keyId,
|
|
57
|
+
};
|
|
58
|
+
const timeNow = Math.floor(Date.now() / 1000);
|
|
59
|
+
const claims = {
|
|
60
|
+
iss: options.teamId,
|
|
61
|
+
aud: 'https://appleid.apple.com',
|
|
62
|
+
sub: options.serviceId,
|
|
63
|
+
iat: timeNow,
|
|
64
|
+
exp: timeNow + 86400,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const token = jwt.sign(claims, options.authKey, {
|
|
68
|
+
algorithm: 'ES256',
|
|
69
|
+
header: headers,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return token;
|
|
73
|
+
},
|
|
74
|
+
options,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
module.exports = Apple;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// https://auth0.openai.com/.well-known/openid-configuration
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {Object} Auth0UserProfile
|
|
5
|
+
* @property {string} sub - The subject of the user profile.
|
|
6
|
+
* @property {string} name - The name of the user.
|
|
7
|
+
* @property {string} picture - The picture URL of the user.
|
|
8
|
+
* @property {string} email - The email of the user.
|
|
9
|
+
* @property {boolean} email_verified - Indicates if the user's email is verified.
|
|
10
|
+
* @property {string} locale - The locale of the user.
|
|
11
|
+
* @property {string} nickname - The nickname of the user.
|
|
12
|
+
* @property {string} updated_at - The last time the user profile was updated.
|
|
13
|
+
* @property {string} iss - The issuer of the token.
|
|
14
|
+
* @property {string} aud - The audience of the token.
|
|
15
|
+
* @property {number} iat - The issued at time of the token.
|
|
16
|
+
* @property {number} exp - The expiration time of the token.
|
|
17
|
+
* @property {string} sid
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const { joinURL } = require('ufo');
|
|
21
|
+
|
|
22
|
+
function Auth0(options) {
|
|
23
|
+
const { issuer } = options;
|
|
24
|
+
return {
|
|
25
|
+
id: 'auth0',
|
|
26
|
+
name: 'Auth0',
|
|
27
|
+
type: 'oidc',
|
|
28
|
+
issuer,
|
|
29
|
+
jwks_uri: joinURL(issuer, '/.well-known/jwks.json'),
|
|
30
|
+
authorization: {
|
|
31
|
+
url: joinURL(issuer, '/authorize'),
|
|
32
|
+
params: {
|
|
33
|
+
prompt: 'login',
|
|
34
|
+
scope: 'openid profile email',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
token: joinURL(issuer, '/oauth/token'),
|
|
38
|
+
userinfo: {
|
|
39
|
+
url: joinURL(issuer, '/userinfo'),
|
|
40
|
+
},
|
|
41
|
+
/**
|
|
42
|
+
* @param {Auth0UserProfile} profile - The profile object to be modified.
|
|
43
|
+
* @return {Object} The modified profile object.
|
|
44
|
+
*/
|
|
45
|
+
profile(profile) {
|
|
46
|
+
return {
|
|
47
|
+
...profile,
|
|
48
|
+
name: profile.nickname || profile.name,
|
|
49
|
+
emailVerified: profile.email_verified,
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
options,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = Auth0;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
function Facebook(options) {
|
|
2
|
+
return {
|
|
3
|
+
id: 'facebook',
|
|
4
|
+
name: 'Facebook',
|
|
5
|
+
type: 'oauth',
|
|
6
|
+
authorization: {
|
|
7
|
+
url: 'https://www.facebook.com/v15.0/dialog/oauth',
|
|
8
|
+
params: {
|
|
9
|
+
scope: 'email',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
token: 'https://graph.facebook.com/oauth/access_token',
|
|
13
|
+
userinfo: {
|
|
14
|
+
// https://developers.facebook.com/docs/graph-api/reference/user/#fields
|
|
15
|
+
url: 'https://graph.facebook.com/me?fields=id,name,email,picture',
|
|
16
|
+
request({ tokens, provider }) {
|
|
17
|
+
return fetch(provider.userinfo?.url, {
|
|
18
|
+
headers: { Authorization: `Bearer ${tokens.access_token}` },
|
|
19
|
+
}).then((res) => res.json());
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
profile(profile) {
|
|
23
|
+
return {
|
|
24
|
+
id: profile.id,
|
|
25
|
+
name: profile.name,
|
|
26
|
+
email: profile.email,
|
|
27
|
+
image: profile.picture.data.url,
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
options,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = Facebook;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const { default: axios } = require('axios');
|
|
2
|
+
const logger = require('../../logger')('blocklet-services:oauth');
|
|
3
|
+
|
|
4
|
+
function GitHub(options) {
|
|
5
|
+
const baseUrl = 'https://github.com';
|
|
6
|
+
const apiBaseUrl = 'https://api.github.com';
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
id: 'github',
|
|
10
|
+
name: 'GitHub',
|
|
11
|
+
type: 'oauth',
|
|
12
|
+
authorization: {
|
|
13
|
+
url: `${baseUrl}/login/oauth/authorize`,
|
|
14
|
+
params: {
|
|
15
|
+
scope: 'read:user user:email',
|
|
16
|
+
// HACK: prompt: login 对 github 没效果,如果当前只登录了一个 github 账号,则会跳过登录页面直接成功,只能设置为 consent,让页面不直接登录
|
|
17
|
+
prompt: 'consent',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
token: `${baseUrl}/login/oauth/access_token`,
|
|
21
|
+
userinfo: {
|
|
22
|
+
async request({ tokens }) {
|
|
23
|
+
const url = `${apiBaseUrl}/user`;
|
|
24
|
+
const { data } = await axios.get(url, {
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: `token ${tokens.access_token}`,
|
|
27
|
+
'User-Agent': '@blocklet/auth',
|
|
28
|
+
Accept: 'application/json',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (!data.email) {
|
|
33
|
+
// If the user does not have a public email, get another via the GitHub API
|
|
34
|
+
// See https://docs.github.com/en/rest/users/emails#list-public-email-addresses-for-the-authenticated-user
|
|
35
|
+
try {
|
|
36
|
+
const { data: emails } = await axios.get(`${apiBaseUrl}/user/emails`, {
|
|
37
|
+
headers: {
|
|
38
|
+
Authorization: `Bearer ${tokens.access_token}`,
|
|
39
|
+
'User-Agent': '@blocklet/auth',
|
|
40
|
+
Accept: 'application/json',
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
data.email = (emails.find((e) => e.primary) ?? emails[0]).email;
|
|
44
|
+
} catch (err) {
|
|
45
|
+
logger.error('Failed to get github user email');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return data;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
profile(profile) {
|
|
53
|
+
return {
|
|
54
|
+
sub: `github|${profile.id}`,
|
|
55
|
+
name: profile.name ?? profile.login,
|
|
56
|
+
email: profile.email,
|
|
57
|
+
picture: profile.avatar_url,
|
|
58
|
+
extraData: {
|
|
59
|
+
login: profile.login,
|
|
60
|
+
nodeId: profile.node_id,
|
|
61
|
+
company: profile.company,
|
|
62
|
+
blog: profile.blog,
|
|
63
|
+
location: profile.location,
|
|
64
|
+
hireable: profile.hireable,
|
|
65
|
+
bio: profile.bio,
|
|
66
|
+
twitterUsername: profile.twitter_username,
|
|
67
|
+
twoFactorAuthentication: profile.two_factor_authentication,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
options,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = GitHub;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// https://accounts.google.com/.well-known/openid-configuration
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {Object} GoogleUserProfile
|
|
5
|
+
* @property {string} iss - issuer of oauth provider
|
|
6
|
+
* @property {string} azp
|
|
7
|
+
* @property {string} aud
|
|
8
|
+
* @property {string} at_hash
|
|
9
|
+
* @property {string} iat
|
|
10
|
+
* @property {string} exp
|
|
11
|
+
* @property {string} sub - user's usb
|
|
12
|
+
* @property {string} email - user's email
|
|
13
|
+
* @property {string} name - user's name
|
|
14
|
+
* @property {string} picture - user's avatar url
|
|
15
|
+
* @property {string} email_verified - user's email is verifyed
|
|
16
|
+
* @property {string} given_name
|
|
17
|
+
* @property {string} family_name
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {Object} UserProfile
|
|
22
|
+
* @property {string} sub - The subject of the user profile.
|
|
23
|
+
* @property {string} name - The name of the user.
|
|
24
|
+
* @property {string} picture - The picture URL of the user.
|
|
25
|
+
* @property {string} email - The email of the user.
|
|
26
|
+
* @property {boolean} [email_verified] - Indicates if the user's email is verified.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
function Google(options) {
|
|
30
|
+
return {
|
|
31
|
+
id: 'google',
|
|
32
|
+
name: 'Google',
|
|
33
|
+
type: 'oidc',
|
|
34
|
+
issuer: 'https://accounts.google.com',
|
|
35
|
+
jwks_uri: 'https://www.googleapis.com/oauth2/v3/certs',
|
|
36
|
+
authorization: {
|
|
37
|
+
url: 'https://accounts.google.com/o/oauth2/v2/auth',
|
|
38
|
+
params: {
|
|
39
|
+
scope: 'openid profile email',
|
|
40
|
+
prompt: 'login',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
token: 'https://oauth2.googleapis.com/token',
|
|
44
|
+
userinfo: 'https://openidconnect.googleapis.com/v1/userinfo',
|
|
45
|
+
options,
|
|
46
|
+
/**
|
|
47
|
+
* @param {GoogleUserProfile} profile
|
|
48
|
+
* @returns {UserProfile}
|
|
49
|
+
*/
|
|
50
|
+
profile(profile) {
|
|
51
|
+
return {
|
|
52
|
+
sub: `google-oauth2|${profile.sub}`,
|
|
53
|
+
name: profile.name,
|
|
54
|
+
picture: profile.picture,
|
|
55
|
+
email: profile.email,
|
|
56
|
+
emailVerified: profile.email_verified,
|
|
57
|
+
extraData: {
|
|
58
|
+
givenName: profile.given_name,
|
|
59
|
+
familyName: profile.family_name,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = Google;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function Twitter(options) {
|
|
2
|
+
return {
|
|
3
|
+
id: 'twitter',
|
|
4
|
+
name: 'Twitter',
|
|
5
|
+
type: 'oauth',
|
|
6
|
+
checks: ['pkce', 'state'],
|
|
7
|
+
authorization: 'https://twitter.com/i/oauth2/authorize?scope=users.read tweet.read offline.access',
|
|
8
|
+
token: 'https://api.twitter.com/2/oauth2/token',
|
|
9
|
+
userinfo: 'https://api.twitter.com/2/users/me?user.fields=profile_image_url',
|
|
10
|
+
profile({ data }) {
|
|
11
|
+
return {
|
|
12
|
+
id: data.id,
|
|
13
|
+
name: data.name,
|
|
14
|
+
email: data.email ?? null,
|
|
15
|
+
image: data.profile_image_url,
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
options,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = Twitter;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
const { default: axios } = require('axios');
|
|
2
|
+
const logger = require('../logger')('blocklet-services:oauth');
|
|
3
|
+
const { verifyIdToken } = require('../../services/oauth');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} Provider
|
|
7
|
+
* @property {string} id - provider id
|
|
8
|
+
* @property {string} name - provider 名称
|
|
9
|
+
* @property {string} authorizeUrl - 授权的 url
|
|
10
|
+
* @property {string} [scope] - 获取的授权范围,以空格分隔
|
|
11
|
+
* @property {string} clientId - client id
|
|
12
|
+
* @property {string} clientSecret - client secret
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {Object} AuthorizationToken
|
|
17
|
+
* @property {string} access_token
|
|
18
|
+
* @property {string} [id_token] - 包含了用户信息,通过 jwt 解码可获取
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {Object} UserProfile
|
|
23
|
+
* @property {string} sub - The subject of the user profile.
|
|
24
|
+
* @property {string} name - The name of the user.
|
|
25
|
+
* @property {string} picture - The picture URL of the user.
|
|
26
|
+
* @property {string} email - The email of the user.
|
|
27
|
+
* @property {boolean} [email_verified] - Indicates if the user's email is verified.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 根据 url 和 params 参数生成最终的 url
|
|
32
|
+
* @param {string | {url: string, params: object}} urlLike - The URL string or an object containing the URL and parameters.
|
|
33
|
+
* @param {object} params - The parameters to append to the URL.
|
|
34
|
+
* @return {string} The complete URL string with parameters appended.
|
|
35
|
+
*/
|
|
36
|
+
function getUrl(urlLike, params) {
|
|
37
|
+
const uri = typeof urlLike === 'string' ? urlLike : urlLike.url;
|
|
38
|
+
const appendParams =
|
|
39
|
+
typeof urlLike === 'string'
|
|
40
|
+
? { ...params }
|
|
41
|
+
: {
|
|
42
|
+
...urlLike.params,
|
|
43
|
+
...params,
|
|
44
|
+
};
|
|
45
|
+
const url = new URL(uri);
|
|
46
|
+
for (const k of Object.keys(appendParams)) {
|
|
47
|
+
const v = appendParams[k];
|
|
48
|
+
if (v !== undefined) {
|
|
49
|
+
url.searchParams.set(k, v);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return url.toString();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
class OAuthClient {
|
|
56
|
+
/**
|
|
57
|
+
* Constructor for initializing providers.
|
|
58
|
+
* @param {Object} options
|
|
59
|
+
* @param {Provider} options.provider
|
|
60
|
+
*/
|
|
61
|
+
constructor({ provider }) {
|
|
62
|
+
this.provider = provider;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 获取 oauth 授权 code 用的地址
|
|
67
|
+
*
|
|
68
|
+
* @return {string}
|
|
69
|
+
*/
|
|
70
|
+
getAuthorizationUrl() {
|
|
71
|
+
if (this.provider.authorization?.request) {
|
|
72
|
+
return this.provider.authorization.request();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return getUrl(this.provider.authorization, {
|
|
76
|
+
response_type: 'code',
|
|
77
|
+
client_id: this.provider?.getClientId?.() || this.provider.options.clientId,
|
|
78
|
+
redirect_uri: this.provider.options.callbackUrl,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 通过授权码换取 token
|
|
84
|
+
*
|
|
85
|
+
* @param {Object} code - oauth 步骤的授权码
|
|
86
|
+
* @return {Promise<AuthorizationToken>}
|
|
87
|
+
*/
|
|
88
|
+
async getToken({ code }) {
|
|
89
|
+
try {
|
|
90
|
+
if (this.provider.token?.request) {
|
|
91
|
+
return this.provider.token.request();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const params = {
|
|
95
|
+
grant_type: 'authorization_code',
|
|
96
|
+
client_id: this.provider?.getClientId?.() || this.provider.options.clientId,
|
|
97
|
+
client_secret: this.provider?.getClientSecret?.() || this.provider.options.clientSecret,
|
|
98
|
+
code,
|
|
99
|
+
redirect_uri: this.provider.options.callbackUrl,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// 标准的 oauth code-flow 协议要求是使用 application/x-www-form-urlencoded 来携带数据,所以此处使用 URLSearchParams 来传递数据
|
|
103
|
+
const { data } = await axios.post(this.provider.token, new URLSearchParams(params), {
|
|
104
|
+
headers: { Accept: 'application/json' },
|
|
105
|
+
});
|
|
106
|
+
return data;
|
|
107
|
+
} catch (err) {
|
|
108
|
+
logger.error('Failed get token', { error: err });
|
|
109
|
+
throw new Error(`Failed get token: ${err.message}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 通过授权 token 获取用户信息
|
|
115
|
+
* @param {AuthorizationToken} tokens
|
|
116
|
+
* @returns {Object} user info, 具体信息根据不同平台有不同的结构
|
|
117
|
+
*/
|
|
118
|
+
async getUserInfo(tokens) {
|
|
119
|
+
try {
|
|
120
|
+
if (tokens.id_token) {
|
|
121
|
+
const cliams = await verifyIdToken({
|
|
122
|
+
clientId: this.provider?.getClientId?.() || this.provider.options.clientId,
|
|
123
|
+
idToken: tokens.id_token,
|
|
124
|
+
iss: this.provider.issuer,
|
|
125
|
+
jwksUri: this.provider.jwks_uri,
|
|
126
|
+
nonce: tokens.nonce,
|
|
127
|
+
});
|
|
128
|
+
return cliams;
|
|
129
|
+
}
|
|
130
|
+
if (this.provider.userinfo?.request) {
|
|
131
|
+
return this.provider.userinfo.request({ tokens });
|
|
132
|
+
}
|
|
133
|
+
const url = new URL(this.provider.userinfo?.url || this.provider.userinfo);
|
|
134
|
+
|
|
135
|
+
const { data } = await axios.get(url.toString(), {
|
|
136
|
+
headers: {
|
|
137
|
+
Authorization: `Bearer ${tokens.access_token}`,
|
|
138
|
+
'User-Agent': '@blocklet/auth',
|
|
139
|
+
Accept: 'application/json',
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
return data;
|
|
143
|
+
} catch (err) {
|
|
144
|
+
logger.error('Failed get user info', { error: err });
|
|
145
|
+
throw new Error(`Failed get user info: ${err.message}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 通过授权 token 获取标准格式化后的用户信息
|
|
151
|
+
* @param {AuthorizationToken} tokens
|
|
152
|
+
* @returns {UserProfile} 返回标准格式化后的用户信息
|
|
153
|
+
*/
|
|
154
|
+
async getProfile(tokens) {
|
|
155
|
+
try {
|
|
156
|
+
const userInfo = await this.getUserInfo(tokens);
|
|
157
|
+
if (this.provider.profile) {
|
|
158
|
+
return this.provider.profile(userInfo);
|
|
159
|
+
}
|
|
160
|
+
return userInfo;
|
|
161
|
+
} catch (err) {
|
|
162
|
+
logger.error('Failed get user profile', { error: err });
|
|
163
|
+
throw new Error(`Failed get user profile: ${err.message}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
module.exports = {
|
|
169
|
+
OAuthClient,
|
|
170
|
+
};
|
package/api/routes/federated.js
CHANGED
|
@@ -95,6 +95,27 @@ async function syncConnectAccount(user, { node, teamDid, dataDir, blocklet }) {
|
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
async function syncDisconnectAccount(user, { node, teamDid, blocklet }) {
|
|
99
|
+
const { disconnectedAccount, sourceAppPid, did, pk } = user;
|
|
100
|
+
const masterSite = getFederatedMaster(blocklet);
|
|
101
|
+
if (masterSite.appPid !== teamDid) {
|
|
102
|
+
await getUserWithinFederated(
|
|
103
|
+
{
|
|
104
|
+
sourceAppPid,
|
|
105
|
+
teamDid,
|
|
106
|
+
userDid: did,
|
|
107
|
+
userPk: pk,
|
|
108
|
+
},
|
|
109
|
+
{ blocklet, node }
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
await node.disconnectUserAccount({
|
|
114
|
+
teamDid,
|
|
115
|
+
connectedAccount: disconnectedAccount,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
98
119
|
/**
|
|
99
120
|
* member 站点向 master 站点请求拉取一个用户信息
|
|
100
121
|
*/
|
|
@@ -127,7 +148,7 @@ async function pullUserAccount(user, { node, teamDid, blocklet }) {
|
|
|
127
148
|
syncUser.avatar = getUserAvatarUrl(currentUser.avatar, blocklet);
|
|
128
149
|
syncUser.email = syncUser.email || '';
|
|
129
150
|
syncUser.connectedAccounts = currentUser.connectedAccounts.map((x) => {
|
|
130
|
-
const connectAccount = pick(x, ['did', 'pk', 'provider', 'id']);
|
|
151
|
+
const connectAccount = pick(x, ['did', 'pk', 'provider', 'id', 'userInfo']);
|
|
131
152
|
if (!connectAccount.id) {
|
|
132
153
|
delete connectAccount.id;
|
|
133
154
|
}
|
|
@@ -140,6 +161,7 @@ async function pullUserAccount(user, { node, teamDid, blocklet }) {
|
|
|
140
161
|
const syncFnMaps = {
|
|
141
162
|
switchProfile: syncSwitchProfile,
|
|
142
163
|
connectAccount: syncConnectAccount,
|
|
164
|
+
disconnectAccount: syncDisconnectAccount,
|
|
143
165
|
pullAccount: pullUserAccount,
|
|
144
166
|
};
|
|
145
167
|
|