feat(auth): 实现全自动无感续杯 (401/即将过期自动重试换票) 与企业多身份唯一标识分层
This commit is contained in:
1 parent
189415cdac
commit
b7a3bf2c03
7 files changed
+122
-17
No files matched your search
@@ -26,9 +26,18 @@ export function resolveCorpConfig(
|
||||
const selectedCorpId = requestedCorpId ?? configuredCorpId;
|
||||
|
||||
if (selectedCorpId) {
|
||||
const corp = corps.find((item) => item.id === selectedCorpId);
|
||||
// 1. 优先按身份/配置 ID 精确匹配 (如 uzU7pcWfScck00@17718556446)
|
||||
let corp = corps.find((item) => item.id === selectedCorpId);
|
||||
// 2. 其次按企业物理 ID 匹配 (如 uzU7pcWfScck00)
|
||||
if (!corp) {
|
||||
corp = corps.find(
|
||||
(item) =>
|
||||
item.corpId === selectedCorpId ||
|
||||
item.credentials.corpId === selectedCorpId
|
||||
);
|
||||
}
|
||||
if (corp) return corp;
|
||||
throw new Error(`未找到企业 ID 为 ${selectedCorpId} 的企业配置`);
|
||||
throw new Error(`未找到企业或身份标识为 [${selectedCorpId}] 的企业配置`);
|
||||
}
|
||||
|
||||
if (!options.stateful) {
|
||||
|
||||
@@ -16,8 +16,11 @@ export const CorpAuthConfigSchema = z.object({
|
||||
});
|
||||
|
||||
export const CorpConfigSchema = z.object({
|
||||
id: z.string().describe("企业 ID"),
|
||||
id: z.string().describe("配置/身份唯一标识 (默认等于 corpId,同企业多身份时形如 corpId@accountId 或 corpId:staffId)"),
|
||||
name: z.string().describe("企业名称"),
|
||||
corpId: z.string().optional().describe("底层企业物理 ID (未填时默认等于 id)"),
|
||||
userId: z.string().optional().describe("所属用户 ID"),
|
||||
staffId: z.string().optional().describe("员工工号 (默认取 credentials.staffId)"),
|
||||
baseUrl: z.string().url().optional().default("https://app.ekuaibao.com"),
|
||||
source: CredentialSourceSchema.optional().default("manual").describe("凭证来源: account/manual/browser/f12"),
|
||||
accountId: z.string().optional().describe("所属主账号标识(如手机号)"),
|
||||
|
||||
Reference in new issue
Block a user