Remove legacy direct enterprise source

This commit is contained in:
gitea committed 2026-09-22 14:06:13 +08:00
1 parent 01ef5b37cb
commit 2e941f0842
29 files changed
+117 -132

No files matched your search

+1
View File
@@ -193,6 +193,7 @@ describe("corps link onboarding", () => {
expect(config.source.provider).toBe("hosecloud");
expect(config.source.token).toBe("seal-bearer-token");
expect(config.source.expiresIn).toBe(1800);
expect(config.source.expiresAt).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/);
});
test("rejects --elevate-hose when passed with a Seal native delegate link", async () => {
+10 -11
View File
@@ -101,20 +101,12 @@ function formatSafeSourceDetail(source: SealSource) {
sealUrl: source.sealUrl,
hasToken: Boolean(source.token),
tokenMasked: maskSecret(source.token),
expiresIn: source.expiresIn
expiresIn: source.expiresIn,
expiresAt: source.expiresAt
};
}
return {
type: "direct",
provider: "direct",
staffId: source.staffId,
corpId: source.corpId,
sealUrl: source.sealUrl,
hasToken: Boolean(source.token),
tokenMasked: maskSecret(source.token),
expiresIn: source.expiresIn
};
throw new Error(`Unsupported enterprise source type: ${(source as { type: string }).type}`);
}
export async function handleCorpsCommand(action: string | undefined, maybeName: string | undefined, args: ParsedArgs) {
@@ -1960,12 +1952,14 @@ function writeSealCorpConfig(
token: string;
sealUrl: string;
expiresIn: number;
expiresAt?: string;
verify: boolean;
remote?: RemoteSealIdentity;
custom?: { headers?: Record<string, string>; cookies?: Record<string, string> };
}
) {
const { token, sealUrl, expiresIn, verify, remote } = auth;
const expiresAt = auth.expiresAt ?? formatUtcTimestampSeconds(Date.now() + expiresIn * 1000);
const custom = auth.custom ?? sealCustomHeadersFromInput(input);
const remoteUser = remote?.user;
const remoteTenant = remote?.tenant;
@@ -2004,6 +1998,7 @@ function writeSealCorpConfig(
token,
sealUrl,
expiresIn,
expiresAt,
staffId,
corpId,
tenantId,
@@ -2035,6 +2030,10 @@ function writeSealCorpConfig(
});
}
function formatUtcTimestampSeconds(timestampMs: number): string {
return new Date(timestampMs).toISOString().replace(/\.\d{3}Z$/, "Z");
}
async function resolveHoseCorporation(domain: string, appKey: string, appSecurity: string) {
const response = await fetch(`${domain.replace(/\/+$/, "")}/api/openapi/v1/auth/getAccessToken`, {
method: "POST",
@@ -49,7 +49,7 @@ function setupMockEnv() {
name: "测试资源包企业",
environment: "test",
source: {
type: "direct",
type: "seal",
token: "mock-valid-token",
sealUrl: "https://test-pack.sealai.cc"
},
@@ -115,7 +115,7 @@ describe("Webhook Resource Pack CLI Commands", () => {
id: "test-corp-pack",
name: "测试企业",
source: {
type: "direct",
type: "seal",
token: "mock-valid-token",
sealUrl: "https://test-pack.sealai.cc",
expiresIn: 3600,