Remove redundant enterprise provider metadata
Drop source.provider/providerName, cached enterprise.provider, onboarding writes, CLI outputs, and the search index entry; legacy configs and token caches still parse. Add a compatibility test for stripping the old keys.
This commit is contained in:
1 parent
8adae54c54
commit
8d6b65d3d5
22 files changed
+113
-47
No files matched your search
@@ -137,7 +137,6 @@ describe("hose auth helpers", () => {
|
||||
seal: { endpoints: { approvalStylePreferences: "" } },
|
||||
source: {
|
||||
type: "hose",
|
||||
provider: "hosecloud",
|
||||
domain: "https://wx2.ekuaibao.com",
|
||||
closeToken: "hose-close-token",
|
||||
staffId: "corp-web:staff-1",
|
||||
@@ -149,7 +148,7 @@ describe("hose auth helpers", () => {
|
||||
const session = await getHoseSealSession(corp);
|
||||
expect(requestedToken).toBe("hose-close-token");
|
||||
expect(session.token).toBe("seal-runtime-token");
|
||||
expect(session.enterprise.provider).toBe("hose");
|
||||
expect(session.enterprise).not.toHaveProperty("provider");
|
||||
});
|
||||
|
||||
test("HOSE_STANDARD_DOMAINS contains 6 expected public platform domains", () => {
|
||||
|
||||
@@ -495,7 +495,6 @@ export async function getHoseSealSession(corp: CorpConfig): Promise<SealSession>
|
||||
3600;
|
||||
|
||||
const enterprise: SealEnterpriseConfig = {
|
||||
provider: "hose",
|
||||
corpId: corp.source.corpId,
|
||||
staffId: corp.source.staffId,
|
||||
sealUrl: normalizeBaseUrl(sealUrl),
|
||||
|
||||
@@ -31,7 +31,6 @@ describe("getNativeSealSession", () => {
|
||||
const session = await getNativeSealSession(corp);
|
||||
expect(session.token).toBe("bearer-token-native");
|
||||
expect(session.enterprise).toEqual({
|
||||
provider: "seal",
|
||||
corpId: "corp-native-1",
|
||||
staffId: "staff-123",
|
||||
sealUrl: "https://seal.example.com",
|
||||
@@ -75,7 +74,7 @@ describe("getNativeSealSession", () => {
|
||||
|
||||
const session = await getNativeSealSession(corp);
|
||||
expect(session.token).toBe("bearer-token-native");
|
||||
expect(session.enterprise.provider).toBe("seal");
|
||||
expect(session.enterprise).not.toHaveProperty("provider");
|
||||
expect(session.enterprise.tenantId).toBe("tenant-100");
|
||||
expect(session.enterprise.tenantName).toBe("Tenant 100 Name");
|
||||
expect(session.expiresAt).toBe(new Date("2026-09-22T05:30:00Z").getTime());
|
||||
|
||||
@@ -15,7 +15,6 @@ export async function getNativeSealSession(corp: CorpConfig): Promise<SealSessio
|
||||
token: corp.source.token,
|
||||
expiresAt,
|
||||
enterprise: {
|
||||
provider: corp.source.provider ?? "seal",
|
||||
corpId: corp.source.corpId ?? corp.id,
|
||||
staffId: corp.source.staffId,
|
||||
sealUrl,
|
||||
|
||||
@@ -38,8 +38,7 @@ const fixtureCorp: CorpConfig = {
|
||||
corpId: "test-delegate-corp",
|
||||
tenantId: "t-456",
|
||||
tenantSlug: "mytenant",
|
||||
tenantName: "My Tenant",
|
||||
provider: "seal"
|
||||
tenantName: "My Tenant"
|
||||
},
|
||||
auth: { refreshTtl: 300 }
|
||||
};
|
||||
|
||||
@@ -69,7 +69,6 @@ export async function renewNativeSealSession(corp: CorpConfig): Promise<SealSess
|
||||
token: exchanged.token,
|
||||
expiresAt: Date.now() + exchanged.expiresIn * 1000,
|
||||
enterprise: {
|
||||
provider: source.provider ?? "seal",
|
||||
corpId: source.corpId ?? corp.id,
|
||||
staffId: source.staffId,
|
||||
sealUrl,
|
||||
|
||||
@@ -68,7 +68,6 @@ describe("token-store", () => {
|
||||
token: "test-token-123",
|
||||
expiresAt: Date.now() + 3600_000,
|
||||
enterprise: {
|
||||
provider: "seal",
|
||||
corpId: "corp-1",
|
||||
staffId: "staff-1",
|
||||
sealUrl: "https://seal.example.com"
|
||||
@@ -136,7 +135,6 @@ describe("token-store", () => {
|
||||
token: "legacy-token-456",
|
||||
expiresAt: Date.now() + 3600_000,
|
||||
enterprise: {
|
||||
provider: "seal",
|
||||
corpId: "corp-legacy",
|
||||
staffId: "staff-legacy",
|
||||
sealUrl: "https://seal.example.com"
|
||||
|
||||
@@ -7,7 +7,6 @@ export const TokenEntrySchema = z.object({
|
||||
});
|
||||
|
||||
export const SealEnterpriseConfigSchema = z.object({
|
||||
provider: z.string(),
|
||||
corpId: z.string().optional(),
|
||||
staffId: z.string(),
|
||||
sealUrl: z.string().url(),
|
||||
|
||||
@@ -52,7 +52,6 @@ describe("CorpConfigSchema", () => {
|
||||
name: "Hose Web Session",
|
||||
source: {
|
||||
type: "hose",
|
||||
provider: "hosecloud",
|
||||
domain: "https://wx2.ekuaibao.com",
|
||||
closeToken: "hose-close-token",
|
||||
expiresIn: 1800,
|
||||
@@ -71,6 +70,36 @@ describe("CorpConfigSchema", () => {
|
||||
expect(config.source.expiresAt).toBe("2026-09-22T13:30:00+08:00");
|
||||
});
|
||||
|
||||
test("drops legacy provider metadata instead of rejecting the config", () => {
|
||||
const hoseConfig = CorpConfigSchema.parse({
|
||||
id: "legacy-hose",
|
||||
name: "Legacy Hose",
|
||||
source: {
|
||||
type: "hose",
|
||||
provider: "hosecloud",
|
||||
domain: "https://wx2.ekuaibao.com",
|
||||
closeToken: "hose-close-token",
|
||||
corpId: "corp-1",
|
||||
staffId: "corp-1:staff-1"
|
||||
}
|
||||
});
|
||||
expect(hoseConfig.source).not.toHaveProperty("provider");
|
||||
|
||||
const sealConfig = CorpConfigSchema.parse({
|
||||
id: "legacy-seal",
|
||||
name: "Legacy Seal",
|
||||
source: {
|
||||
type: "seal",
|
||||
token: "seal-token",
|
||||
sealUrl: "https://seal.sealai.cc",
|
||||
provider: "feishu",
|
||||
providerName: "飞书"
|
||||
}
|
||||
});
|
||||
expect(sealConfig.source).not.toHaveProperty("provider");
|
||||
expect(sealConfig.source).not.toHaveProperty("providerName");
|
||||
});
|
||||
|
||||
test("accepts Seal Bearer source with expiry metadata and normalizes legacy UTC to +08:00", () => {
|
||||
const config = CorpConfigSchema.parse({
|
||||
id: "seal",
|
||||
|
||||
@@ -8,7 +8,6 @@ const IsoSecondTimestampSchema = z.string().regex(
|
||||
|
||||
export const HoseSealSourceSchema = z.object({
|
||||
type: z.literal("hose"),
|
||||
provider: z.string().optional(),
|
||||
domain: z.string().url().default("https://app.ekuaibao.com"),
|
||||
appKey: z.string().optional(),
|
||||
appSecurity: z.string().optional(),
|
||||
@@ -49,9 +48,7 @@ export const NativeSealSourceSchema = z.object({
|
||||
tenantId: z.string().optional(),
|
||||
tenantSlug: z.string().optional(),
|
||||
tenantName: z.string().optional(),
|
||||
providerUserId: z.string().optional(),
|
||||
provider: z.string().optional(),
|
||||
providerName: z.string().optional()
|
||||
providerUserId: z.string().optional()
|
||||
});
|
||||
|
||||
export const SealSourceSchema = z.discriminatedUnion("type", [
|
||||
|
||||
@@ -22,8 +22,7 @@ function corpSearchFields(corp: CorpConfig): CorpField[] {
|
||||
{ text: corp.testCorpId, weight: 1.0 },
|
||||
{ text: corp.prodCorpId, weight: 1.0 },
|
||||
{ text: corp.environment ?? "production", weight: 0.8 },
|
||||
{ text: corp.source.type, weight: 0.8 },
|
||||
{ text: (corp.source as any).provider, weight: 0.8 }
|
||||
{ text: corp.source.type, weight: 0.8 }
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ function recoveryFixture(sourceType: "hose" | "seal", alwaysUnauthorized = false
|
||||
});
|
||||
setSealSession(id, {
|
||||
token: "stale-token", expiresAt: Date.now() + 3600000,
|
||||
enterprise: { provider: sourceType, staffId: "fixture-staff", sealUrl: "https://fixture.invalid" }
|
||||
enterprise: { staffId: "fixture-staff", sealUrl: "https://fixture.invalid" }
|
||||
});
|
||||
const requests: Array<{ method: string; token: string | null }> = [];
|
||||
let refreshes = 0;
|
||||
|
||||
Reference in new issue
Block a user