feat(assist-platform): add assist platform automation and tenant onboarding
- Add SSO QR status poller and assist platform HTTP client - Add assist-platform session store with 0600 secure permissions - Implement domains/assist-platform (api, services, types) for corporation search, detail, tickets, staff query and passwordless token generation - Implement cli/commands/assist-platform with aliases assist-center and ap - Support seamless --save --switch --elevate pipeline to import tenant and extract persistent OpenAPI credentials - Update embedded skill documentation, reference guide, and test suites
This commit is contained in:
1 parent
d839fcbe2b
commit
ed9fa979e0
25 files changed
+1811
-2
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import ky, { type KyInstance } from "ky";
|
||||
import { AuthenticationError } from "../errors.js";
|
||||
|
||||
export const DEFAULT_ASSIST_PLATFORM_API_URL = "https://unity.ekuaibao.com/api";
|
||||
|
||||
export interface AssistPlatformClientOptions {
|
||||
token: string;
|
||||
baseUrl?: string;
|
||||
hoseAccessToken?: string;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
export function createAssistPlatformClient(options: AssistPlatformClientOptions): KyInstance {
|
||||
if (!options.token || !options.token.trim()) {
|
||||
throw new AuthenticationError("缺少协助平台凭证 Token,请先登录协助平台");
|
||||
}
|
||||
|
||||
const baseUrl = options.baseUrl || DEFAULT_ASSIST_PLATFORM_API_URL;
|
||||
const cookieParts: string[] = [];
|
||||
if (options.hoseAccessToken) {
|
||||
cookieParts.push(`hose-access-token=${options.hoseAccessToken}`);
|
||||
}
|
||||
|
||||
return ky.create({
|
||||
prefix: baseUrl,
|
||||
timeout: options.timeout ?? 30000,
|
||||
headers: {
|
||||
accept: "application/json",
|
||||
"content-type": "application/json;charset=UTF-8",
|
||||
token: options.token.trim(),
|
||||
referer: "https://unity.ekuaibao.com/platform-charge/index.html",
|
||||
...(cookieParts.length > 0 ? { cookie: cookieParts.join("; ") } : {}),
|
||||
},
|
||||
hooks: {
|
||||
afterResponse: [
|
||||
async ({ response }) => {
|
||||
if (response.status === 401 || response.status === 403) {
|
||||
throw new AuthenticationError("协助平台凭证已过期或无效,请重新登录协助平台");
|
||||
}
|
||||
return response;
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user