Remove legacy key/password aliases and clean up workspace

Drop the Hose key/password compatibility path from the config schema, credential reads, CLI messages, tests, and docs; appKey/appSecurity are now the only accepted fields. Isolate seal-renew tests from the real enterprises directory so renewals never write local config. Remove the tracked pkg/ report spec and local artifacts, and rewrite .gitignore with complete sections.
This commit is contained in:
gitea committed 2026-11-19 16:10:21 +08:00
1 parent 8d6b65d3d5
commit 35f761e8a0
18 files changed
+106 -940

No files matched your search

+2 -2
View File
@@ -274,8 +274,8 @@ function hoseClient(source: HoseSealSource): KyInstance {
async function fetchHoseOpenapiToken(source: HoseSealSource): Promise<TokenEntry> {
const client = hoseClient(source);
const appKey = source.appKey ?? source.key;
const appSecurity = source.appSecurity ?? source.password;
const appKey = source.appKey;
const appSecurity = source.appSecurity;
if (!appKey || !appSecurity) {
throw new Error("Hose source has no OpenAPI credentials; the configured closeToken is only valid for Hose web-session APIs");
+12
View File
@@ -16,8 +16,10 @@ import {
} from "./token-store.js";
const originalFetch = globalThis.fetch;
const ORIGINAL_ENTERPRISES_DIR = process.env.SEAL_USE_ENTERPRISES_DIR;
let tempDir: string;
let storePath: string;
let enterprisesDir: string;
const fixtureCorp: CorpConfig = {
id: "test-delegate-corp",
@@ -47,7 +49,12 @@ describe("seal-renew: 原生 Seal 协助授权长效续期与会话池救险", (
beforeEach(() => {
tempDir = mkdtempSync(join(tmpdir(), "seal-renew-test-"));
storePath = join(tempDir, "tokens.json");
enterprisesDir = join(tempDir, "enterprises");
process.env.SEAL_USE_TOKEN_STORE = storePath;
// renewNativeSealSession writes the renewed token back through
// saveCorpConfig; keep that write inside the sandbox so tests never
// touch the real ~/.config/seal-use/enterprises directory.
process.env.SEAL_USE_ENTERPRISES_DIR = enterprisesDir;
clearSealToken(fixtureCorp.id);
});
@@ -55,6 +62,11 @@ describe("seal-renew: 原生 Seal 协助授权长效续期与会话池救险", (
globalThis.fetch = originalFetch;
clearSealToken(fixtureCorp.id);
delete process.env.SEAL_USE_TOKEN_STORE;
if (ORIGINAL_ENTERPRISES_DIR === undefined) {
delete process.env.SEAL_USE_ENTERPRISES_DIR;
} else {
process.env.SEAL_USE_ENTERPRISES_DIR = ORIGINAL_ENTERPRISES_DIR;
}
rmSync(tempDir, { recursive: true, force: true });
});
+25 -8
View File
@@ -8,10 +8,33 @@ import {
import { isCorpActive } from "./active.js";
describe("CorpConfigSchema", () => {
test("accepts Hose key/password aliases", () => {
test("accepts Hose appKey/appSecurity credentials", () => {
const config = CorpConfigSchema.parse({
id: "corp-local",
name: "Local Corp",
source: {
type: "hose",
domain: "https://app.ekuaibao.com",
appKey: "app-key",
appSecurity: "app-security",
corpId: "ID01",
staffId: "ID01:STAFF01"
}
});
expect(config.source.type).toBe("hose");
if (config.source.type !== "hose") {
throw new Error("expected hose source");
}
expect(config.source.appKey).toBe("app-key");
expect(config.source.appSecurity).toBe("app-security");
expect(config.auth.refreshTtl).toBe(300);
});
test("rejects legacy key/password aliases", () => {
const result = CorpConfigSchema.safeParse({
id: "corp-legacy",
name: "Legacy Corp",
source: {
type: "hose",
domain: "https://app.ekuaibao.com",
@@ -22,13 +45,7 @@ describe("CorpConfigSchema", () => {
}
});
expect(config.source.type).toBe("hose");
if (config.source.type !== "hose") {
throw new Error("expected hose source");
}
expect(config.source.key).toBe("app-key");
expect(config.source.password).toBe("app-security");
expect(config.auth.refreshTtl).toBe(300);
expect(result.success).toBe(false);
});
test("requires a Hose key and secret", () => {
+4 -6
View File
@@ -11,8 +11,6 @@ export const HoseSealSourceSchema = z.object({
domain: z.string().url().default("https://app.ekuaibao.com"),
appKey: z.string().optional(),
appSecurity: z.string().optional(),
key: z.string().optional(),
password: z.string().optional(),
closeToken: z.string().optional(),
expiresIn: z.number().int().positive().optional(),
expiresAt: IsoSecondTimestampSchema.optional(),
@@ -20,19 +18,19 @@ export const HoseSealSourceSchema = z.object({
corpId: z.string(),
sealUrl: z.string().url().optional()
}).superRefine((source, ctx) => {
if (!source.closeToken && !source.appKey && !source.key) {
if (!source.closeToken && !source.appKey) {
ctx.addIssue({
code: "custom",
path: ["appKey"],
message: "Hose source requires appKey/key or closeToken"
message: "Hose source requires appKey or closeToken"
});
}
if (!source.closeToken && !source.appSecurity && !source.password) {
if (!source.closeToken && !source.appSecurity) {
ctx.addIssue({
code: "custom",
path: ["appSecurity"],
message: "Hose source requires appSecurity/password or closeToken"
message: "Hose source requires appSecurity or closeToken"
});
}
});