@e-xi/xion 0.0.6
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/README.md +1 -0
- package/dist/bin/icon-generator.d.ts +22 -0
- package/dist/bin/index.d.ts +5 -0
- package/dist/bin/index.js +92 -0
- package/dist/bin/logo-generator.d.ts +22 -0
- package/dist/chunk-files/chunk-34OODP7M.js +147 -0
- package/dist/chunk-files/chunk-3KBZWBNP.js +51 -0
- package/dist/chunk-files/chunk-3R6EJDYR.js +10 -0
- package/dist/chunk-files/chunk-3RVKOFMP.js +68 -0
- package/dist/chunk-files/chunk-3S5OTD47.js +35 -0
- package/dist/chunk-files/chunk-3XB4IEWO.js +195 -0
- package/dist/chunk-files/chunk-3XOVD6UX.js +8 -0
- package/dist/chunk-files/chunk-4HEDNQUP.js +426 -0
- package/dist/chunk-files/chunk-4SSGMLEE.js +934 -0
- package/dist/chunk-files/chunk-5PKWVAQP.js +92 -0
- package/dist/chunk-files/chunk-6BOPFOZD.js +19 -0
- package/dist/chunk-files/chunk-6FDO72PN.js +25 -0
- package/dist/chunk-files/chunk-6X74EPRM.js +0 -0
- package/dist/chunk-files/chunk-B2FI5WI5.js +67 -0
- package/dist/chunk-files/chunk-B7DTBTWQ.js +74 -0
- package/dist/chunk-files/chunk-BFD2LHLK.js +60 -0
- package/dist/chunk-files/chunk-BJOPQNB2.js +319 -0
- package/dist/chunk-files/chunk-BMOLIJ3W.js +89 -0
- package/dist/chunk-files/chunk-BPTFUGTP.js +97 -0
- package/dist/chunk-files/chunk-CSUNGWAE.js +405 -0
- package/dist/chunk-files/chunk-D5ZV4VMI.js +627 -0
- package/dist/chunk-files/chunk-DD6WZ4NY.js +841 -0
- package/dist/chunk-files/chunk-DEODEAKM.js +19 -0
- package/dist/chunk-files/chunk-DRMV3M5V.js +1970 -0
- package/dist/chunk-files/chunk-EQTU45UO.js +21 -0
- package/dist/chunk-files/chunk-F7YTK2MY.js +154 -0
- package/dist/chunk-files/chunk-FMQTZ3QV.js +17 -0
- package/dist/chunk-files/chunk-FPN7JYR4.js +67 -0
- package/dist/chunk-files/chunk-FULHNQ4O.js +1243 -0
- package/dist/chunk-files/chunk-GN2FNR3Z.js +259 -0
- package/dist/chunk-files/chunk-GROGDGEL.js +177 -0
- package/dist/chunk-files/chunk-GUOSVDXA.js +34 -0
- package/dist/chunk-files/chunk-HT5V5A7S.js +6 -0
- package/dist/chunk-files/chunk-ID3YDA2K.js +19 -0
- package/dist/chunk-files/chunk-IH3R2NDR.js +230 -0
- package/dist/chunk-files/chunk-IMGYTSWY.js +261 -0
- package/dist/chunk-files/chunk-J34MOWJP.js +26 -0
- package/dist/chunk-files/chunk-KFK47PDH.js +77 -0
- package/dist/chunk-files/chunk-KFV4GXVE.js +11 -0
- package/dist/chunk-files/chunk-LFHJJQW3.js +723 -0
- package/dist/chunk-files/chunk-LQ67F6EY.js +32 -0
- package/dist/chunk-files/chunk-MJ6Q3TIX.js +703 -0
- package/dist/chunk-files/chunk-OUFO3LM4.js +135 -0
- package/dist/chunk-files/chunk-P4CX6I4J.js +14 -0
- package/dist/chunk-files/chunk-PL5KNBCY.js +78 -0
- package/dist/chunk-files/chunk-PVWRRUOK.js +11 -0
- package/dist/chunk-files/chunk-Q7LCZIQP.js +15 -0
- package/dist/chunk-files/chunk-Q7YMMN7J.js +220 -0
- package/dist/chunk-files/chunk-RAVPJRBA.js +118 -0
- package/dist/chunk-files/chunk-RN7AI33H.js +26 -0
- package/dist/chunk-files/chunk-RODB64YF.js +148 -0
- package/dist/chunk-files/chunk-SVTZ4T6S.js +10 -0
- package/dist/chunk-files/chunk-T3QCAOCO.js +20 -0
- package/dist/chunk-files/chunk-U4XEWVBH.js +19 -0
- package/dist/chunk-files/chunk-UCMR6V67.js +746 -0
- package/dist/chunk-files/chunk-UFYEZIUE.js +1269 -0
- package/dist/chunk-files/chunk-UIJUY7QZ.js +18 -0
- package/dist/chunk-files/chunk-VGDNICVG.js +67 -0
- package/dist/chunk-files/chunk-W2I3I7U7.js +35 -0
- package/dist/chunk-files/chunk-WGYOMA43.js +33 -0
- package/dist/chunk-files/chunk-WKVLVI6N.js +44 -0
- package/dist/chunk-files/chunk-WOJ2UKI7.js +11 -0
- package/dist/chunk-files/chunk-Y3OEXVQ2.js +59 -0
- package/dist/chunk-files/chunk-YLZRRUY7.js +6 -0
- package/dist/chunk-files/chunk-YTHS2ZV7.js +51 -0
- package/dist/chunk-files/chunk-YXAEUJKJ.js +331 -0
- package/dist/chunk-files/chunk-YZOJOLFL.js +121 -0
- package/dist/main/app/app-lifecycle-abstract.d.ts +190 -0
- package/dist/main/app/app-lifecycle.d.ts +7 -0
- package/dist/main/app/icons/icon.ico +0 -0
- package/dist/main/app/index.d.ts +8 -0
- package/dist/main/app/index.js +1226 -0
- package/dist/main/app/types/app.d.ts +74 -0
- package/dist/main/app/xo-app-abstract.d.ts +464 -0
- package/dist/main/app/xo-app.d.ts +23 -0
- package/dist/main/auth/index.d.ts +8 -0
- package/dist/main/auth/index.js +109 -0
- package/dist/main/auth/jwt-auth-manager.d.ts +302 -0
- package/dist/main/auth/jwt-auth-provider-abstract.d.ts +100 -0
- package/dist/main/auth/jwt-auth-refresh-rejected-error.d.ts +12 -0
- package/dist/main/auth/jwt-auth-session-changed-error.d.ts +12 -0
- package/dist/main/auth/types/jwt-auth-manager.d.ts +13 -0
- package/dist/main/banner/banner-abstract.d.ts +38 -0
- package/dist/main/banner/banner-manager.d.ts +20 -0
- package/dist/main/banner/index.d.ts +6 -0
- package/dist/main/banner/index.js +10 -0
- package/dist/main/banner/types/banner.d.ts +17 -0
- package/dist/main/config/app-config.d.ts +6 -0
- package/dist/main/config/index.d.ts +13 -0
- package/dist/main/config/index.js +33 -0
- package/dist/main/config/logger-config.d.ts +6 -0
- package/dist/main/config/remote-service-config.d.ts +6 -0
- package/dist/main/config/tray-config.d.ts +6 -0
- package/dist/main/config/types/app.d.ts +38 -0
- package/dist/main/config/types/logger.d.ts +82 -0
- package/dist/main/config/types/window.d.ts +35 -0
- package/dist/main/config/updater-config.d.ts +6 -0
- package/dist/main/config/window/main-window-config.d.ts +6 -0
- package/dist/main/config/window/setting-window-config.d.ts +6 -0
- package/dist/main/file-association/file-association-handlers-abstract.d.ts +23 -0
- package/dist/main/file-association/file-association-manager-abstract.d.ts +87 -0
- package/dist/main/file-association/file-association-manager.d.ts +13 -0
- package/dist/main/file-association/handlers/app-file-association-handlers.d.ts +12 -0
- package/dist/main/file-association/index.d.ts +8 -0
- package/dist/main/file-association/index.js +13 -0
- package/dist/main/file-association/types/file-association.d.ts +31 -0
- package/dist/main/ipc/handlers/app-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/auth-handlers.d.ts +12 -0
- package/dist/main/ipc/handlers/clipboard-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/contex-menu-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/dialog-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/file-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/log-handlers.d.ts +45 -0
- package/dist/main/ipc/handlers/remote-service-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/shell-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/theme-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/updater-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/window-handlers.d.ts +13 -0
- package/dist/main/ipc/index.d.ts +20 -0
- package/dist/main/ipc/index.js +60 -0
- package/dist/main/ipc/ipc-handlers-abstract.d.ts +23 -0
- package/dist/main/ipc/ipc-manager-abstract.d.ts +46 -0
- package/dist/main/ipc/ipc-manager.d.ts +13 -0
- package/dist/main/ipc/types/ipc-handler.d.ts +22 -0
- package/dist/main/ipc/utils/ipc-handler-util.d.ts +24 -0
- package/dist/main/logger/index.d.ts +4 -0
- package/dist/main/logger/index.js +13 -0
- package/dist/main/logger/xo-logger.d.ts +113 -0
- package/dist/main/menu/consts/menu-type.d.ts +1 -0
- package/dist/main/menu/index.d.ts +8 -0
- package/dist/main/menu/index.js +28 -0
- package/dist/main/menu/menu-items.d.ts +192 -0
- package/dist/main/menu/menu-manager-abstract.d.ts +273 -0
- package/dist/main/menu/menu-manager.d.ts +12 -0
- package/dist/main/menu/types/menu.d.ts +101 -0
- package/dist/main/mode/app-mode.d.ts +32 -0
- package/dist/main/mode/index.d.ts +5 -0
- package/dist/main/mode/index.js +9 -0
- package/dist/main/mode/types/mode.d.ts +25 -0
- package/dist/main/protocol/consts/protocol-keys.d.ts +10 -0
- package/dist/main/protocol/handlers/app-protocol-handlers.d.ts +12 -0
- package/dist/main/protocol/index.d.ts +9 -0
- package/dist/main/protocol/index.js +15 -0
- package/dist/main/protocol/protocol-handlers-abstract.d.ts +23 -0
- package/dist/main/protocol/protocol-manager-abstract.d.ts +85 -0
- package/dist/main/protocol/protocol-manager.d.ts +13 -0
- package/dist/main/protocol/types/protocol.d.ts +33 -0
- package/dist/main/remote-service/consts/remote-service-methods.d.ts +5 -0
- package/dist/main/remote-service/index.d.ts +7 -0
- package/dist/main/remote-service/index.js +17 -0
- package/dist/main/remote-service/remote-service-manager-abstract.d.ts +303 -0
- package/dist/main/remote-service/remote-service-manager.d.ts +7 -0
- package/dist/main/remote-service/types/remote-service.d.ts +9 -0
- package/dist/main/renderer-protocol/handlers/renderer-remote-service-protocol-handlers.d.ts +130 -0
- package/dist/main/renderer-protocol/handlers/renderer-root-protocol-handlers.d.ts +65 -0
- package/dist/main/renderer-protocol/index.d.ts +9 -0
- package/dist/main/renderer-protocol/index.js +18 -0
- package/dist/main/renderer-protocol/renderer-protocol-handlers-abstract.d.ts +23 -0
- package/dist/main/renderer-protocol/renderer-protocol-manager-abstract.d.ts +78 -0
- package/dist/main/renderer-protocol/renderer-protocol-manager.d.ts +13 -0
- package/dist/main/renderer-protocol/types/renderer-protocol.d.ts +34 -0
- package/dist/main/shortcut/handlers/app-shortcut-handlers.d.ts +11 -0
- package/dist/main/shortcut/handlers/window-shortcut-handlers.d.ts +11 -0
- package/dist/main/shortcut/index.d.ts +9 -0
- package/dist/main/shortcut/index.js +17 -0
- package/dist/main/shortcut/shortcut-handlers-abstract.d.ts +18 -0
- package/dist/main/shortcut/shortcut-manager-abstract.d.ts +121 -0
- package/dist/main/shortcut/shortcut-manager.d.ts +12 -0
- package/dist/main/shortcut/types/shortcut.d.ts +50 -0
- package/dist/main/store/app-store.d.ts +179 -0
- package/dist/main/store/index.d.ts +7 -0
- package/dist/main/store/index.js +13 -0
- package/dist/main/store/jwt-auth-store.d.ts +36 -0
- package/dist/main/store/types/app-store.d.ts +46 -0
- package/dist/main/store/types/jwt-auth-store.d.ts +14 -0
- package/dist/main/theme/consts/theme-sources.d.ts +10 -0
- package/dist/main/theme/index.d.ts +7 -0
- package/dist/main/theme/index.js +16 -0
- package/dist/main/theme/theme-manager-abstract.d.ts +93 -0
- package/dist/main/theme/theme-manager.d.ts +7 -0
- package/dist/main/theme/types/theme.d.ts +38 -0
- package/dist/main/tray/consts/tray-animation-name.d.ts +1 -0
- package/dist/main/tray/consts/tray-icon-name.d.ts +1 -0
- package/dist/main/tray/icons/blur.ico +0 -0
- package/dist/main/tray/icons/error.ico +0 -0
- package/dist/main/tray/icons/focus.ico +0 -0
- package/dist/main/tray/icons/none.ico +0 -0
- package/dist/main/tray/icons/offline.ico +0 -0
- package/dist/main/tray/icons/online.ico +0 -0
- package/dist/main/tray/icons/success.ico +0 -0
- package/dist/main/tray/index.d.ts +11 -0
- package/dist/main/tray/index.js +27 -0
- package/dist/main/tray/tray-animation.d.ts +48 -0
- package/dist/main/tray/tray-icon.d.ts +51 -0
- package/dist/main/tray/tray-lifecycle-abstract.d.ts +154 -0
- package/dist/main/tray/tray-lifecycle.d.ts +7 -0
- package/dist/main/tray/tray-manager.d.ts +173 -0
- package/dist/main/tray/types/tray.d.ts +81 -0
- package/dist/main/updater/dev-app-update.yml +5 -0
- package/dist/main/updater/index.d.ts +6 -0
- package/dist/main/updater/index.js +20 -0
- package/dist/main/updater/types/updater.d.ts +167 -0
- package/dist/main/updater/updater-manager-abstract.d.ts +237 -0
- package/dist/main/updater/updater-manager.d.ts +7 -0
- package/dist/main/utils/file-association-util.d.ts +43 -0
- package/dist/main/utils/index.d.ts +14 -0
- package/dist/main/utils/index.js +105 -0
- package/dist/main/utils/menu-util.d.ts +12 -0
- package/dist/main/utils/protocol-util.d.ts +49 -0
- package/dist/main/utils/runtime-config-util.d.ts +75 -0
- package/dist/main/utils/shortcut-util.d.ts +38 -0
- package/dist/main/utils/tray-util.d.ts +18 -0
- package/dist/main/utils/window-util.d.ts +55 -0
- package/dist/main/utils/xo-app-root-util.d.ts +30 -0
- package/dist/main/utils/xo-app-util.d.ts +24 -0
- package/dist/main/utils/xo-path-util.d.ts +59 -0
- package/dist/main/utils/xo-util.d.ts +17 -0
- package/dist/main/window/index.d.ts +10 -0
- package/dist/main/window/index.js +36 -0
- package/dist/main/window/main/main-window-lifecycle.d.ts +7 -0
- package/dist/main/window/main/main-window-type.d.ts +5 -0
- package/dist/main/window/setting/setting-window-lifecycle.d.ts +7 -0
- package/dist/main/window/setting/setting-window-type.d.ts +5 -0
- package/dist/main/window/types/window.d.ts +86 -0
- package/dist/main/window/window-lifecycle-abstract.d.ts +514 -0
- package/dist/main/window/window-manager.d.ts +422 -0
- package/dist/preload/bridge/bridge-abstract.d.ts +11 -0
- package/dist/preload/bridge/bridge.d.ts +35 -0
- package/dist/preload/bridge/index.d.ts +6 -0
- package/dist/preload/bridge/index.js +117 -0
- package/dist/preload/bridge/preload.cjs +1706 -0
- package/dist/preload/bridge/preload.internal.d.ts +1 -0
- package/dist/preload/bridge/types/bridge.d.ts +19 -0
- package/dist/preload/bridges/app/app-bridge.d.ts +142 -0
- package/dist/preload/bridges/app/types/app.d.ts +65 -0
- package/dist/preload/bridges/auth/auth-bridge.d.ts +36 -0
- package/dist/preload/bridges/auth/types/auth.d.ts +23 -0
- package/dist/preload/bridges/clipboard/clipboard-bridge.d.ts +37 -0
- package/dist/preload/bridges/clipboard/types/clipboard.d.ts +23 -0
- package/dist/preload/bridges/context-menu/context-menu-bridge.d.ts +27 -0
- package/dist/preload/bridges/context-menu/types/context-menu.d.ts +19 -0
- package/dist/preload/bridges/dialog/dialog-bridge.d.ts +30 -0
- package/dist/preload/bridges/dialog/types/dialog.d.ts +41 -0
- package/dist/preload/bridges/file/file-bridge.d.ts +34 -0
- package/dist/preload/bridges/file/types/file.d.ts +21 -0
- package/dist/preload/bridges/index.d.ts +29 -0
- package/dist/preload/bridges/index.js +40 -0
- package/dist/preload/bridges/ipc/ipc-bridge.d.ts +43 -0
- package/dist/preload/bridges/ipc/types/ipc.d.ts +23 -0
- package/dist/preload/bridges/log/log-bridge.d.ts +52 -0
- package/dist/preload/bridges/log/types/log.d.ts +20 -0
- package/dist/preload/bridges/remote-service/remote-service-bridge.d.ts +55 -0
- package/dist/preload/bridges/remote-service/types/remote-service.d.ts +29 -0
- package/dist/preload/bridges/shell/shell-bridge.d.ts +27 -0
- package/dist/preload/bridges/shell/types/shell.d.ts +19 -0
- package/dist/preload/bridges/theme/theme-bridge.d.ts +32 -0
- package/dist/preload/bridges/theme/types/theme.d.ts +21 -0
- package/dist/preload/bridges/updater/types/updater.d.ts +35 -0
- package/dist/preload/bridges/updater/updater-bridge.d.ts +66 -0
- package/dist/preload/bridges/window/internal/route-redirect-buffer.d.ts +36 -0
- package/dist/preload/bridges/window/types/window.d.ts +53 -0
- package/dist/preload/bridges/window/window-bridge.d.ts +118 -0
- package/dist/preload/utils/bridge-util.d.ts +43 -0
- package/dist/preload/utils/index.d.ts +4 -0
- package/dist/preload/utils/index.js +7 -0
- package/dist/renderer/app/bootstrap-renderer.d.ts +6 -0
- package/dist/renderer/app/index.d.ts +5 -0
- package/dist/renderer/app/index.js +164 -0
- package/dist/renderer/app/styles-element-plus.internal.d.ts +2 -0
- package/dist/renderer/app/styles-xion.internal.d.ts +2 -0
- package/dist/renderer/app/types/app.d.ts +51 -0
- package/dist/renderer/components/captcha/internal/captcha-controller.d.ts +280 -0
- package/dist/renderer/components/captcha/internal/captcha-css-property.d.ts +25 -0
- package/dist/renderer/components/captcha/internal/captcha-defaults.d.ts +33 -0
- package/dist/renderer/components/captcha/internal/captcha-errors.d.ts +21 -0
- package/dist/renderer/components/captcha/internal/captcha-helper.d.ts +72 -0
- package/dist/renderer/components/captcha/internal/captcha-injector.d.ts +16 -0
- package/dist/renderer/components/captcha/internal/captcha-runtime-types.d.ts +153 -0
- package/dist/renderer/components/captcha/internal/captcha-service.d.ts +22 -0
- package/dist/renderer/components/captcha/internal/captcha-slide-types.d.ts +62 -0
- package/dist/renderer/components/captcha/internal/captcha-ui-patch.d.ts +43 -0
- package/dist/renderer/components/captcha/internal/captcha-wasm-loader.d.ts +36 -0
- package/dist/renderer/components/captcha/style/index.less +132 -0
- package/dist/renderer/components/captcha/types/captcha.d.ts +132 -0
- package/dist/renderer/components/captcha/xo-captcha-host.vue +151 -0
- package/dist/renderer/components/captcha/xo-captcha.vue +83 -0
- package/dist/renderer/components/captcha.d.ts +40 -0
- package/dist/renderer/components/context-menu/types/context-menu.d.ts +55 -0
- package/dist/renderer/components/context-menu/xo-context-menu-items.vue +112 -0
- package/dist/renderer/components/context-menu/xo-context-menu.vue +356 -0
- package/dist/renderer/components/context-menu.d.ts +32 -0
- package/dist/renderer/components/divider/types/divider.d.ts +31 -0
- package/dist/renderer/components/divider/xo-divider.vue +176 -0
- package/dist/renderer/components/form/types/form-flex-row.d.ts +21 -0
- package/dist/renderer/components/form/types/form-flex.d.ts +49 -0
- package/dist/renderer/components/form/xo-form-flex-row.vue +122 -0
- package/dist/renderer/components/form/xo-form-flex.vue +115 -0
- package/dist/renderer/components/index.d.ts +70 -0
- package/dist/renderer/components/index.js +1282 -0
- package/dist/renderer/components/layouts/types/app-layout.d.ts +29 -0
- package/dist/renderer/components/layouts/types/mini-layout.d.ts +23 -0
- package/dist/renderer/components/layouts/types/simple-layout.d.ts +17 -0
- package/dist/renderer/components/layouts/xo-app-layout.vue +350 -0
- package/dist/renderer/components/layouts/xo-mini-layout.vue +207 -0
- package/dist/renderer/components/layouts/xo-simple-layout.vue +43 -0
- package/dist/renderer/components/pages/types/app-page.d.ts +25 -0
- package/dist/renderer/components/pages/types/bootstrap-page.d.ts +35 -0
- package/dist/renderer/components/pages/types/dynamic-page.d.ts +20 -0
- package/dist/renderer/components/pages/types/settings-page.d.ts +23 -0
- package/dist/renderer/components/pages/xo-app-page.vue +230 -0
- package/dist/renderer/components/pages/xo-bootstrap-page.vue +93 -0
- package/dist/renderer/components/pages/xo-dynamic-page.vue +28 -0
- package/dist/renderer/components/pages/xo-settings-page.vue +143 -0
- package/dist/renderer/components/radio-group/types/radio-group.d.ts +30 -0
- package/dist/renderer/components/radio-group/xo-radio-group.vue +38 -0
- package/dist/renderer/components/service-status-bar/types/service-status-bar.d.ts +65 -0
- package/dist/renderer/components/service-status-bar/xo-service-status-bar.vue +193 -0
- package/dist/renderer/components/settings-components/types/setting-app-opacity.d.ts +19 -0
- package/dist/renderer/components/settings-components/types/setting-log-level.d.ts +23 -0
- package/dist/renderer/components/settings-components/types/setting-shortcut-keys-record-for-form-flex-rows.d.ts +47 -0
- package/dist/renderer/components/settings-components/types/setting-shortcut-keys-record.d.ts +23 -0
- package/dist/renderer/components/settings-components/types/setting-window-material.d.ts +23 -0
- package/dist/renderer/components/settings-components/xo-setting-app-opacity.vue +105 -0
- package/dist/renderer/components/settings-components/xo-setting-log-level.vue +84 -0
- package/dist/renderer/components/settings-components/xo-setting-shortcut-keys-record-for-form-flex-rows.vue +37 -0
- package/dist/renderer/components/settings-components/xo-setting-shortcut-keys-record.vue +74 -0
- package/dist/renderer/components/settings-components/xo-setting-window-material.vue +83 -0
- package/dist/renderer/components/settings-pages/types/setting-page-folder.d.ts +41 -0
- package/dist/renderer/components/settings-pages/types/setting-page-general.d.ts +23 -0
- package/dist/renderer/components/settings-pages/types/setting-page-remote-service.d.ts +19 -0
- package/dist/renderer/components/settings-pages/types/setting-page-updater.d.ts +27 -0
- package/dist/renderer/components/settings-pages/xo-setting-page-folder.vue +137 -0
- package/dist/renderer/components/settings-pages/xo-setting-page-general.vue +255 -0
- package/dist/renderer/components/settings-pages/xo-setting-page-remote-service.vue +183 -0
- package/dist/renderer/components/settings-pages/xo-setting-page-updater.vue +350 -0
- package/dist/renderer/components/shortcut-keys-record/types/shortcut-keys-record.d.ts +25 -0
- package/dist/renderer/components/shortcut-keys-record/xo-shortcut-keys-record.vue +161 -0
- package/dist/renderer/components/side-bar/types/sidebar-logo.d.ts +39 -0
- package/dist/renderer/components/side-bar/xo-sidebar-logo.vue +133 -0
- package/dist/renderer/components/spacing-line/types/spacing-line.d.ts +17 -0
- package/dist/renderer/components/spacing-line/xo-spacing-line.vue +53 -0
- package/dist/renderer/components/theme-switch/types/theme-switch-mini.d.ts +21 -0
- package/dist/renderer/components/theme-switch/types/theme-switch.d.ts +45 -0
- package/dist/renderer/components/theme-switch/xo-theme-switch-mini.vue +93 -0
- package/dist/renderer/components/theme-switch/xo-theme-switch.vue +200 -0
- package/dist/renderer/components/title-bar/types/title-bar.d.ts +58 -0
- package/dist/renderer/components/title-bar/xo-title-bar.vue +364 -0
- package/dist/renderer/components/types/sidebar-menu.d.ts +37 -0
- package/dist/renderer/components/types/vue.d.ts +9 -0
- package/dist/renderer/components/updater/types/updater.d.ts +97 -0
- package/dist/renderer/components/updater/xo-updater.vue +1190 -0
- package/dist/renderer/components/window-control/types/window-control.d.ts +17 -0
- package/dist/renderer/components/window-control/xo-window-control.vue +193 -0
- package/dist/renderer/composables/index.d.ts +7 -0
- package/dist/renderer/composables/index.js +570 -0
- package/dist/renderer/composables/use-xo-boolean.d.ts +14 -0
- package/dist/renderer/composables/use-xo-data-loader.d.ts +73 -0
- package/dist/renderer/composables/use-xo-form-control.d.ts +84 -0
- package/dist/renderer/composables/use-xo-updater-action.d.ts +25 -0
- package/dist/renderer/global/index.d.ts +4 -0
- package/dist/renderer/global/index.js +0 -0
- package/dist/renderer/global/types/window.d.ts +21 -0
- package/dist/renderer/icons/demo.css +539 -0
- package/dist/renderer/icons/iconfont.css +490 -0
- package/dist/renderer/services/index.d.ts +6 -0
- package/dist/renderer/services/index.js +444 -0
- package/dist/renderer/services/orval-axios-mutator.d.ts +9 -0
- package/dist/renderer/services/types/xo-api.d.ts +92 -0
- package/dist/renderer/services/xo-api-requester.d.ts +129 -0
- package/dist/renderer/store/app/app-store.d.ts +68 -0
- package/dist/renderer/store/auth/auth-store.d.ts +43 -0
- package/dist/renderer/store/index.d.ts +9 -0
- package/dist/renderer/store/index.js +595 -0
- package/dist/renderer/store/remote-service/remote-service-store.d.ts +52 -0
- package/dist/renderer/store/theme/theme-store.d.ts +52 -0
- package/dist/renderer/store/updater/updater-store.d.ts +88 -0
- package/dist/renderer/store/window/window-store.d.ts +58 -0
- package/dist/renderer/styles/css/element-plus.less +280 -0
- package/dist/renderer/styles/css/iconfont-patch.less +6 -0
- package/dist/renderer/styles/css/reset.less +83 -0
- package/dist/renderer/styles/css/scrollbar.less +56 -0
- package/dist/renderer/styles/index.less +35 -0
- package/dist/renderer/styles/mixin.less +144 -0
- package/dist/renderer/styles/var/element-plus/dark.less +32 -0
- package/dist/renderer/styles/var/element-plus/root.less +88 -0
- package/dist/renderer/styles/var/global/dark.less +10 -0
- package/dist/renderer/styles/var/global/root.less +46 -0
- package/dist/renderer/styles/var/layout/dark.less +7 -0
- package/dist/renderer/styles/var/layout/root.less +9 -0
- package/dist/renderer/styles/var/scrollbar/dark.less +13 -0
- package/dist/renderer/styles/var/scrollbar/root.less +35 -0
- package/dist/renderer/utils/auth-route-util.d.ts +117 -0
- package/dist/renderer/utils/context-util.d.ts +13 -0
- package/dist/renderer/utils/error-util.d.ts +12 -0
- package/dist/renderer/utils/index.d.ts +14 -0
- package/dist/renderer/utils/index.js +1522 -0
- package/dist/renderer/utils/keyboard-util.d.ts +86 -0
- package/dist/renderer/utils/message-util.d.ts +161 -0
- package/dist/renderer/utils/renderer-log-util.d.ts +44 -0
- package/dist/renderer/utils/renderer-util.d.ts +37 -0
- package/dist/renderer/utils/router-util.d.ts +186 -0
- package/dist/renderer/utils/shortcut-util.d.ts +20 -0
- package/dist/renderer/utils/storage-util.d.ts +85 -0
- package/dist/renderer/utils/types/vue-router.d.ts +17 -0
- package/dist/shared/app/consts/app-launch-mode.d.ts +9 -0
- package/dist/shared/app/consts/update-mode.d.ts +8 -0
- package/dist/shared/app/consts/window-close-behavior.d.ts +8 -0
- package/dist/shared/app/consts/window-material.d.ts +8 -0
- package/dist/shared/app/consts/xion-name.d.ts +5 -0
- package/dist/shared/app/electron-app-config.d.ts +5 -0
- package/dist/shared/app/index.d.ts +16 -0
- package/dist/shared/app/index.js +30 -0
- package/dist/shared/app/types/app-info.d.ts +32 -0
- package/dist/shared/app/types/app-launch-mode.d.ts +13 -0
- package/dist/shared/app/types/app-paths.d.ts +27 -0
- package/dist/shared/app/types/general-settings.d.ts +27 -0
- package/dist/shared/app/types/on-window-close.d.ts +13 -0
- package/dist/shared/app/types/update-mode.d.ts +13 -0
- package/dist/shared/app/types/window-material.d.ts +2 -0
- package/dist/shared/auth/const/auth-status.d.ts +2 -0
- package/dist/shared/auth/index.d.ts +5 -0
- package/dist/shared/auth/index.js +5 -0
- package/dist/shared/auth/types/auth.d.ts +78 -0
- package/dist/shared/color/consts/color.d.ts +5 -0
- package/dist/shared/color/index.d.ts +5 -0
- package/dist/shared/color/index.js +6 -0
- package/dist/shared/color/types/color.d.ts +26 -0
- package/dist/shared/electron-builder/index.d.ts +4 -0
- package/dist/shared/electron-builder/index.js +0 -0
- package/dist/shared/electron-builder/types/electron-builder-options.d.ts +34 -0
- package/dist/shared/errors/index.d.ts +4 -0
- package/dist/shared/errors/index.js +10 -0
- package/dist/shared/errors/ipc-invoke-error.d.ts +32 -0
- package/dist/shared/ipc/channels/app-channels.d.ts +56 -0
- package/dist/shared/ipc/channels/auth-channels.d.ts +14 -0
- package/dist/shared/ipc/channels/clipboard-channels.d.ts +14 -0
- package/dist/shared/ipc/channels/context-menu-channels.d.ts +10 -0
- package/dist/shared/ipc/channels/dialog-channels.d.ts +12 -0
- package/dist/shared/ipc/channels/file-channels.d.ts +12 -0
- package/dist/shared/ipc/channels/log-channels.d.ts +14 -0
- package/dist/shared/ipc/channels/remote-service-channels.d.ts +20 -0
- package/dist/shared/ipc/channels/shell-channels.d.ts +10 -0
- package/dist/shared/ipc/channels/theme-channels.d.ts +12 -0
- package/dist/shared/ipc/channels/updater-channels.d.ts +26 -0
- package/dist/shared/ipc/channels/window-channels.d.ts +44 -0
- package/dist/shared/ipc/consts/ipc-channel.d.ts +1 -0
- package/dist/shared/ipc/index.d.ts +19 -0
- package/dist/shared/ipc/index.js +46 -0
- package/dist/shared/ipc/ipc-result.d.ts +20 -0
- package/dist/shared/ipc/types/ipc-logger.d.ts +27 -0
- package/dist/shared/ipc/types/ipc.d.ts +61 -0
- package/dist/shared/logger/consts/log-levels.d.ts +14 -0
- package/dist/shared/logger/index.d.ts +4 -0
- package/dist/shared/logger/index.js +10 -0
- package/dist/shared/menu/consts/menu-command.d.ts +1 -0
- package/dist/shared/menu/index.d.ts +6 -0
- package/dist/shared/menu/index.js +10 -0
- package/dist/shared/menu/menu-command.d.ts +24 -0
- package/dist/shared/menu/types/menu.d.ts +72 -0
- package/dist/shared/mode/consts/command.d.ts +10 -0
- package/dist/shared/mode/consts/mode.d.ts +22 -0
- package/dist/shared/mode/index.d.ts +5 -0
- package/dist/shared/mode/index.js +18 -0
- package/dist/shared/remote-service/const/remote-service.d.ts +8 -0
- package/dist/shared/remote-service/index.d.ts +5 -0
- package/dist/shared/remote-service/index.js +38 -0
- package/dist/shared/remote-service/types/remote-service.d.ts +146 -0
- package/dist/shared/renderer/index.d.ts +7 -0
- package/dist/shared/renderer/index.js +0 -0
- package/dist/shared/renderer/types/element-plus.d.ts +20 -0
- package/dist/shared/renderer/types/input.d.ts +11 -0
- package/dist/shared/renderer/types/options.d.ts +22 -0
- package/dist/shared/renderer/types/switch.d.ts +11 -0
- package/dist/shared/renderer-protocol/consts/renderer-protocol-keys.d.ts +10 -0
- package/dist/shared/renderer-protocol/index.d.ts +5 -0
- package/dist/shared/renderer-protocol/index.js +6 -0
- package/dist/shared/renderer-protocol/types/renderer-protocol.d.ts +7 -0
- package/dist/shared/runtime/index.d.ts +4 -0
- package/dist/shared/runtime/index.js +0 -0
- package/dist/shared/runtime/types/runtime.d.ts +20 -0
- package/dist/shared/shortcut/consts/shortcut-handler-ids.d.ts +9 -0
- package/dist/shared/shortcut/consts/shortcut-id.d.ts +1 -0
- package/dist/shared/shortcut/index.d.ts +6 -0
- package/dist/shared/shortcut/index.js +10 -0
- package/dist/shared/shortcut/types/shortcut.d.ts +13 -0
- package/dist/shared/utils/bytes-util.d.ts +16 -0
- package/dist/shared/utils/index.d.ts +15 -0
- package/dist/shared/utils/index.js +42 -0
- package/dist/shared/utils/ipc-util.d.ts +12 -0
- package/dist/shared/utils/log-util.d.ts +33 -0
- package/dist/shared/utils/menu-util.d.ts +12 -0
- package/dist/shared/utils/number-util.d.ts +12 -0
- package/dist/shared/utils/object-util.d.ts +88 -0
- package/dist/shared/utils/regexp-util.d.ts +22 -0
- package/dist/shared/utils/shortcut-util.d.ts +12 -0
- package/dist/shared/utils/string-util.d.ts +14 -0
- package/dist/shared/utils/time-util.d.ts +32 -0
- package/dist/shared/utils/validator-util.d.ts +12 -0
- package/dist/shared/utils/window-shared-util.d.ts +26 -0
- package/dist/shared/window/consts/window-record-id.d.ts +2 -0
- package/dist/shared/window/consts/window-type-name.d.ts +1 -0
- package/dist/shared/window/identity/main-window-identity.d.ts +5 -0
- package/dist/shared/window/identity/setting-window-identity.d.ts +5 -0
- package/dist/shared/window/index.d.ts +8 -0
- package/dist/shared/window/index.js +23 -0
- package/dist/shared/window/types/window.d.ts +84 -0
- package/dist/types/index.d.ts +102 -0
- package/dist/types/index.js +0 -0
- package/dist/vite/build/build-chunk.d.ts +53 -0
- package/dist/vite/build/build-csp-update.d.ts +80 -0
- package/dist/vite/build/build-obfuscation.d.ts +33 -0
- package/dist/vite/build/component-map.d.ts +38 -0
- package/dist/vite/build/component-resolver.d.ts +6 -0
- package/dist/vite/build/index.d.ts +9 -0
- package/dist/vite/build/index.js +18 -0
- package/dist/vite/build/types/build.d.ts +13 -0
- package/dist/vite/config/electron-app-config.d.ts +6 -0
- package/dist/vite/config/electron-builder-config.d.ts +8 -0
- package/dist/vite/config/electron-vite-config.d.ts +9 -0
- package/dist/vite/config/index.d.ts +11 -0
- package/dist/vite/config/index.js +2259 -0
- package/dist/vite/config/types/electron-app-options.d.ts +22 -0
- package/dist/vite/config/types/electron-builder-options.d.ts +16 -0
- package/dist/vite/config/types/electron-vite-options.d.ts +43 -0
- package/dist/vite/config/types/vite-obfuscation.d.ts +36 -0
- package/dist/vite/config/vite-obfuscation-config.d.ts +6 -0
- package/dist/vite/mode/index.d.ts +4 -0
- package/dist/vite/mode/index.js +8 -0
- package/dist/vite/mode/vite-mode.d.ts +37 -0
- package/dist/vite/orval/index.d.ts +4 -0
- package/dist/vite/orval/index.js +75 -0
- package/dist/vite/orval/orval-global-types.d.ts +23 -0
- package/dist/vite/utils/file-write-vite-util.d.ts +30 -0
- package/dist/vite/utils/index.d.ts +5 -0
- package/dist/vite/utils/index.js +10 -0
- package/dist/vite/utils/runtime-config-vite-util.d.ts +39 -0
- package/package.json +287 -0
|
@@ -0,0 +1,703 @@
|
|
|
1
|
+
import {
|
|
2
|
+
JwtAuthSessionChangedError
|
|
3
|
+
} from "./chunk-J34MOWJP.js";
|
|
4
|
+
import {
|
|
5
|
+
JwtAuthStore
|
|
6
|
+
} from "./chunk-B7DTBTWQ.js";
|
|
7
|
+
import {
|
|
8
|
+
AuthChannels
|
|
9
|
+
} from "./chunk-T3QCAOCO.js";
|
|
10
|
+
|
|
11
|
+
// src/main/auth/jwt-auth-refresh-rejected-error.ts
|
|
12
|
+
var JwtAuthRefreshRejectedError = class extends Error {
|
|
13
|
+
/**
|
|
14
|
+
* 构造函数
|
|
15
|
+
* @param {string} message 错误信息
|
|
16
|
+
*/
|
|
17
|
+
constructor(message = "\u5237\u65B0\u4EE4\u724C\u5DF2\u5931\u6548") {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = "JwtAuthRefreshRejectedError";
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// src/main/auth/jwt-auth-manager.ts
|
|
24
|
+
import { BrowserWindow, powerMonitor, session as electronSession } from "electron";
|
|
25
|
+
var JwtAuthManager = class {
|
|
26
|
+
/** Xion 应用 */
|
|
27
|
+
xoApp;
|
|
28
|
+
/** 业务 JWT Provider */
|
|
29
|
+
provider;
|
|
30
|
+
/** JWT 加密存储 */
|
|
31
|
+
store;
|
|
32
|
+
/** 是否已初始化 */
|
|
33
|
+
initialized = false;
|
|
34
|
+
/** 当前认证状态 */
|
|
35
|
+
state = { status: "unauthenticated" };
|
|
36
|
+
/** 访问令牌(内存中管理) */
|
|
37
|
+
accessToken;
|
|
38
|
+
/** 访问令牌绝对过期时间戳(内存中管理) */
|
|
39
|
+
accessTokenExpiresAt;
|
|
40
|
+
/** 内存中的刷新会话 */
|
|
41
|
+
storedRefreshSession;
|
|
42
|
+
/** 自动刷新定时器 */
|
|
43
|
+
refreshTimer;
|
|
44
|
+
/** 当前刷新任务,用于合并并发刷新 */
|
|
45
|
+
refreshPromise;
|
|
46
|
+
/** 当前退出任务,用于合并并发退出并阻止登录与退出交错执行 */
|
|
47
|
+
logoutPromise;
|
|
48
|
+
/** 认证操作版本号,用于阻止旧登录或刷新请求回写新会话 */
|
|
49
|
+
authRevision = 0;
|
|
50
|
+
/** 上一次观察到的远程服务连接状态 */
|
|
51
|
+
remoteConnected = false;
|
|
52
|
+
/** 是否已输出安全存储不可用警告 */
|
|
53
|
+
encryptionWarningLogged = false;
|
|
54
|
+
/**
|
|
55
|
+
* 构造函数
|
|
56
|
+
* @param {XoAppAbstract} xoApp Xion 应用
|
|
57
|
+
* @param {AnyJwtAuthProvider} provider 业务 JWT Provider
|
|
58
|
+
*/
|
|
59
|
+
constructor(xoApp, provider) {
|
|
60
|
+
this.xoApp = xoApp;
|
|
61
|
+
this.provider = provider;
|
|
62
|
+
this.store = new JwtAuthStore();
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 是否已配置 JWT 认证
|
|
66
|
+
* @returns {boolean}
|
|
67
|
+
*/
|
|
68
|
+
enabled() {
|
|
69
|
+
return this.provider !== void 0;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 获取当前认证操作版本
|
|
73
|
+
* @returns {number}
|
|
74
|
+
*/
|
|
75
|
+
getAuthRevision() {
|
|
76
|
+
return this.authRevision;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 获取由主进程管理的认证请求头名称
|
|
80
|
+
* <p>远程服务层使用这些名称阻止渲染进程伪造认证请求头</p>
|
|
81
|
+
* @returns {readonly string[]}
|
|
82
|
+
*/
|
|
83
|
+
getAuthenticationHeaderNames() {
|
|
84
|
+
const authorizationHeaderName = this.provider?.authorizationHeaderName ?? "Authorization";
|
|
85
|
+
const refreshTokenHeaderName = this.provider?.refreshTokenHeaderName ?? "X-Refresh-Token";
|
|
86
|
+
const deviceIdHeaderName = this.provider?.deviceIdHeaderName ?? "x-device-id";
|
|
87
|
+
return [...new Set([
|
|
88
|
+
// 兜底
|
|
89
|
+
"authorization",
|
|
90
|
+
"x-refresh-token",
|
|
91
|
+
"x-device-id",
|
|
92
|
+
// 业务设置
|
|
93
|
+
authorizationHeaderName,
|
|
94
|
+
refreshTokenHeaderName,
|
|
95
|
+
deviceIdHeaderName
|
|
96
|
+
].map((name) => name.trim().toLowerCase()))];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 获取远程服务管理器
|
|
100
|
+
* @returns {RemoteServiceManagerAbstract}
|
|
101
|
+
* @private
|
|
102
|
+
*/
|
|
103
|
+
getRemoteService() {
|
|
104
|
+
return this.xoApp.getRemoteServiceManager();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 获取 Electron 默认会话
|
|
108
|
+
* @returns {Electron.Session}
|
|
109
|
+
* @private
|
|
110
|
+
*/
|
|
111
|
+
electronSession() {
|
|
112
|
+
return electronSession.defaultSession;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 初始化认证模块
|
|
116
|
+
* <p>启动时存在有效刷新会话则自动刷新;远程服务暂不可用时保留会话并等待恢复</p>
|
|
117
|
+
* @returns {boolean} 是否启动了认证模块
|
|
118
|
+
*/
|
|
119
|
+
initialize() {
|
|
120
|
+
if (this.initialized || !this.provider) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
this.provider.requireValidate();
|
|
124
|
+
this.initialized = true;
|
|
125
|
+
this.getRemoteService().addStateListener((state) => {
|
|
126
|
+
const connected = state.status === "connected";
|
|
127
|
+
const becameConnected = connected && !this.remoteConnected;
|
|
128
|
+
this.remoteConnected = connected;
|
|
129
|
+
if (becameConnected) {
|
|
130
|
+
void this.refreshAccessTokenIfNeeded().catch((error) => {
|
|
131
|
+
this.xoApp.authLog.warn("\u8FDC\u7A0B\u670D\u52A1\u6062\u590D\u65F6\u5237\u65B0\u8BBF\u95EE\u4EE4\u724C\u5931\u8D25", this.errorMessage(error));
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
powerMonitor.on("resume", () => {
|
|
136
|
+
void this.refreshAccessTokenIfNeeded().catch((error) => {
|
|
137
|
+
this.xoApp.authLog.warn("\u7CFB\u7EDF\u6062\u590D\u65F6\u5237\u65B0\u8BBF\u95EE\u4EE4\u724C\u5931\u8D25", this.errorMessage(error));
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
void this.restoreRefreshSession();
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 获取可暴露给渲染进程的认证状态
|
|
145
|
+
* @returns {XoAuth.State}
|
|
146
|
+
*/
|
|
147
|
+
getState() {
|
|
148
|
+
return { ...this.state };
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* 登录
|
|
152
|
+
* @param {XoAuth.LoginRequest} request 登录请求
|
|
153
|
+
* @returns {Promise<XoAuth.State>}
|
|
154
|
+
*/
|
|
155
|
+
async login(request) {
|
|
156
|
+
if (this.logoutPromise) {
|
|
157
|
+
try {
|
|
158
|
+
await this.logoutPromise;
|
|
159
|
+
} catch {
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const provider = this.requireProvider();
|
|
163
|
+
this.clearSession();
|
|
164
|
+
const authRevision = this.authRevision;
|
|
165
|
+
this.updateStateAuthenticating();
|
|
166
|
+
try {
|
|
167
|
+
const response = await this.getRemoteService().request(
|
|
168
|
+
{
|
|
169
|
+
...provider.loginRequest(request),
|
|
170
|
+
method: provider.loginMethod,
|
|
171
|
+
path: provider.loginPath
|
|
172
|
+
},
|
|
173
|
+
this.electronSession(),
|
|
174
|
+
{ authentication: "none", retryUnauthorized: false }
|
|
175
|
+
);
|
|
176
|
+
if (this.authRevision !== authRevision) {
|
|
177
|
+
throw new Error("\u767B\u5F55\u8BF7\u6C42\u5DF2\u5931\u6548");
|
|
178
|
+
}
|
|
179
|
+
const authResult = provider.loginResponse(response);
|
|
180
|
+
this.requireResponseStatusOK(response, "\u767B\u5F55");
|
|
181
|
+
this.applyAuthResult(authResult);
|
|
182
|
+
return this.getState();
|
|
183
|
+
} catch (error) {
|
|
184
|
+
if (this.authRevision === authRevision) {
|
|
185
|
+
this.updateStateUnauthenticated(this.errorMessage(error));
|
|
186
|
+
}
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* 退出登录
|
|
192
|
+
* <p>无论服务端退出是否成功,都会清除本地令牌</p>
|
|
193
|
+
* @returns {Promise<XoAuth.State>}
|
|
194
|
+
*/
|
|
195
|
+
async logout() {
|
|
196
|
+
if (this.logoutPromise) {
|
|
197
|
+
return this.logoutPromise;
|
|
198
|
+
}
|
|
199
|
+
const promise = this.executeLogout();
|
|
200
|
+
this.logoutPromise = promise;
|
|
201
|
+
try {
|
|
202
|
+
return await promise;
|
|
203
|
+
} finally {
|
|
204
|
+
if (this.logoutPromise === promise) {
|
|
205
|
+
this.logoutPromise = void 0;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* 执行一次退出登录请求
|
|
211
|
+
* @returns {Promise<XoAuth.State>}
|
|
212
|
+
* @private
|
|
213
|
+
*/
|
|
214
|
+
async executeLogout() {
|
|
215
|
+
const provider = this.requireProvider();
|
|
216
|
+
try {
|
|
217
|
+
if (this.storedRefreshSession) {
|
|
218
|
+
const response = await this.getRemoteService().request(
|
|
219
|
+
{
|
|
220
|
+
...provider.logoutRequest(),
|
|
221
|
+
method: provider.logoutMethod,
|
|
222
|
+
path: provider.logoutPath
|
|
223
|
+
},
|
|
224
|
+
this.electronSession(),
|
|
225
|
+
{ retryUnauthorized: false }
|
|
226
|
+
);
|
|
227
|
+
provider.logoutResponse(response);
|
|
228
|
+
this.requireResponseStatusOK(response, "\u9000\u51FA\u767B\u5F55");
|
|
229
|
+
}
|
|
230
|
+
} finally {
|
|
231
|
+
this.clearSession();
|
|
232
|
+
}
|
|
233
|
+
return this.getState();
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* 使用刷新令牌更新令牌对(强制刷新,即使访问令牌未过期也刷新)
|
|
237
|
+
* @returns {Promise<void>}
|
|
238
|
+
*/
|
|
239
|
+
async refreshAccessToken() {
|
|
240
|
+
if (this.refreshPromise) {
|
|
241
|
+
return this.refreshPromise;
|
|
242
|
+
}
|
|
243
|
+
const promise = this.executeRefresh();
|
|
244
|
+
this.refreshPromise = promise;
|
|
245
|
+
try {
|
|
246
|
+
await promise;
|
|
247
|
+
} finally {
|
|
248
|
+
if (this.refreshPromise === promise) {
|
|
249
|
+
this.refreshPromise = void 0;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* 在存在刷新会话且访问令牌需要刷新时更新令牌对
|
|
255
|
+
* @returns {Promise<void>}
|
|
256
|
+
*/
|
|
257
|
+
async refreshAccessTokenIfNeeded() {
|
|
258
|
+
if (!this.storedRefreshSession || !this.shouldRefreshAccessToken()) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
await this.refreshAccessToken();
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* 执行一次刷新请求
|
|
265
|
+
* @returns {Promise<void>}
|
|
266
|
+
* @private
|
|
267
|
+
*/
|
|
268
|
+
async executeRefresh() {
|
|
269
|
+
const provider = this.requireProvider();
|
|
270
|
+
const session = this.storedRefreshSession;
|
|
271
|
+
const authRevision = this.authRevision;
|
|
272
|
+
if (!session) {
|
|
273
|
+
throw new Error("\u6CA1\u6709\u53EF\u7528\u7684\u5237\u65B0\u4EE4\u724C");
|
|
274
|
+
}
|
|
275
|
+
if (session.refreshTokenExpiresAt <= Date.now()) {
|
|
276
|
+
this.clearSession("\u767B\u5F55\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55");
|
|
277
|
+
throw new JwtAuthRefreshRejectedError("\u5237\u65B0\u4EE4\u724C\u5DF2\u8FC7\u671F");
|
|
278
|
+
}
|
|
279
|
+
const previousState = this.state.status;
|
|
280
|
+
this.updateStateRefreshing();
|
|
281
|
+
try {
|
|
282
|
+
const response = await this.getRemoteService().request(
|
|
283
|
+
{
|
|
284
|
+
...provider.refreshRequest(),
|
|
285
|
+
method: provider.refreshMethod,
|
|
286
|
+
path: provider.refreshPath
|
|
287
|
+
},
|
|
288
|
+
this.electronSession(),
|
|
289
|
+
{
|
|
290
|
+
authentication: "none",
|
|
291
|
+
retryUnauthorized: false,
|
|
292
|
+
// 注入刷新令牌请求头名称和值
|
|
293
|
+
authenticationHeaders: { [provider.refreshTokenHeaderName.trim()]: session.refreshToken }
|
|
294
|
+
}
|
|
295
|
+
);
|
|
296
|
+
if (this.authRevision !== authRevision) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
let authResult;
|
|
300
|
+
try {
|
|
301
|
+
authResult = provider.refreshResponse(response);
|
|
302
|
+
} catch (error) {
|
|
303
|
+
if (response.status === 401 || response.status === 403) {
|
|
304
|
+
throw new JwtAuthRefreshRejectedError(this.errorMessage(error));
|
|
305
|
+
}
|
|
306
|
+
throw error;
|
|
307
|
+
}
|
|
308
|
+
this.requireRefreshResponseStatusOK(response);
|
|
309
|
+
this.applyAuthResult(authResult);
|
|
310
|
+
} catch (error) {
|
|
311
|
+
if (this.authRevision !== authRevision) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
if (error instanceof JwtAuthRefreshRejectedError) {
|
|
315
|
+
this.clearSession(error.message);
|
|
316
|
+
throw error;
|
|
317
|
+
}
|
|
318
|
+
if (session.refreshTokenExpiresAt <= Date.now()) {
|
|
319
|
+
this.clearSession("\u767B\u5F55\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55");
|
|
320
|
+
throw error;
|
|
321
|
+
}
|
|
322
|
+
const refreshError = this.errorMessage(error);
|
|
323
|
+
if (this.hasValidAccessToken() || previousState === "authenticated") {
|
|
324
|
+
this.updateStateAuthenticated(this.storedRefreshSession?.user, refreshError);
|
|
325
|
+
} else {
|
|
326
|
+
this.updateStateError(refreshError);
|
|
327
|
+
}
|
|
328
|
+
this.scheduleRefreshRetry();
|
|
329
|
+
throw error;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* 获取请求使用的 Authorization 上下文
|
|
334
|
+
* <p>访问令牌即将过期时先自动刷新;刷新暂时失败但旧令牌仍有效时继续使用旧令牌</p>
|
|
335
|
+
* @returns {Promise<JwtAuthorizationContext | undefined>}
|
|
336
|
+
*/
|
|
337
|
+
async getAuthorizationContext() {
|
|
338
|
+
if (!this.provider || !this.storedRefreshSession) {
|
|
339
|
+
return void 0;
|
|
340
|
+
}
|
|
341
|
+
const authRevision = this.authRevision;
|
|
342
|
+
const accessExpiresAt = this.accessTokenExpiresAt ?? 0;
|
|
343
|
+
try {
|
|
344
|
+
await this.refreshAccessTokenIfNeeded();
|
|
345
|
+
} catch (error) {
|
|
346
|
+
if (!this.accessToken || accessExpiresAt <= Date.now()) {
|
|
347
|
+
throw error;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (this.authRevision !== authRevision) {
|
|
351
|
+
throw new JwtAuthSessionChangedError();
|
|
352
|
+
}
|
|
353
|
+
return this.hasValidAccessToken() ? this.buildAuthorizationContext(authRevision) : void 0;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* 处理携带访问令牌的请求返回 401
|
|
357
|
+
* <p>若其他并发请求已经完成令牌轮换,则直接返回新令牌,不重复刷新</p>
|
|
358
|
+
* @param {JwtAuthorizationContext} failedAuthorization 失败请求使用的 Authorization 上下文
|
|
359
|
+
* @returns {Promise<JwtAuthorizationContext | undefined>}
|
|
360
|
+
*/
|
|
361
|
+
async refreshAfterUnauthorized(failedAuthorization) {
|
|
362
|
+
if (this.authRevision !== failedAuthorization.revision) {
|
|
363
|
+
throw new JwtAuthSessionChangedError();
|
|
364
|
+
}
|
|
365
|
+
const currentAuthorization = this.hasValidAccessToken() ? this.buildAuthorizationHeader(this.accessToken) : void 0;
|
|
366
|
+
if (currentAuthorization && currentAuthorization !== failedAuthorization.header) {
|
|
367
|
+
return this.buildAuthorizationContext(failedAuthorization.revision, currentAuthorization);
|
|
368
|
+
}
|
|
369
|
+
await this.refreshAccessToken();
|
|
370
|
+
if (this.authRevision !== failedAuthorization.revision) {
|
|
371
|
+
throw new JwtAuthSessionChangedError();
|
|
372
|
+
}
|
|
373
|
+
return this.hasValidAccessToken() ? this.buildAuthorizationContext(failedAuthorization.revision) : void 0;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* 恢复磁盘中的加密刷新会话
|
|
377
|
+
* @returns {Promise<void>}
|
|
378
|
+
* @private
|
|
379
|
+
*/
|
|
380
|
+
async restoreRefreshSession() {
|
|
381
|
+
this.updateStateInitializing();
|
|
382
|
+
try {
|
|
383
|
+
const session = this.store.getSession();
|
|
384
|
+
if (!session) {
|
|
385
|
+
if (!this.store.isEncryptionAvailable()) {
|
|
386
|
+
this.onceLogEncryptionWarning();
|
|
387
|
+
}
|
|
388
|
+
this.updateStateUnauthenticated();
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
if (session.refreshTokenExpiresAt <= Date.now()) {
|
|
392
|
+
this.clearSession("\u767B\u5F55\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55");
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
this.storedRefreshSession = session;
|
|
396
|
+
this.updateStateInitializing(session.user);
|
|
397
|
+
await this.refreshAccessTokenIfNeeded();
|
|
398
|
+
} catch (error) {
|
|
399
|
+
if (!this.storedRefreshSession) {
|
|
400
|
+
this.updateStateUnauthenticated(this.errorMessage(error));
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* 应用并保存服务端返回的认证结果
|
|
406
|
+
* @param {XoAuth.AuthResult} authResult 认证结果
|
|
407
|
+
* @returns {void}
|
|
408
|
+
* @private
|
|
409
|
+
*/
|
|
410
|
+
applyAuthResult(authResult) {
|
|
411
|
+
this.validateTokenPair(authResult);
|
|
412
|
+
const storedSession = {
|
|
413
|
+
refreshToken: authResult.refreshToken,
|
|
414
|
+
refreshTokenExpiresAt: authResult.refreshTokenExpiresAt,
|
|
415
|
+
user: authResult.user ?? this.storedRefreshSession?.user
|
|
416
|
+
};
|
|
417
|
+
this.accessToken = authResult.accessToken;
|
|
418
|
+
this.accessTokenExpiresAt = authResult.accessTokenExpiresAt;
|
|
419
|
+
this.storedRefreshSession = storedSession;
|
|
420
|
+
this.persistRefreshSession(storedSession);
|
|
421
|
+
this.updateStateAuthenticated(storedSession.user);
|
|
422
|
+
this.scheduleRefresh();
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* 校验令牌对
|
|
426
|
+
* @param {XoAuth.TokenPair} tokenPair 令牌对
|
|
427
|
+
* @returns {void}
|
|
428
|
+
* @private
|
|
429
|
+
*/
|
|
430
|
+
validateTokenPair(tokenPair) {
|
|
431
|
+
const now = Date.now();
|
|
432
|
+
if (!tokenPair.accessToken?.trim() || !Number.isFinite(tokenPair.accessTokenExpiresAt) || tokenPair.accessTokenExpiresAt <= now) {
|
|
433
|
+
throw new Error("\u670D\u52A1\u7AEF\u8FD4\u56DE\u7684\u8BBF\u95EE\u4EE4\u724C\u65E0\u6548");
|
|
434
|
+
}
|
|
435
|
+
if (!tokenPair.refreshToken?.trim() || !Number.isFinite(tokenPair.refreshTokenExpiresAt) || tokenPair.refreshTokenExpiresAt <= now) {
|
|
436
|
+
throw new Error("\u670D\u52A1\u7AEF\u8FD4\u56DE\u7684\u5237\u65B0\u4EE4\u724C\u65E0\u6548");
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* 持久化刷新会话
|
|
441
|
+
* <p>持久化失败时保留内存会话,避免将服务端已经成功的登录误判为失败</p>
|
|
442
|
+
* @param {XoAuth.StoredRefreshSession} session 刷新会话
|
|
443
|
+
* @returns {void}
|
|
444
|
+
* @private
|
|
445
|
+
*/
|
|
446
|
+
persistRefreshSession(session) {
|
|
447
|
+
try {
|
|
448
|
+
if (!this.store.setSession(session)) {
|
|
449
|
+
this.onceLogEncryptionWarning();
|
|
450
|
+
}
|
|
451
|
+
} catch (error) {
|
|
452
|
+
this.xoApp.authLog.error("JWT \u767B\u5F55\u4F1A\u8BDD\u52A0\u5BC6\u5B58\u50A8\u5931\u8D25", error);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* 安排访问令牌到期前自动刷新
|
|
457
|
+
* @returns {void}
|
|
458
|
+
* @private
|
|
459
|
+
*/
|
|
460
|
+
scheduleRefresh() {
|
|
461
|
+
this.clearRefreshTimer();
|
|
462
|
+
if (!this.accessTokenExpiresAt || !this.storedRefreshSession) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
const refreshBeforeExpiration = this.provider?.refreshBeforeExpiration ?? 0;
|
|
466
|
+
const delay = Math.max(1e3, this.accessTokenExpiresAt - Date.now() - refreshBeforeExpiration);
|
|
467
|
+
this.refreshTimer = setTimeout(() => {
|
|
468
|
+
void this.refreshAccessTokenIfNeeded().catch((error) => {
|
|
469
|
+
this.xoApp.authLog.warn("\u8BBF\u95EE\u4EE4\u724C\u81EA\u52A8\u5237\u65B0\u5931\u8D25", this.errorMessage(error));
|
|
470
|
+
});
|
|
471
|
+
}, delay);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* 安排刷新失败后的重试
|
|
475
|
+
* @returns {void}
|
|
476
|
+
* @private
|
|
477
|
+
*/
|
|
478
|
+
scheduleRefreshRetry() {
|
|
479
|
+
this.clearRefreshTimer();
|
|
480
|
+
if (!this.storedRefreshSession || this.storedRefreshSession.refreshTokenExpiresAt <= Date.now()) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
const remaining = this.storedRefreshSession.refreshTokenExpiresAt - Date.now();
|
|
484
|
+
const retryDelay = this.provider?.refreshRetryDelay ?? remaining;
|
|
485
|
+
const delay = Math.max(1e3, Math.min(retryDelay, remaining));
|
|
486
|
+
this.refreshTimer = setTimeout(() => {
|
|
487
|
+
void this.refreshAccessToken().catch((error) => {
|
|
488
|
+
this.xoApp.authLog.warn("\u8BBF\u95EE\u4EE4\u724C\u91CD\u8BD5\u5237\u65B0\u5931\u8D25", this.errorMessage(error));
|
|
489
|
+
});
|
|
490
|
+
}, delay);
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* 清除本地会话
|
|
494
|
+
* @param {string} error 可选状态提示
|
|
495
|
+
* @returns {void}
|
|
496
|
+
* @private
|
|
497
|
+
*/
|
|
498
|
+
clearSession(error) {
|
|
499
|
+
this.authRevision++;
|
|
500
|
+
this.refreshPromise = void 0;
|
|
501
|
+
this.clearRefreshTimer();
|
|
502
|
+
this.accessToken = void 0;
|
|
503
|
+
this.accessTokenExpiresAt = void 0;
|
|
504
|
+
this.storedRefreshSession = void 0;
|
|
505
|
+
this.store.clear();
|
|
506
|
+
this.updateStateUnauthenticated(error);
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* 清除自动刷新定时器
|
|
510
|
+
* @returns {void}
|
|
511
|
+
* @private
|
|
512
|
+
*/
|
|
513
|
+
clearRefreshTimer() {
|
|
514
|
+
if (this.refreshTimer) {
|
|
515
|
+
clearTimeout(this.refreshTimer);
|
|
516
|
+
this.refreshTimer = void 0;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* 当前访问令牌是否有效
|
|
521
|
+
* @returns {boolean}
|
|
522
|
+
* @private
|
|
523
|
+
*/
|
|
524
|
+
hasValidAccessToken() {
|
|
525
|
+
return Boolean(this.accessToken && this.accessTokenExpiresAt && this.accessTokenExpiresAt > Date.now());
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* 判断访问令牌是否需要刷新
|
|
529
|
+
* <p>访问令牌缺失、已经过期或进入 Provider 配置的提前刷新窗口时返回 true</p>
|
|
530
|
+
* @returns {boolean}
|
|
531
|
+
* @private
|
|
532
|
+
*/
|
|
533
|
+
shouldRefreshAccessToken() {
|
|
534
|
+
const accessExpiresAt = this.accessTokenExpiresAt ?? 0;
|
|
535
|
+
const refreshBeforeExpiration = this.provider?.refreshBeforeExpiration ?? 0;
|
|
536
|
+
return !this.accessToken || accessExpiresAt <= Date.now() + refreshBeforeExpiration;
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* 构建 Authorization 请求头
|
|
540
|
+
* @param {string} accessToken 访问令牌
|
|
541
|
+
* @returns {string}
|
|
542
|
+
* @private
|
|
543
|
+
*/
|
|
544
|
+
buildAuthorizationHeader(accessToken) {
|
|
545
|
+
const scheme = this.provider?.authorizationScheme.trim() || "Bearer";
|
|
546
|
+
return `${scheme} ${accessToken}`;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* 构建设备标识请求头
|
|
550
|
+
* @returns {Readonly<Record<string, string>> | undefined}
|
|
551
|
+
* @private
|
|
552
|
+
*/
|
|
553
|
+
getDeviceIdHeaders() {
|
|
554
|
+
if (!this.provider?.useDeviceIdHeader) {
|
|
555
|
+
return void 0;
|
|
556
|
+
}
|
|
557
|
+
return {
|
|
558
|
+
[this.provider.deviceIdHeaderName.trim()]: this.xoApp.getAppStore().getDeviceId()
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* 构建访问令牌请求头上下文
|
|
563
|
+
* @param {number} revision 认证操作版本
|
|
564
|
+
* @param {string} accessHeader 可选访问令牌请求头值
|
|
565
|
+
* @returns {JwtAuthorizationContext}
|
|
566
|
+
* @private
|
|
567
|
+
*/
|
|
568
|
+
buildAuthorizationContext(revision, accessHeader) {
|
|
569
|
+
return {
|
|
570
|
+
headerName: this.provider?.authorizationHeaderName.trim() || "Authorization",
|
|
571
|
+
header: accessHeader ?? this.buildAuthorizationHeader(this.accessToken),
|
|
572
|
+
revision
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* 获取业务 Provider,未配置时抛出错误
|
|
577
|
+
* @returns {AnyJwtAuthProvider}
|
|
578
|
+
* @private
|
|
579
|
+
*/
|
|
580
|
+
requireProvider() {
|
|
581
|
+
if (!this.provider) {
|
|
582
|
+
throw new Error("\u672A\u914D\u7F6E JWT \u8BA4\u8BC1 Provider");
|
|
583
|
+
}
|
|
584
|
+
return this.provider;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* 校验刷新接口响应状态,确保 HTTP 状态码为 200
|
|
588
|
+
* @param {XoRemoteService.Response} response 响应
|
|
589
|
+
* @returns {void}
|
|
590
|
+
* @private
|
|
591
|
+
*/
|
|
592
|
+
requireRefreshResponseStatusOK(response) {
|
|
593
|
+
if (response.status === 401 || response.status === 403) {
|
|
594
|
+
throw new JwtAuthRefreshRejectedError("\u5237\u65B0\u4EE4\u724C\u5DF2\u88AB\u670D\u52A1\u7AEF\u62D2\u7EDD");
|
|
595
|
+
}
|
|
596
|
+
this.requireResponseStatusOK(response, "\u5237\u65B0\u4EE4\u724C");
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* 更新状态并同步全部窗口
|
|
600
|
+
* @param {Partial<XoAuth.State>} state 状态变更
|
|
601
|
+
* @returns {void}
|
|
602
|
+
* @private
|
|
603
|
+
*/
|
|
604
|
+
updateState(state) {
|
|
605
|
+
this.state = { ...this.state, ...state };
|
|
606
|
+
BrowserWindow.getAllWindows().forEach((window) => {
|
|
607
|
+
if (!window.isDestroyed() && !window.webContents.isDestroyed()) {
|
|
608
|
+
window.webContents.send(AuthChannels.onState, this.getState());
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* 更新为初始化状态
|
|
614
|
+
* @param {XoAuth.User} user 持久化的用户快照
|
|
615
|
+
* @returns {void}
|
|
616
|
+
* @private
|
|
617
|
+
*/
|
|
618
|
+
updateStateInitializing(user) {
|
|
619
|
+
this.updateState({ status: "initializing", user, error: void 0 });
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* 更新为认证中状态
|
|
623
|
+
* @returns {void}
|
|
624
|
+
* @private
|
|
625
|
+
*/
|
|
626
|
+
updateStateAuthenticating() {
|
|
627
|
+
this.updateState({ status: "authenticating", error: void 0 });
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* 更新为刷新中状态
|
|
631
|
+
* @returns {void}
|
|
632
|
+
* @private
|
|
633
|
+
*/
|
|
634
|
+
updateStateRefreshing() {
|
|
635
|
+
this.updateState({ status: "refreshing", error: void 0 });
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* 更新为已认证状态
|
|
639
|
+
* @param {XoAuth.User} user 认证用户
|
|
640
|
+
* @param {string} error 可选错误信息
|
|
641
|
+
* @returns {void}
|
|
642
|
+
* @private
|
|
643
|
+
*/
|
|
644
|
+
updateStateAuthenticated(user, error) {
|
|
645
|
+
this.updateState({ status: "authenticated", user, error });
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* 更新为未认证状态
|
|
649
|
+
* @param {string} error 可选错误信息
|
|
650
|
+
* @returns {void}
|
|
651
|
+
* @private
|
|
652
|
+
*/
|
|
653
|
+
updateStateUnauthenticated(error) {
|
|
654
|
+
this.updateState({ status: "unauthenticated", user: void 0, error });
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* 更新为错误状态
|
|
658
|
+
* @param {string} error 错误信息
|
|
659
|
+
* @returns {void}
|
|
660
|
+
* @private
|
|
661
|
+
*/
|
|
662
|
+
updateStateError(error) {
|
|
663
|
+
this.updateState({ status: "error", error });
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* 校验接口响应状态,确保 HTTP 状态码为 200
|
|
667
|
+
* @param {XoRemoteService.Response} response 响应
|
|
668
|
+
* @param {string} action 操作名称
|
|
669
|
+
* @returns {void}
|
|
670
|
+
* @private
|
|
671
|
+
*/
|
|
672
|
+
requireResponseStatusOK(response, action) {
|
|
673
|
+
if (response.status !== 200) {
|
|
674
|
+
throw new Error(`${action}\u5931\u8D25\uFF0CHTTP \u72B6\u6001\u7801 ${response.status}`);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* 仅输出一次安全存储不可用警告
|
|
679
|
+
* @returns {void}
|
|
680
|
+
* @private
|
|
681
|
+
*/
|
|
682
|
+
onceLogEncryptionWarning() {
|
|
683
|
+
if (this.encryptionWarningLogged) {
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
this.encryptionWarningLogged = true;
|
|
687
|
+
this.xoApp.authLog.warn("safeStorage \u4E0D\u53EF\u7528\uFF0C\u5237\u65B0\u4EE4\u724C\u4EC5\u5728\u672C\u6B21\u8FD0\u884C\u671F\u95F4\u4FDD\u5B58\u5728\u5185\u5B58\u4E2D");
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* 获取错误信息
|
|
691
|
+
* @param {unknown} error 错误
|
|
692
|
+
* @returns {string}
|
|
693
|
+
* @private
|
|
694
|
+
*/
|
|
695
|
+
errorMessage(error) {
|
|
696
|
+
return error instanceof Error ? error.message : String(error || "JWT \u8BA4\u8BC1\u5931\u8D25");
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
export {
|
|
701
|
+
JwtAuthRefreshRejectedError,
|
|
702
|
+
JwtAuthManager
|
|
703
|
+
};
|