Add Seal-native enterprise support
This commit is contained in:
1 parent
2611ce4c85
commit
997ece006a
10 files changed
+176
-9
No files matched your search
@@ -57,4 +57,25 @@ describe("CorpConfigSchema", () => {
|
||||
}
|
||||
expect(config.source.expiresIn).toBe(3600);
|
||||
});
|
||||
|
||||
test("accepts native Seal bearer source", () => {
|
||||
const config = CorpConfigSchema.parse({
|
||||
id: "xiezihao",
|
||||
name: "谢子豪的测试环境",
|
||||
source: {
|
||||
type: "seal",
|
||||
token: "seal-token",
|
||||
sealUrl: "https://xiezihao.staging.sealai.cc",
|
||||
tenantSlug: "xiezihao",
|
||||
tenantId: "tenant-id"
|
||||
}
|
||||
});
|
||||
|
||||
expect(config.source.type).toBe("seal");
|
||||
if (config.source.type !== "seal") {
|
||||
throw new Error("expected seal source");
|
||||
}
|
||||
expect(config.source.staffId).toBe("seal");
|
||||
expect(config.source.tenantSlug).toBe("xiezihao");
|
||||
});
|
||||
});
|
||||
@@ -37,9 +37,23 @@ export const DirectSealSourceSchema = z.object({
|
||||
corpId: z.string().optional()
|
||||
});
|
||||
|
||||
export const NativeSealSourceSchema = z.object({
|
||||
type: z.literal("seal"),
|
||||
token: z.string(),
|
||||
sealUrl: z.string().url(),
|
||||
expiresIn: z.number().int().positive().default(3600),
|
||||
staffId: z.string().default("seal"),
|
||||
corpId: z.string().optional(),
|
||||
tenantId: z.string().optional(),
|
||||
tenantSlug: z.string().optional(),
|
||||
tenantName: z.string().optional(),
|
||||
providerUserId: z.string().optional()
|
||||
});
|
||||
|
||||
export const SealSourceSchema = z.discriminatedUnion("type", [
|
||||
HoseSealSourceSchema,
|
||||
DirectSealSourceSchema
|
||||
DirectSealSourceSchema,
|
||||
NativeSealSourceSchema
|
||||
]);
|
||||
|
||||
export const SealEndpointSchema = z.object({
|
||||
@@ -70,6 +84,7 @@ export const CorpConfigSchema = z.object({
|
||||
|
||||
export type HoseSealSource = z.infer<typeof HoseSealSourceSchema>;
|
||||
export type DirectSealSource = z.infer<typeof DirectSealSourceSchema>;
|
||||
export type NativeSealSource = z.infer<typeof NativeSealSourceSchema>;
|
||||
export type SealSource = z.infer<typeof SealSourceSchema>;
|
||||
export type CorpAuthConfig = z.infer<typeof CorpAuthConfigSchema>;
|
||||
export type CorpConfig = z.infer<typeof CorpConfigSchema>;
|
||||
Reference in new issue
Block a user