mn-ws 0.1.0 → 0.2.0
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/assets/groups.json +10 -0
- package/assets/mn-ws/SKILL.md +55 -0
- package/assets/mn-ws/hooks.json +14 -0
- package/assets/mn-ws/install/inject-root.mjs +26 -0
- package/bin/ws.mjs +13 -0
- package/dist/core/auth.d.ts +194 -0
- package/dist/core/auth.d.ts.map +1 -0
- package/dist/core/auth.js +331 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/brand.d.ts +11 -0
- package/dist/core/brand.d.ts.map +1 -0
- package/dist/core/brand.js +7 -0
- package/dist/core/brand.js.map +1 -0
- package/dist/core/bridge.d.ts +106 -0
- package/dist/core/bridge.d.ts.map +1 -0
- package/dist/core/bridge.js +308 -0
- package/dist/core/bridge.js.map +1 -0
- package/dist/core/config.d.ts +174 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +417 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/controller.d.ts +64 -0
- package/dist/core/controller.d.ts.map +1 -0
- package/dist/core/controller.js +100 -0
- package/dist/core/controller.js.map +1 -0
- package/dist/core/errors/index.d.ts +30 -0
- package/dist/core/errors/index.d.ts.map +1 -0
- package/dist/core/errors/index.js +88 -0
- package/dist/core/errors/index.js.map +1 -0
- package/dist/core/open.d.ts +3 -0
- package/dist/core/open.d.ts.map +1 -0
- package/dist/core/open.js +27 -0
- package/dist/core/open.js.map +1 -0
- package/dist/core/paths.d.ts +15 -0
- package/dist/core/paths.d.ts.map +1 -0
- package/dist/core/paths.js +50 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/serve-port.d.ts +73 -0
- package/dist/core/serve-port.d.ts.map +1 -0
- package/dist/core/serve-port.js +134 -0
- package/dist/core/serve-port.js.map +1 -0
- package/dist/core/session.d.ts +78 -0
- package/dist/core/session.d.ts.map +1 -0
- package/dist/core/session.js +124 -0
- package/dist/core/session.js.map +1 -0
- package/dist/core/skills/bus.d.ts +29 -0
- package/dist/core/skills/bus.d.ts.map +1 -0
- package/dist/core/skills/bus.js +114 -0
- package/dist/core/skills/bus.js.map +1 -0
- package/dist/core/skills/get.d.ts +17 -0
- package/dist/core/skills/get.d.ts.map +1 -0
- package/dist/core/skills/get.js +87 -0
- package/dist/core/skills/get.js.map +1 -0
- package/dist/core/skills/handlers.d.ts +22 -0
- package/dist/core/skills/handlers.d.ts.map +1 -0
- package/dist/core/skills/handlers.js +86 -0
- package/dist/core/skills/handlers.js.map +1 -0
- package/dist/core/skills/index.d.ts +47 -0
- package/dist/core/skills/index.d.ts.map +1 -0
- package/dist/core/skills/index.js +268 -0
- package/dist/core/skills/index.js.map +1 -0
- package/dist/core/skills/install.d.ts +18 -0
- package/dist/core/skills/install.d.ts.map +1 -0
- package/dist/core/skills/install.js +123 -0
- package/dist/core/skills/install.js.map +1 -0
- package/dist/core/skills/text-util.d.ts +2 -0
- package/dist/core/skills/text-util.d.ts.map +1 -0
- package/dist/core/skills/text-util.js +14 -0
- package/dist/core/skills/text-util.js.map +1 -0
- package/dist/core/store.d.ts +29 -0
- package/dist/core/store.d.ts.map +1 -0
- package/dist/core/store.js +100 -0
- package/dist/core/store.js.map +1 -0
- package/dist/core/views.d.ts +11 -0
- package/dist/core/views.d.ts.map +1 -0
- package/dist/core/views.js +20 -0
- package/dist/core/views.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/auth/index.d.ts +73 -0
- package/dist/modules/auth/index.d.ts.map +1 -0
- package/dist/modules/auth/index.js +64 -0
- package/dist/modules/auth/index.js.map +1 -0
- package/dist/modules/auth/service.d.ts +98 -0
- package/dist/modules/auth/service.d.ts.map +1 -0
- package/dist/modules/auth/service.js +200 -0
- package/dist/modules/auth/service.js.map +1 -0
- package/dist/modules/bridge/index.d.ts +73 -0
- package/dist/modules/bridge/index.d.ts.map +1 -0
- package/dist/modules/bridge/index.js +89 -0
- package/dist/modules/bridge/index.js.map +1 -0
- package/dist/modules/bridge/service.d.ts +75 -0
- package/dist/modules/bridge/service.d.ts.map +1 -0
- package/dist/modules/bridge/service.js +134 -0
- package/dist/modules/bridge/service.js.map +1 -0
- package/dist/modules/home/index.d.ts +95 -0
- package/dist/modules/home/index.d.ts.map +1 -0
- package/dist/modules/home/index.js +123 -0
- package/dist/modules/home/index.js.map +1 -0
- package/dist/modules/home/service.d.ts +48 -0
- package/dist/modules/home/service.d.ts.map +1 -0
- package/dist/modules/home/service.js +195 -0
- package/dist/modules/home/service.js.map +1 -0
- package/dist/modules/skill/index.d.ts +78 -0
- package/dist/modules/skill/index.d.ts.map +1 -0
- package/dist/modules/skill/index.js +132 -0
- package/dist/modules/skill/index.js.map +1 -0
- package/dist/runtime/api.d.ts +24 -0
- package/dist/runtime/api.d.ts.map +1 -0
- package/dist/runtime/api.js +140 -0
- package/dist/runtime/api.js.map +1 -0
- package/dist/runtime/cli.d.ts +23 -0
- package/dist/runtime/cli.d.ts.map +1 -0
- package/dist/runtime/cli.js +410 -0
- package/dist/runtime/cli.js.map +1 -0
- package/dist/runtime/help.d.ts +29 -0
- package/dist/runtime/help.d.ts.map +1 -0
- package/dist/runtime/help.js +89 -0
- package/dist/runtime/help.js.map +1 -0
- package/dist/runtime/registry.d.ts +318 -0
- package/dist/runtime/registry.d.ts.map +1 -0
- package/dist/runtime/registry.js +75 -0
- package/dist/runtime/registry.js.map +1 -0
- package/dist/runtime/server.d.ts +10 -0
- package/dist/runtime/server.d.ts.map +1 -0
- package/dist/runtime/server.js +127 -0
- package/dist/runtime/server.js.map +1 -0
- package/dist/runtime/spec.d.ts +32 -0
- package/dist/runtime/spec.d.ts.map +1 -0
- package/dist/runtime/spec.js +180 -0
- package/dist/runtime/spec.js.map +1 -0
- package/dist/runtime/types/action.d.ts +101 -0
- package/dist/runtime/types/action.d.ts.map +1 -0
- package/dist/runtime/types/action.js +19 -0
- package/dist/runtime/types/action.js.map +1 -0
- package/dist/runtime/types/client.d.ts +39 -0
- package/dist/runtime/types/client.d.ts.map +1 -0
- package/dist/runtime/types/client.js +2 -0
- package/dist/runtime/types/client.js.map +1 -0
- package/dist/runtime/types/http.d.ts +22 -0
- package/dist/runtime/types/http.d.ts.map +1 -0
- package/dist/runtime/types/http.js +6 -0
- package/dist/runtime/types/http.js.map +1 -0
- package/dist/runtime/types/module.d.ts +72 -0
- package/dist/runtime/types/module.d.ts.map +1 -0
- package/dist/runtime/types/module.js +15 -0
- package/dist/runtime/types/module.js.map +1 -0
- package/dist/web/public/assets/CliHints-BOxU-Duc.js +1 -0
- package/dist/web/public/assets/index-BTRKdMIW.js +50 -0
- package/dist/web/public/assets/index-BjGe8ggI.css +1 -0
- package/dist/web/public/assets/view-CE4tnCuy.js +1 -0
- package/dist/web/public/assets/view-CEQ2uPxE.js +1 -0
- package/dist/web/public/favicon-16.png +0 -0
- package/dist/web/public/favicon-32.png +0 -0
- package/dist/web/public/favicon-48.png +0 -0
- package/dist/web/public/favicon.ico +0 -0
- package/dist/web/public/index.html +19 -0
- package/dist/web/public/logo-rounded.png +0 -0
- package/dist/web/public/logo-rounded.svg +6 -0
- package/dist/web/public/logo.png +0 -0
- package/dist/web/public/logo.svg +6 -0
- package/package.json +52 -31
- package/README.md +0 -251
- package/bin/index.js +0 -714
- package/client/bridge-client.js +0 -160
- package/client/web.js +0 -234
- package/client/ws-client.js +0 -191
- package/lib/apps.js +0 -237
- package/lib/auth.js +0 -319
- package/lib/config.js +0 -534
- package/lib/index.js +0 -15
- package/lib/logger.js +0 -63
- package/lib/protocol.js +0 -208
- package/lib/store.js +0 -66
- package/server/auth.js +0 -274
- package/server/server.js +0 -752
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// 「有哪些页面」的**单一来源**:纯数据、零 import。
|
|
2
|
+
//
|
|
3
|
+
// 为什么放 core 而不是前端注册表:这份清单两端都要读——
|
|
4
|
+
// - 前端(web/frontend/registry.ts)按 id 拼出懒加载组件,渲染头部导航
|
|
5
|
+
// - 后端(modules/home)按 id 校验「导航分组 / 隐藏」配置,坏 id 当场报错
|
|
6
|
+
// 放 core 且不 import 任何东西,两边都能安全引用(前端不会因此把 node: 打进包里)。
|
|
7
|
+
//
|
|
8
|
+
// 新增一个页面 = 写 modules/<域>/view.tsx + 这里加一行 + registry.ts 的 COMPONENTS 加一行。
|
|
9
|
+
// tests/unit/registry.test.mjs 把「清单 ↔ 组件 ↔ 模块目录」钉在一起对账。
|
|
10
|
+
export const VIEWS_META = [
|
|
11
|
+
{ id: 'home', title: '首页', order: 10 },
|
|
12
|
+
{ id: 'bridge', title: '桥接', order: 20 },
|
|
13
|
+
];
|
|
14
|
+
export function viewMetaOf(id) {
|
|
15
|
+
return VIEWS_META.find((v) => v.id === id) || null;
|
|
16
|
+
}
|
|
17
|
+
export function viewIdsOf() {
|
|
18
|
+
return VIEWS_META.map((v) => v.id);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=views.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"views.js","sourceRoot":"","sources":["../../src/core/views.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,EAAE;AACF,iCAAiC;AACjC,sDAAsD;AACtD,qDAAqD;AACrD,sDAAsD;AACtD,EAAE;AACF,0EAA0E;AAC1E,wDAAwD;AAUxD,MAAM,CAAC,MAAM,UAAU,GAAwB;IAC7C,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;IACtC,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;CACzC,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,EAAU;IACnC,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * as errors from './core/errors/index.js';
|
|
2
|
+
export * as homeService from './modules/home/service.js';
|
|
3
|
+
export { ACTIONS, MODULES } from './runtime/registry.js';
|
|
4
|
+
export { startServer } from './runtime/server.js';
|
|
5
|
+
export { runCli } from './runtime/cli.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,KAAK,WAAW,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// 编程入口:供其他工具 / agent 以库方式调用。
|
|
2
|
+
// 导出的是各模块的 service(业务真相源),不是 CLI/HTTP 壳——库用方自己组织 I/O。
|
|
3
|
+
export * as errors from './core/errors/index.js';
|
|
4
|
+
export * as homeService from './modules/home/service.js';
|
|
5
|
+
export { ACTIONS, MODULES } from './runtime/registry.js';
|
|
6
|
+
export { startServer } from './runtime/server.js';
|
|
7
|
+
export { runCli } from './runtime/cli.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,sDAAsD;AACtD,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,KAAK,WAAW,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
readonly id: "auth";
|
|
3
|
+
readonly title: "登录";
|
|
4
|
+
readonly order: 3;
|
|
5
|
+
readonly actions: readonly [import("../../runtime/types/action.js").TypedAction<{
|
|
6
|
+
readonly id: "auth.login";
|
|
7
|
+
readonly cli: readonly ["auth", "login"];
|
|
8
|
+
readonly http: readonly ["POST", "/api/auth/login/start"];
|
|
9
|
+
readonly summary: "统一登录(弹浏览器):换回设备令牌,之后免手填";
|
|
10
|
+
readonly flags: {
|
|
11
|
+
readonly 'new-account': {
|
|
12
|
+
readonly type: "boolean";
|
|
13
|
+
readonly hint: "强制认证中心重新登录(换人用)";
|
|
14
|
+
};
|
|
15
|
+
readonly 'no-open': {
|
|
16
|
+
readonly type: "boolean";
|
|
17
|
+
readonly hint: "只打印授权地址、不弹浏览器";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}, import("./service.js").LoginView>, import("../../runtime/types/action.js").TypedAction<{
|
|
21
|
+
readonly id: "auth.list";
|
|
22
|
+
readonly cli: readonly ["auth", "list"];
|
|
23
|
+
readonly http: readonly ["GET", "/api/auth/accounts"];
|
|
24
|
+
readonly summary: "列出本机已存账号";
|
|
25
|
+
}, import("./service.js").AccountsView>, import("../../runtime/types/action.js").TypedAction<{
|
|
26
|
+
readonly id: "auth.switch";
|
|
27
|
+
readonly cli: readonly ["auth", "switch"];
|
|
28
|
+
readonly http: readonly ["POST", "/api/auth/switch"];
|
|
29
|
+
readonly summary: "切换当前生效账号(序号/邮箱/用户名/昵称)";
|
|
30
|
+
readonly args: readonly [{
|
|
31
|
+
readonly name: "account";
|
|
32
|
+
readonly required: false;
|
|
33
|
+
}];
|
|
34
|
+
}, {
|
|
35
|
+
ok: boolean;
|
|
36
|
+
changed: boolean;
|
|
37
|
+
key?: string;
|
|
38
|
+
label?: string;
|
|
39
|
+
error?: string;
|
|
40
|
+
}>, import("../../runtime/types/action.js").TypedAction<{
|
|
41
|
+
readonly id: "auth.status";
|
|
42
|
+
readonly cli: readonly ["auth", "status"];
|
|
43
|
+
readonly http: readonly ["GET", "/api/auth/status"];
|
|
44
|
+
readonly summary: "查看当前身份、令牌剩余有效期";
|
|
45
|
+
}, {
|
|
46
|
+
loggedIn: boolean;
|
|
47
|
+
userId?: string;
|
|
48
|
+
email?: string;
|
|
49
|
+
nickname?: string;
|
|
50
|
+
clientId: string;
|
|
51
|
+
serverHttp: string;
|
|
52
|
+
expiresAt?: number;
|
|
53
|
+
expired: boolean;
|
|
54
|
+
via: string;
|
|
55
|
+
}>, import("../../runtime/types/action.js").TypedAction<{
|
|
56
|
+
readonly id: "auth.logout";
|
|
57
|
+
readonly cli: readonly ["auth", "logout"];
|
|
58
|
+
readonly http: readonly ["POST", "/api/auth/logout"];
|
|
59
|
+
readonly summary: "清除登录凭据(--all 清空全部账号)";
|
|
60
|
+
readonly flags: {
|
|
61
|
+
readonly all: {
|
|
62
|
+
readonly type: "boolean";
|
|
63
|
+
readonly hint: "清空全部账号";
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
}, {
|
|
67
|
+
ok: boolean;
|
|
68
|
+
remaining: number;
|
|
69
|
+
error?: string;
|
|
70
|
+
}>];
|
|
71
|
+
};
|
|
72
|
+
export default _default;
|
|
73
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,wBAoEG"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// auth 模块:统一登录(go-ah auth-hub)与本机多账号账号簿。
|
|
2
|
+
//
|
|
3
|
+
// login 弹浏览器完成一次授权 → 换回设备令牌,之后免手填
|
|
4
|
+
// list 列出本机已存账号(标出当前生效的那个)
|
|
5
|
+
// switch 切换当前生效账号(多人共用这台电脑时就是换人)
|
|
6
|
+
// status 查看当前身份、令牌剩余有效期
|
|
7
|
+
// logout 清除登录凭据(默认只清当前账号,--all 清空全部)
|
|
8
|
+
//
|
|
9
|
+
// 与 mn-rt 的 auth 同一套形状(命令名、账号簿语义、--new-account 都对齐)。
|
|
10
|
+
import { defineAction } from '../../runtime/types/action.js';
|
|
11
|
+
import { defineModule } from '../../runtime/types/module.js';
|
|
12
|
+
import { getController } from '../../core/controller.js';
|
|
13
|
+
import { login, listAccountsView, switchAccount, authStatus, logout, renderLogin, renderList, renderSwitch, renderStatus, renderLogout, } from './service.js';
|
|
14
|
+
export default defineModule({
|
|
15
|
+
id: 'auth',
|
|
16
|
+
title: '登录',
|
|
17
|
+
order: 3,
|
|
18
|
+
actions: [
|
|
19
|
+
defineAction({
|
|
20
|
+
id: 'auth.login',
|
|
21
|
+
cli: ['auth', 'login'],
|
|
22
|
+
http: ['POST', '/api/auth/login/start'],
|
|
23
|
+
summary: '统一登录(弹浏览器):换回设备令牌,之后免手填',
|
|
24
|
+
flags: {
|
|
25
|
+
'new-account': { type: 'boolean', hint: '强制认证中心重新登录(换人用)' },
|
|
26
|
+
'no-open': { type: 'boolean', hint: '只打印授权地址、不弹浏览器' },
|
|
27
|
+
},
|
|
28
|
+
})(async (ctx, meta) => login(getController(), {
|
|
29
|
+
newAccount: ctx['new-account'] === true,
|
|
30
|
+
noOpen: ctx['no-open'] === true,
|
|
31
|
+
// 面板与 CLI 的登录流程**发起位置不同**:
|
|
32
|
+
// CLI → 自己起一个随机端口的回环监听
|
|
33
|
+
// 面板 → 回调落在面板自己的 /callback(端口是面板运行时选的)
|
|
34
|
+
transport: meta?.transport,
|
|
35
|
+
}), (r) => renderLogin(r)),
|
|
36
|
+
defineAction({
|
|
37
|
+
id: 'auth.list',
|
|
38
|
+
cli: ['auth', 'list'],
|
|
39
|
+
http: ['GET', '/api/auth/accounts'],
|
|
40
|
+
summary: '列出本机已存账号',
|
|
41
|
+
})(() => listAccountsView(getController()), (r) => renderList(r)),
|
|
42
|
+
defineAction({
|
|
43
|
+
id: 'auth.switch',
|
|
44
|
+
cli: ['auth', 'switch'],
|
|
45
|
+
http: ['POST', '/api/auth/switch'],
|
|
46
|
+
summary: '切换当前生效账号(序号/邮箱/用户名/昵称)',
|
|
47
|
+
args: [{ name: 'account', required: false }],
|
|
48
|
+
})((ctx) => switchAccount(getController(), String(ctx.account || '')), (r) => renderSwitch(r)),
|
|
49
|
+
defineAction({
|
|
50
|
+
id: 'auth.status',
|
|
51
|
+
cli: ['auth', 'status'],
|
|
52
|
+
http: ['GET', '/api/auth/status'],
|
|
53
|
+
summary: '查看当前身份、令牌剩余有效期',
|
|
54
|
+
})(() => authStatus(getController()), (r) => renderStatus(r)),
|
|
55
|
+
defineAction({
|
|
56
|
+
id: 'auth.logout',
|
|
57
|
+
cli: ['auth', 'logout'],
|
|
58
|
+
http: ['POST', '/api/auth/logout'],
|
|
59
|
+
summary: '清除登录凭据(--all 清空全部账号)',
|
|
60
|
+
flags: { all: { type: 'boolean', hint: '清空全部账号' } },
|
|
61
|
+
})((ctx) => logout(getController(), ctx.all === true), (r) => renderLogout(r)),
|
|
62
|
+
],
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/auth/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,sCAAsC;AACtC,gCAAgC;AAChC,o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AAE,IAAI,EAAE,QAAQ,EAAE,EAAE;SACpD,CAAC,CACA,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,GAAG,CAAC,GAAG,KAAK,IAAI,CAAC,EAClD,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CACvB;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { MnWsController } from '../../core/controller.js';
|
|
2
|
+
/** 登录结果视图。 */
|
|
3
|
+
export interface LoginView {
|
|
4
|
+
ok: boolean;
|
|
5
|
+
/** 流程已发起但还没走完(--no-open 只打印地址;面板路径等回调) */
|
|
6
|
+
pending: boolean;
|
|
7
|
+
/** 发起位置:cli / panel */
|
|
8
|
+
via?: 'cli' | 'panel';
|
|
9
|
+
authorizeUrl?: string;
|
|
10
|
+
userId?: string;
|
|
11
|
+
email?: string;
|
|
12
|
+
nickname?: string;
|
|
13
|
+
clientId?: string;
|
|
14
|
+
expiresAt?: number;
|
|
15
|
+
error?: string;
|
|
16
|
+
}
|
|
17
|
+
/** 账号簿视图。 */
|
|
18
|
+
export interface AccountsView {
|
|
19
|
+
accounts: {
|
|
20
|
+
key: string;
|
|
21
|
+
label: string;
|
|
22
|
+
userId?: string;
|
|
23
|
+
email?: string;
|
|
24
|
+
expired: boolean;
|
|
25
|
+
active: boolean;
|
|
26
|
+
}[];
|
|
27
|
+
activeKey: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 登录。
|
|
31
|
+
*
|
|
32
|
+
* 两种发起位置:
|
|
33
|
+
* · **CLI**(transport=cli):自己起一个随机端口的回环监听,弹浏览器,收码,换 token。
|
|
34
|
+
* · **面板**(transport=http):起流程后**立刻返回**(不阻塞 HTTP 请求),
|
|
35
|
+
* 回调落在面板自己的 /callback —— 面板端口是运行时选的,所以回环必须用
|
|
36
|
+
* 面板自己的端口,不能另起一个(另起的端口浏览器回不去)。
|
|
37
|
+
*
|
|
38
|
+
* `--no-open` 只打印授权地址、**不写登录态**(半途而废的登录不该留下空账号)。
|
|
39
|
+
* 完整走完时:设备令牌落进账号簿并激活,面板的登录态同步更新。
|
|
40
|
+
*/
|
|
41
|
+
export declare function login(c: MnWsController, opts: {
|
|
42
|
+
newAccount?: boolean;
|
|
43
|
+
noOpen?: boolean;
|
|
44
|
+
transport?: string;
|
|
45
|
+
}): Promise<LoginView>;
|
|
46
|
+
/** 账号簿。 */
|
|
47
|
+
export declare function listAccountsView(c: MnWsController): AccountsView;
|
|
48
|
+
/** 切换当前生效账号。 */
|
|
49
|
+
export declare function switchAccount(c: MnWsController, target: string): {
|
|
50
|
+
ok: boolean;
|
|
51
|
+
changed: boolean;
|
|
52
|
+
key?: string;
|
|
53
|
+
label?: string;
|
|
54
|
+
error?: string;
|
|
55
|
+
};
|
|
56
|
+
/** 当前身份。 */
|
|
57
|
+
export declare function authStatus(c: MnWsController): {
|
|
58
|
+
loggedIn: boolean;
|
|
59
|
+
userId?: string;
|
|
60
|
+
email?: string;
|
|
61
|
+
nickname?: string;
|
|
62
|
+
clientId: string;
|
|
63
|
+
serverHttp: string;
|
|
64
|
+
expiresAt?: number;
|
|
65
|
+
expired: boolean;
|
|
66
|
+
via: string;
|
|
67
|
+
};
|
|
68
|
+
/** 清除登录凭据。 */
|
|
69
|
+
export declare function logout(c: MnWsController, all: boolean): {
|
|
70
|
+
ok: boolean;
|
|
71
|
+
remaining: number;
|
|
72
|
+
error?: string;
|
|
73
|
+
};
|
|
74
|
+
export declare function renderLogin(r: LoginView): string;
|
|
75
|
+
export declare function renderList(r: AccountsView): string;
|
|
76
|
+
export declare function renderSwitch(r: {
|
|
77
|
+
ok: boolean;
|
|
78
|
+
changed: boolean;
|
|
79
|
+
key?: string;
|
|
80
|
+
label?: string;
|
|
81
|
+
error?: string;
|
|
82
|
+
}): string;
|
|
83
|
+
export declare function renderStatus(r: {
|
|
84
|
+
loggedIn: boolean;
|
|
85
|
+
userId?: string;
|
|
86
|
+
email?: string;
|
|
87
|
+
nickname?: string;
|
|
88
|
+
clientId: string;
|
|
89
|
+
serverHttp: string;
|
|
90
|
+
expired: boolean;
|
|
91
|
+
via: string;
|
|
92
|
+
}): string;
|
|
93
|
+
export declare function renderLogout(r: {
|
|
94
|
+
ok: boolean;
|
|
95
|
+
remaining: number;
|
|
96
|
+
error?: string;
|
|
97
|
+
}): string;
|
|
98
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAM/D,cAAc;AACd,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,OAAO,CAAC;IACZ,0CAA0C;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,uBAAuB;IACvB,GAAG,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,aAAa;AACb,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IAC/G,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,KAAK,CACz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,wBAAgB,YAAY,CAAC,CAAC,EAAE;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAGvH;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IACtE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;CACrE,GAAG,MAAM,CAYT;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAG1F"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { authLogin } from '../../core/auth.js';
|
|
2
|
+
import { clearAuthCredentials, labelOf, listAccounts, readConfigFile, saveAuthAccount, switchActiveAccount, withAccounts, isExpired, } from '../../core/config.js';
|
|
3
|
+
/**
|
|
4
|
+
* 登录。
|
|
5
|
+
*
|
|
6
|
+
* 两种发起位置:
|
|
7
|
+
* · **CLI**(transport=cli):自己起一个随机端口的回环监听,弹浏览器,收码,换 token。
|
|
8
|
+
* · **面板**(transport=http):起流程后**立刻返回**(不阻塞 HTTP 请求),
|
|
9
|
+
* 回调落在面板自己的 /callback —— 面板端口是运行时选的,所以回环必须用
|
|
10
|
+
* 面板自己的端口,不能另起一个(另起的端口浏览器回不去)。
|
|
11
|
+
*
|
|
12
|
+
* `--no-open` 只打印授权地址、**不写登录态**(半途而废的登录不该留下空账号)。
|
|
13
|
+
* 完整走完时:设备令牌落进账号簿并激活,面板的登录态同步更新。
|
|
14
|
+
*/
|
|
15
|
+
export async function login(c, opts) {
|
|
16
|
+
const cfg = c.cfg;
|
|
17
|
+
// ── 面板路径:起流程就返回,等浏览器回调到面板的 /callback ──
|
|
18
|
+
if (opts.transport === 'http') {
|
|
19
|
+
try {
|
|
20
|
+
const { authorizeUrl } = await c.session.startLogin(c.panelPort);
|
|
21
|
+
return { ok: false, pending: true, authorizeUrl, via: 'panel' };
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
return { ok: false, pending: false, error: e.message };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const res = await authLogin({
|
|
29
|
+
serverHttp: cfg.serverHttp,
|
|
30
|
+
clientId: cfg.clientId,
|
|
31
|
+
deviceName: cfg.deviceName,
|
|
32
|
+
noOpen: opts.noOpen === true,
|
|
33
|
+
promptLogin: opts.newAccount === true,
|
|
34
|
+
});
|
|
35
|
+
if (res.pending) {
|
|
36
|
+
// 只打印地址:不碰账号簿,不碰面板登录态
|
|
37
|
+
return { ok: false, pending: true, authorizeUrl: res.authorizeUrl, via: 'cli' };
|
|
38
|
+
}
|
|
39
|
+
const entry = {
|
|
40
|
+
userId: res.userId,
|
|
41
|
+
email: res.email,
|
|
42
|
+
username: res.username,
|
|
43
|
+
nickname: res.nickname,
|
|
44
|
+
deviceToken: res.token,
|
|
45
|
+
expiresAt: res.tokenExpiresAt,
|
|
46
|
+
deviceName: res.deviceName || cfg.deviceName,
|
|
47
|
+
clientId: res.clientId || cfg.clientId,
|
|
48
|
+
url: cfg.url,
|
|
49
|
+
serverHttp: cfg.serverHttp,
|
|
50
|
+
loginAt: Date.now(),
|
|
51
|
+
};
|
|
52
|
+
saveAuthAccount({ entry, setActive: true });
|
|
53
|
+
// 面板的登录态跟着更新(它读的是同一份账号簿)
|
|
54
|
+
c.session.adoptFromAccountStore();
|
|
55
|
+
return {
|
|
56
|
+
ok: true,
|
|
57
|
+
pending: false,
|
|
58
|
+
userId: res.userId,
|
|
59
|
+
email: res.email,
|
|
60
|
+
nickname: res.nickname,
|
|
61
|
+
clientId: res.clientId,
|
|
62
|
+
expiresAt: res.tokenExpiresAt,
|
|
63
|
+
via: 'cli',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
return { ok: false, pending: false, error: e.message };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** 账号簿。 */
|
|
71
|
+
export function listAccountsView(c) {
|
|
72
|
+
const view = withAccounts(readConfigRaw(c));
|
|
73
|
+
return {
|
|
74
|
+
activeKey: view.activeAccountKey,
|
|
75
|
+
accounts: listAccounts(view).map(({ key, entry }) => ({
|
|
76
|
+
key,
|
|
77
|
+
label: labelOf(entry),
|
|
78
|
+
userId: entry.userId,
|
|
79
|
+
email: entry.email,
|
|
80
|
+
expired: isExpired(entry),
|
|
81
|
+
active: key === view.activeAccountKey,
|
|
82
|
+
})),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** 切换当前生效账号。 */
|
|
86
|
+
export function switchAccount(c, target) {
|
|
87
|
+
try {
|
|
88
|
+
const r = switchActiveAccount(target, { defaultClientId: c.cfg.clientId });
|
|
89
|
+
if (!r.changed && !r.key) {
|
|
90
|
+
return { ok: false, changed: false, error: '需要指定账号(序号 / 邮箱 / 用户名 / 昵称)' };
|
|
91
|
+
}
|
|
92
|
+
c.cfg.token = r.entry.deviceToken || '';
|
|
93
|
+
c.cfg.clientId = r.entry.clientId || c.cfg.clientId;
|
|
94
|
+
c.cfg.url = r.entry.url || c.cfg.url;
|
|
95
|
+
c.cfg.serverHttp = r.entry.serverHttp || c.cfg.serverHttp;
|
|
96
|
+
c.session.adoptFromAccountStore();
|
|
97
|
+
return { ok: true, changed: r.changed, key: r.key, label: labelOf(r.entry) };
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
return { ok: false, changed: false, error: e.message };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** 当前身份。 */
|
|
104
|
+
export function authStatus(c) {
|
|
105
|
+
const sess = c.session.snapshot();
|
|
106
|
+
const view = withAccounts(readConfigRaw(c));
|
|
107
|
+
const active = view.activeAccountKey ? view.accounts[view.activeAccountKey] : undefined;
|
|
108
|
+
return {
|
|
109
|
+
loggedIn: sess.loggedIn,
|
|
110
|
+
userId: sess.userId,
|
|
111
|
+
email: sess.email,
|
|
112
|
+
nickname: sess.nickname,
|
|
113
|
+
clientId: c.cfg.clientId,
|
|
114
|
+
serverHttp: c.cfg.serverHttp,
|
|
115
|
+
expiresAt: active?.expiresAt,
|
|
116
|
+
expired: isExpired(active),
|
|
117
|
+
via: sess.via,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/** 清除登录凭据。 */
|
|
121
|
+
export function logout(c, all) {
|
|
122
|
+
try {
|
|
123
|
+
const r = clearAuthCredentials({ all });
|
|
124
|
+
c.cfg.token = '';
|
|
125
|
+
c.session.reset();
|
|
126
|
+
return { ok: true, remaining: r.remaining };
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
return { ok: false, remaining: 0, error: e.message };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// ---- 渲染 ----
|
|
133
|
+
export function renderLogin(r) {
|
|
134
|
+
if (r.pending) {
|
|
135
|
+
if (r.via === 'panel') {
|
|
136
|
+
return [
|
|
137
|
+
'已发起登录,浏览器会打开授权页;在那里完成授权后会跳回本面板。',
|
|
138
|
+
r.authorizeUrl ? ` ${r.authorizeUrl}` : '',
|
|
139
|
+
].filter(Boolean).join('\n');
|
|
140
|
+
}
|
|
141
|
+
return [
|
|
142
|
+
'已打印授权地址,未继续登录(--no-open 只做这一步)',
|
|
143
|
+
` ${r.authorizeUrl || ''}`,
|
|
144
|
+
'在浏览器里完成授权后,再执行 mn-ws auth login(不带 --no-open)换回设备令牌',
|
|
145
|
+
].join('\n');
|
|
146
|
+
}
|
|
147
|
+
if (!r.ok)
|
|
148
|
+
return `登录失败:${r.error || '未知原因'}`;
|
|
149
|
+
const days = r.expiresAt ? Math.round((r.expiresAt - Date.now()) / 86400000) : null;
|
|
150
|
+
return [
|
|
151
|
+
`✓ 登录成功:${r.nickname || r.email || r.userId || ''}`,
|
|
152
|
+
r.email ? ` 邮箱 ${r.email}` : '',
|
|
153
|
+
` 本机标识 ${r.clientId || ''}`,
|
|
154
|
+
days !== null ? ` 设备令牌有效期约 ${days} 天` : '',
|
|
155
|
+
].filter(Boolean).join('\n');
|
|
156
|
+
}
|
|
157
|
+
export function renderList(r) {
|
|
158
|
+
if (!r.accounts.length)
|
|
159
|
+
return '本机还没有已存账号:先执行 mn-ws auth login';
|
|
160
|
+
const lines = [`本机已存 ${r.accounts.length} 个账号`];
|
|
161
|
+
for (const a of r.accounts) {
|
|
162
|
+
const mark = a.active ? '(当前)' : '';
|
|
163
|
+
const exp = a.expired ? ' · 已过期' : '';
|
|
164
|
+
lines.push(` ${a.key.padEnd(24)} ${a.label}${mark}${exp}`);
|
|
165
|
+
}
|
|
166
|
+
lines.push('切换:mn-ws auth switch <序号或账号>');
|
|
167
|
+
return lines.join('\n');
|
|
168
|
+
}
|
|
169
|
+
export function renderSwitch(r) {
|
|
170
|
+
if (!r.ok)
|
|
171
|
+
return `切换失败:${r.error || ''}`;
|
|
172
|
+
return r.changed ? `已切换到:${r.label || r.key}` : '当前账号没变';
|
|
173
|
+
}
|
|
174
|
+
export function renderStatus(r) {
|
|
175
|
+
const lines = ['当前身份'];
|
|
176
|
+
if (r.loggedIn) {
|
|
177
|
+
lines.push(` ${r.nickname || r.email || r.userId || '已登录'}(${r.via === 'cli' ? '复用 CLI 登录态' : '面板登录'})`);
|
|
178
|
+
if (r.email)
|
|
179
|
+
lines.push(` 邮箱 ${r.email}`);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
lines.push(' 未登录:用静态门禁 token');
|
|
183
|
+
}
|
|
184
|
+
lines.push(` 本机标识 ${r.clientId}`);
|
|
185
|
+
lines.push(` server ${r.serverHttp}`);
|
|
186
|
+
if (r.expired)
|
|
187
|
+
lines.push(' ! 账号的设备令牌已过期:重新执行 mn-ws auth login');
|
|
188
|
+
return lines.join('\n');
|
|
189
|
+
}
|
|
190
|
+
export function renderLogout(r) {
|
|
191
|
+
if (!r.ok)
|
|
192
|
+
return `清除失败:${r.error || ''}`;
|
|
193
|
+
return r.remaining ? `已清除当前账号的登录凭据(还剩 ${r.remaining} 个账号)` : '已清空本机登录凭据';
|
|
194
|
+
}
|
|
195
|
+
// ---- 小工具 ----
|
|
196
|
+
function readConfigRaw(c) {
|
|
197
|
+
// 直接读配置文件(账号簿的唯一来源),不走 loadClientConfig —— 那个会补默认值
|
|
198
|
+
return readConfigFile();
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/modules/auth/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EACL,oBAAoB,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,eAAe,EAC5E,mBAAmB,EAAE,YAAY,EAAE,SAAS,GAE7C,MAAM,sBAAsB,CAAC;AAuB9B;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,CAAiB,EACjB,IAAoE;IAEpE,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;IAElB,yCAAyC;IACzC,IAAI,IAAI,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;QAC9B,IAAI,CAAC;YACH,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACjE,OAAO,EAAE,EAAE,EAAE,KAAK,E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AG,CAAC,CAAC;QAC1G,IAAI,CAAC,CAAC,KAAK;YAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IAChD,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAClC,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1C,IAAI,CAAC,CAAC,OAAO;QAAE,KAAK,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IAClE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,CAAqD;IAChF,IAAI,CAAC,CAAC,CAAC,EAAE;QAAE,OAAO,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;IAC1C,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC;AAC3E,CAAC;AAED,gBAAgB;AAEhB,SAAS,aAAa,CAAC,CAAiB;IACtC,mDAAmD;IACnD,OAAO,cAAc,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type BridgeStatusView, type BridgeAppsView, type CatalogView } from './service.js';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
readonly id: "bridge";
|
|
4
|
+
readonly title: "桥接";
|
|
5
|
+
readonly order: 2;
|
|
6
|
+
readonly actions: readonly [import("../../runtime/types/action.js").TypedAction<{
|
|
7
|
+
readonly id: "bridge.status";
|
|
8
|
+
readonly cli: readonly ["status"];
|
|
9
|
+
readonly http: readonly ["GET", "/api/bridge/status"];
|
|
10
|
+
readonly summary: "桥接状态:连没连、注册了哪些 app、当前凭据是谁";
|
|
11
|
+
}, BridgeStatusView>, import("../../runtime/types/action.js").TypedAction<{
|
|
12
|
+
readonly id: "bridge.apps";
|
|
13
|
+
readonly cli: readonly ["apps"];
|
|
14
|
+
readonly http: readonly ["GET", "/api/bridge/apps"];
|
|
15
|
+
readonly summary: "列出可桥接的应用:白名单 + 本地端口存活探测";
|
|
16
|
+
}, BridgeAppsView>, import("../../runtime/types/action.js").TypedAction<{
|
|
17
|
+
readonly id: "bridge.whitelist.set";
|
|
18
|
+
readonly cli: readonly ["apps", "set"];
|
|
19
|
+
readonly http: readonly ["POST", "/api/bridge/whitelist"];
|
|
20
|
+
readonly summary: "设置白名单(只有列出的应用会被桥;不给就一个都不桥)";
|
|
21
|
+
readonly flags: {
|
|
22
|
+
readonly apps: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly hint: "逗号分隔的应用名,如 nx-kv,nx-rh";
|
|
25
|
+
};
|
|
26
|
+
readonly ports: {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
readonly hint: "逗号分隔的本地端口(从已知表反查应用名)";
|
|
29
|
+
};
|
|
30
|
+
readonly 'app-map': {
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
readonly hint: "显式基址,如 nx-kv=http://127.0.0.1:7999";
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
}, {
|
|
36
|
+
ok: boolean;
|
|
37
|
+
apps: string[];
|
|
38
|
+
applied: boolean;
|
|
39
|
+
}>, import("../../runtime/types/action.js").TypedAction<{
|
|
40
|
+
readonly id: "bridge.catalog";
|
|
41
|
+
readonly cli: readonly ["catalog"];
|
|
42
|
+
readonly http: readonly ["GET", "/api/bridge/catalog"];
|
|
43
|
+
readonly summary: "拉远端 server 半的元信息目录(哪些能路由)";
|
|
44
|
+
}, CatalogView>, import("../../runtime/types/action.js").TypedAction<{
|
|
45
|
+
readonly id: "bridge.start";
|
|
46
|
+
readonly cli: readonly ["bridge", "start"];
|
|
47
|
+
readonly http: readonly ["POST", "/api/bridge/start"];
|
|
48
|
+
readonly summary: "起桥(连 server 半并注册白名单里的应用)";
|
|
49
|
+
}, {
|
|
50
|
+
started: boolean;
|
|
51
|
+
apps: string[];
|
|
52
|
+
reason?: string;
|
|
53
|
+
}>, import("../../runtime/types/action.js").TypedAction<{
|
|
54
|
+
readonly id: "bridge.stop";
|
|
55
|
+
readonly cli: readonly ["bridge", "stop"];
|
|
56
|
+
readonly http: readonly ["POST", "/api/bridge/stop"];
|
|
57
|
+
readonly summary: "停桥(断开 server 半,本机 nx 服务不受影响)";
|
|
58
|
+
}, {
|
|
59
|
+
stopped: boolean;
|
|
60
|
+
reason?: string;
|
|
61
|
+
}>, import("../../runtime/types/action.js").TypedAction<{
|
|
62
|
+
readonly id: "bridge.known";
|
|
63
|
+
readonly cli: readonly ["apps", "known"];
|
|
64
|
+
readonly http: readonly ["GET", "/api/bridge/known"];
|
|
65
|
+
readonly summary: "列出已知的 nx 服务与它们的默认端口";
|
|
66
|
+
}, {
|
|
67
|
+
app: string;
|
|
68
|
+
port: number;
|
|
69
|
+
title: string;
|
|
70
|
+
}[]>];
|
|
71
|
+
};
|
|
72
|
+
export default _default;
|
|
73
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/bridge/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAGL,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAC7D,MAAM,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtB,wBAgGG"}
|