diff --git a/AGENTS.md b/AGENTS.md index ebd4a2a..ede6683 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -107,7 +107,7 @@ Recent commits use concise imperative subjects, often `Add ...` or `Refine ...`, ## Security & Configuration Tips -Never commit real enterprise credentials, Seal tokens, service logs, or local generated state. Use `enterprises/example.hose.json` or `enterprises/example.direct.json` as templates, then place real configs in `enterprises/local.json` or `~/.config/seal-use/enterprises` (with legacy fallback to `~/.config/seal-home/enterprises`). For auth or tenant changes, verify with `bun run probe` or `seal-use auth diagnose`. +Never commit real enterprise credentials, Seal tokens, service logs, or local generated state. Use `enterprises/example.hose.json` or `enterprises/example.seal.json` as templates, then place real configs in `enterprises/local.json` or `~/.config/seal-use/enterprises` (with legacy fallback to `~/.config/seal-home/enterprises`). For auth or tenant changes, verify with `bun run probe` or `seal-use auth diagnose`. Credential files are written `0600`; a config placed by hand keeps the `0o644` default, so run `seal-use doctor` and act on its `credential_permissions` check before sharing a machine or a backup. See `SECURITY.md` for the trust model (local HTTP adapter, self-update, custom linters). diff --git a/README.md b/README.md index eea650d..2977138 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Bun + TypeScript CLI and optional local service for pulling Seal enterprise appr The first provider is Hose/合思: `key`, `password`, `corpId`, `staffId`, and an optional Hose domain. The provider exchanges those credentials for a Seal enterprise session, then the Seal domain tools can read and maintain approval rules, approval documents, and approval style preferences. -Seal-native enterprise pages can be added with a Seal Bearer token. The older `direct` source remains available for existing configs that already provide a Seal Bearer token. +Seal-native enterprise pages can be added with a Seal Bearer token. An incoming Hose/合思 `thirdparty.html` assistance link can be imported directly; the CLI exchanges its temporary token through Seal SSO, verifies the tenant, and stores a short-lived local Seal session. @@ -46,7 +46,7 @@ seal-use update # Future self-update directly from GitHub Release For local development from source with Bun: -For an already-authenticated Seal-native source, use `seal-use corps add-seal-bearer` or copy `enterprises/example.seal.json`. Existing `direct` configs remain supported via `enterprises/example.direct.json`. +For an already-authenticated Seal-native source, use `seal-use corps add-seal-bearer` or copy `enterprises/example.seal.json`. ## Public Usage @@ -95,6 +95,8 @@ seal-use auth diagnose --corp tenant `corps add-seal-bearer` verifies `/api/v1/auth/me` by default and writes the tenant slug, tenant ID, tenant name, and provider user ID into local config metadata. Pass `"force":true` or `"verify":false` only when writing an offline config intentionally. The old `add-seal` spelling remains a compatibility alias. +短期 Seal 配置会同时记录 `expiresIn`(秒数 TTL)和 `expiresAt`(UTC 秒精度,例如 `2026-09-22T05:30:00Z`);Hose 持久化配置则以 `source.type: "hose"` 和 `appKey/appSecurity` 表示,不写入这两个会话过期字段。 + When the Agent receives a cURL copied from an authenticated Hose page, it first attempts to extract durable OpenAPI credentials. If that is not possible, it can import the normalized Hose web session and exchange it for a temporary Seal session: ```bash diff --git a/dist/openapi.json b/dist/openapi.json index c0049fd..fa3051a 100644 --- a/dist/openapi.json +++ b/dist/openapi.json @@ -77,7 +77,6 @@ "type": "string", "enum": [ "hose", - "direct", "seal" ] }, @@ -126,7 +125,6 @@ "type": "string", "enum": [ "hose", - "direct", "seal" ] }, @@ -2970,7 +2968,6 @@ "type": "string", "enum": [ "hose", - "direct", "seal" ] }, diff --git a/enterprises/example.direct.json b/enterprises/example.direct.json deleted file mode 100644 index e33ff3f..0000000 --- a/enterprises/example.direct.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "id": "direct-corp", - "name": "Direct Seal 企业", - "seal": { - "url": "https://corp-id.sealai.cc", - "endpoints": { - "approvalStylePreferences": "api/v1/agent/ai-approval/config" - } - }, - "source": { - "type": "direct", - "token": "seal-bearer-token", - "sealUrl": "https://corp-id.sealai.cc", - "expiresIn": 3600, - "corpId": "corp-id", - "staffId": "staff-id" - }, - "auth": { - "refreshTtl": 300 - } -} diff --git a/enterprises/example.seal.json b/enterprises/example.seal.json index ed496f7..ea30e38 100644 --- a/enterprises/example.seal.json +++ b/enterprises/example.seal.json @@ -13,6 +13,7 @@ "token": "seal-bearer-token", "sealUrl": "https://tenant.sealai.cc", "expiresIn": 2592000, + "expiresAt": "2026-10-22T00:00:00Z", "staffId": "seal-user-id", "corpId": "tenant-slug", "tenantId": "seal-tenant-id", diff --git a/openapi/components/schemas/index.yaml b/openapi/components/schemas/index.yaml index 3eb68b3..4296c5b 100644 --- a/openapi/components/schemas/index.yaml +++ b/openapi/components/schemas/index.yaml @@ -18,7 +18,7 @@ CorpSummary: type: string sourceType: type: string - enum: [hose, direct, seal] + enum: [hose, seal] current: type: boolean SwitchCorpRequest: diff --git a/skills/seal-use/SKILL.md b/skills/seal-use/SKILL.md index 9b73959..913f85f 100644 --- a/skills/seal-use/SKILL.md +++ b/skills/seal-use/SKILL.md @@ -28,6 +28,8 @@ metadata: **Token 类型不得混用**:`add-seal-bearer` 只接受 Seal Bearer Token;合思网页 cURL 中的 `accesstoken` 只能用于 Hose API 和密钥提取,提取失败后由 `add-hose-web-session` 经 SSO 换成 Seal Bearer,不能直接作为 `add-seal-bearer` 的 `token`。 +**配置类型判断**:`source.type: "hose"` 且存在 `appKey/appSecurity` 表示 Hose 持久化凭据;`source.type: "seal"` 且存在 `token` 表示 Seal 会话凭据。短期配置同时记录 `expiresIn`(秒数)和 `expiresAt`(UTC 秒精度,如 `2026-09-22T05:30:00Z`);不要把 Hose 的 `accessToken` 当作 Seal Bearer Token。 + `add-link` 的默认行为是导入临时会话。只有明确使用 `--elevate-hose` 时,才执行合思提权并提取长期 OpenAPI 凭据;`--as-hose` 仅作为兼容旧参数,不作为 Agent 的默认表达。 --- diff --git a/skills/seal-use/references/cli.md b/skills/seal-use/references/cli.md index bf8089a..d930e4b 100644 --- a/skills/seal-use/references/cli.md +++ b/skills/seal-use/references/cli.md @@ -216,6 +216,8 @@ Use the command groups in this order for normal work: **enterprise onboarding** - `seal-use corps add-seal-bearer --json '{"sealUrl":"https://tenant.sealai.cc","token":"..."}'` registers a native Seal enterprise directly from a Seal Bearer Token. The old `add-seal` spelling remains a compatibility alias. - `seal-use corps add-hose-web-session --json '{"baseUrl":"https://wx2.ekuaibao.com","corpId":"...","accessToken":"..."}'` imports a normalized Hose web session (for example, parsed from a Hose admin cURL) and exchanges it for a short-lived Seal Bearer session. It does not create or save OpenAPI `appKey/appSecurity` credentials. - `seal-use corps add-hose-persistent --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"..."}'` registers and persists a Hose enterprise from durable OpenAPI credentials. The old `add-hose` spelling remains a compatibility alias. + +Saved session configs contain both `expiresIn` (TTL seconds) and `expiresAt` (UTC without milliseconds, for example `2026-09-22T05:30:00Z`). Durable Hose configs are identified by `source.type: "hose"` plus `appKey/appSecurity` and do not use session expiry fields. - `seal-use corps list [query] [--env ] [--limit ] [--all] [--strict] [--corp ]` (defaults to displaying the top 10 most frequently used enterprises in the last 7 days; sorting is automatic and query results keep relevance order) - `seal-use corps search [--env ] [--strict]` (intelligent soft search by default: case-insensitive, Chinese homophones, front/back nasal vowels, flat/retroflex consonants, initials, typo/missing letter tolerance; pass `--strict` for exact substring match) - `seal-use corps get ` (rich enterprise attributes with sensitive secrets safely redacted) diff --git a/skills/seal-use/references/enterprise-onboarding.md b/skills/seal-use/references/enterprise-onboarding.md index 903d133..40e21dd 100644 --- a/skills/seal-use/references/enterprise-onboarding.md +++ b/skills/seal-use/references/enterprise-onboarding.md @@ -56,6 +56,8 @@ The Hose web-session `accesstoken` and the Seal Bearer Token are different crede - A Hose cURL's `accesstoken` is used first for Hose key extraction. If no permanent OpenAPI key can be extracted, call `add-hose-web-session`; it exchanges the Hose session through Seal SSO and stores the resulting short-lived Seal Bearer session. - Never pass a Hose `accesstoken` directly as the `token` field of `add-seal-bearer`. +The saved config makes the lifecycle visible: durable Hose credentials use `source.type: "hose"` with `appKey/appSecurity` and no session expiry fields; Seal sessions use `source.type: "seal"` with `token`, `expiresIn` (seconds), and `expiresAt` as a UTC second-precision timestamp such as `2026-09-22T05:30:00Z`. + ## Parameter Ownership Ask the user only for information that cannot be discovered safely: diff --git a/src/cli.test.ts b/src/cli.test.ts index a464aab..5c47d41 100644 --- a/src/cli.test.ts +++ b/src/cli.test.ts @@ -235,7 +235,7 @@ function makeConfigEnv(): Record { id: "corp-a", name: "Corp A", source: { - type: "direct", + type: "seal", token: "seal-token", sealUrl: "https://corp-a.seal.test" } diff --git a/src/cli/commands/corps.test.ts b/src/cli/commands/corps.test.ts index 5f8e94e..a410097 100644 --- a/src/cli/commands/corps.test.ts +++ b/src/cli/commands/corps.test.ts @@ -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 () => { diff --git a/src/cli/commands/corps.ts b/src/cli/commands/corps.ts index 0d83e13..527369d 100644 --- a/src/cli/commands/corps.ts +++ b/src/cli/commands/corps.ts @@ -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; cookies?: Record }; } ) { 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", diff --git a/src/cli/commands/webhook-resource-pack.test.ts b/src/cli/commands/webhook-resource-pack.test.ts index e562872..a67fc3b 100644 --- a/src/cli/commands/webhook-resource-pack.test.ts +++ b/src/cli/commands/webhook-resource-pack.test.ts @@ -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, diff --git a/src/core/auth/direct.ts b/src/core/auth/direct.ts deleted file mode 100644 index 2719cc1..0000000 --- a/src/core/auth/direct.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { CorpConfig } from "../config/types.js"; -import { SealSession } from "./types.js"; - -export async function getDirectSealSession(corp: CorpConfig): Promise { - if (corp.source.type !== "direct" && corp.source.type !== "seal") { - throw new Error(`Unsupported Seal source: ${corp.source.type}`); - } - - const sealUrl = corp.seal.url ?? corp.source.sealUrl; - const nativeSource = corp.source.type === "seal" ? corp.source : undefined; - - return { - token: corp.source.token, - expiresAt: Date.now() + corp.source.expiresIn * 1000, - enterprise: { - provider: nativeSource ? "seal" : "direct", - corpId: corp.source.corpId ?? corp.id, - staffId: corp.source.staffId, - sealUrl, - tenantId: nativeSource?.tenantId, - tenantSlug: corp.seal.tenantSlug ?? nativeSource?.tenantSlug, - tenantName: nativeSource?.tenantName, - raw: { - sourceType: corp.source.type - } - } - }; -} diff --git a/src/core/auth/direct.test.ts b/src/core/auth/native.test.ts similarity index 72% rename from src/core/auth/direct.test.ts rename to src/core/auth/native.test.ts index 40a2f74..73e50a3 100644 --- a/src/core/auth/direct.test.ts +++ b/src/core/auth/native.test.ts @@ -1,45 +1,45 @@ import { describe, expect, test } from "bun:test"; import { CorpConfig } from "../config/types.js"; -import { getDirectSealSession } from "./direct.js"; +import { getNativeSealSession } from "./native.js"; -describe("getDirectSealSession", () => { - test("resolves direct source session correctly", async () => { +describe("getNativeSealSession", () => { + test("resolves native Seal source session correctly", async () => { const corp: CorpConfig = { - id: "corp-direct-1", - name: "Direct Corp", + id: "corp-native-1", + name: "Native Seal Corp", environment: "production", seal: { url: "https://seal.example.com", - tenantSlug: "direct-slug", + tenantSlug: "native-slug", endpoints: { approvalStylePreferences: "api/v1/agent/ai-approval/config" } }, source: { - type: "direct", - token: "bearer-token-direct", + type: "seal", + token: "bearer-token-native", sealUrl: "https://seal.example.com", expiresIn: 3600, staffId: "staff-123", - corpId: "corp-direct-1" + corpId: "corp-native-1" }, auth: { refreshTtl: 300 } }; - const session = await getDirectSealSession(corp); - expect(session.token).toBe("bearer-token-direct"); + const session = await getNativeSealSession(corp); + expect(session.token).toBe("bearer-token-native"); expect(session.enterprise).toEqual({ - provider: "direct", - corpId: "corp-direct-1", + provider: "seal", + corpId: "corp-native-1", staffId: "staff-123", sealUrl: "https://seal.example.com", tenantId: undefined, - tenantSlug: "direct-slug", + tenantSlug: "native-slug", tenantName: undefined, raw: { - sourceType: "direct" + sourceType: "seal" } }); expect(session.expiresAt).toBeGreaterThan(Date.now()); @@ -62,6 +62,7 @@ describe("getDirectSealSession", () => { token: "bearer-token-native", sealUrl: "https://tenant.sealai.cc", expiresIn: 7200, + expiresAt: "2026-09-22T05:30:00Z", staffId: "seal-admin", tenantId: "tenant-100", tenantSlug: "tenant-slug", @@ -72,11 +73,12 @@ describe("getDirectSealSession", () => { } }; - const session = await getDirectSealSession(corp); + const session = await getNativeSealSession(corp); expect(session.token).toBe("bearer-token-native"); expect(session.enterprise.provider).toBe("seal"); 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()); }); test("throws error for unsupported source type", async () => { @@ -88,6 +90,6 @@ describe("getDirectSealSession", () => { auth: { refreshTtl: 300 } } as unknown as CorpConfig; - expect(getDirectSealSession(invalidCorp)).rejects.toThrow("Unsupported Seal source"); + expect(getNativeSealSession(invalidCorp)).rejects.toThrow("Unsupported Seal source"); }); }); diff --git a/src/core/auth/native.ts b/src/core/auth/native.ts new file mode 100644 index 0000000..c3d2b8a --- /dev/null +++ b/src/core/auth/native.ts @@ -0,0 +1,30 @@ +import { CorpConfig } from "../config/types.js"; +import { SealSession } from "./types.js"; + +export async function getNativeSealSession(corp: CorpConfig): Promise { + if (corp.source.type !== "seal") { + throw new Error(`Unsupported Seal source: ${corp.source.type}`); + } + + const sealUrl = corp.seal.url ?? corp.source.sealUrl; + const expiresAt = corp.source.expiresAt + ? new Date(corp.source.expiresAt).getTime() + : Date.now() + corp.source.expiresIn * 1000; + + return { + token: corp.source.token, + expiresAt, + enterprise: { + provider: corp.source.provider ?? "seal", + corpId: corp.source.corpId ?? corp.id, + staffId: corp.source.staffId, + sealUrl, + tenantId: corp.source.tenantId, + tenantSlug: corp.seal.tenantSlug ?? corp.source.tenantSlug, + tenantName: corp.source.tenantName, + raw: { + sourceType: corp.source.type + } + } + }; +} diff --git a/src/core/auth/seal.ts b/src/core/auth/seal.ts index 4f7f58c..e1d4a5c 100644 --- a/src/core/auth/seal.ts +++ b/src/core/auth/seal.ts @@ -1,5 +1,5 @@ import { CorpConfig } from "../config/types.js"; -import { getDirectSealSession } from "./direct.js"; +import { getNativeSealSession } from "./native.js"; import { getHoseSealSession } from "./hose.js"; import { clearSealSession, getSealSession, setSealSession } from "./token-store.js"; import { SealEnterpriseConfig, SealSession } from "./types.js"; @@ -14,9 +14,8 @@ async function refreshSealSession(corp: CorpConfig): Promise { switch (corp.source.type) { case "hose": return getHoseSealSession(corp); - case "direct": case "seal": - return getDirectSealSession(corp); + return getNativeSealSession(corp); } } diff --git a/src/core/auth/token-store.test.ts b/src/core/auth/token-store.test.ts index a1b8164..dbd8195 100644 --- a/src/core/auth/token-store.test.ts +++ b/src/core/auth/token-store.test.ts @@ -66,7 +66,7 @@ describe("token-store", () => { token: "test-token-123", expiresAt: Date.now() + 3600_000, enterprise: { - provider: "direct", + provider: "seal", corpId: "corp-1", staffId: "staff-1", sealUrl: "https://seal.example.com" @@ -108,7 +108,7 @@ describe("token-store", () => { token: "legacy-token-456", expiresAt: Date.now() + 3600_000, enterprise: { - provider: "direct", + provider: "seal", corpId: "corp-legacy", staffId: "staff-legacy", sealUrl: "https://seal.example.com" diff --git a/src/core/config/loader.test.ts b/src/core/config/loader.test.ts index 74b8712..e852cad 100644 --- a/src/core/config/loader.test.ts +++ b/src/core/config/loader.test.ts @@ -55,7 +55,7 @@ describe("loadCorpConfigs", () => { id: "direct", name: "Direct", source: { - type: "direct", + type: "seal", token: "seal-token", sealUrl: "https://direct.sealai.cc" } @@ -70,7 +70,7 @@ describe("loadCorpConfigs", () => { id: "direct-use", name: "Direct Use", source: { - type: "direct", + type: "seal", token: "seal-token", sealUrl: "https://direct.sealai.cc" } @@ -233,7 +233,7 @@ function writeCorpConfig(path: string, id: string, name: string) { id, name, source: { - type: "direct", + type: "seal", token: "seal-token", sealUrl: `https://${id}.sealai.cc` } diff --git a/src/core/config/manager.test.ts b/src/core/config/manager.test.ts index 719b2ce..8e1913f 100644 --- a/src/core/config/manager.test.ts +++ b/src/core/config/manager.test.ts @@ -13,7 +13,7 @@ function corp(id: string, name = id): CorpConfig { } }, source: { - type: "direct", + type: "seal", token: `${id}-token`, sealUrl: `https://${id}.seal.test`, expiresIn: 3600, diff --git a/src/core/config/types.test.ts b/src/core/config/types.test.ts index ec0ed11..4244305 100644 --- a/src/core/config/types.test.ts +++ b/src/core/config/types.test.ts @@ -45,22 +45,24 @@ describe("CorpConfigSchema", () => { expect(result.success).toBe(false); }); - test("accepts direct Seal bearer source", () => { + test("accepts Seal Bearer source with expiry metadata", () => { const config = CorpConfigSchema.parse({ - id: "direct", - name: "Direct", + id: "seal", + name: "Seal", source: { - type: "direct", + type: "seal", token: "seal-token", - sealUrl: "https://direct.sealai.cc" + sealUrl: "https://seal.sealai.cc", + expiresAt: "2026-09-22T05:30:00Z" } }); - expect(config.source.type).toBe("direct"); - if (config.source.type !== "direct") { - throw new Error("expected direct source"); + expect(config.source.type).toBe("seal"); + if (config.source.type !== "seal") { + throw new Error("expected seal source"); } expect(config.source.expiresIn).toBe(3600); + expect(config.source.expiresAt).toBe("2026-09-22T05:30:00Z"); }); test("accepts native Seal bearer source", () => { @@ -86,12 +88,12 @@ describe("CorpConfigSchema", () => { test("leaves custom headers and cookies absent by default", () => { const config = CorpConfigSchema.parse({ - id: "direct", - name: "Direct", + id: "seal", + name: "Seal", source: { - type: "direct", + type: "seal", token: "seal-token", - sealUrl: "https://direct.sealai.cc" + sealUrl: "https://seal.sealai.cc" } }); @@ -109,9 +111,9 @@ describe("CorpConfigSchema", () => { environment: "production", testCorpId: "test-corp", source: { - type: "direct", + type: "seal", token: "seal-token", - sealUrl: "https://direct.sealai.cc" + sealUrl: "https://seal.sealai.cc" } }); expect(prodConfig.environment).toBe("production"); @@ -123,9 +125,9 @@ describe("CorpConfigSchema", () => { environment: "test", prodCorpId: "prod-corp", source: { - type: "direct", + type: "seal", token: "seal-token", - sealUrl: "https://direct.sealai.cc" + sealUrl: "https://seal.sealai.cc" } }); expect(testConfig.environment).toBe("test"); @@ -142,7 +144,7 @@ describe("CorpConfigSchema", () => { cookies: { sdp_app_session_20142: "abc" } }, source: { - type: "direct", + type: "seal", token: "seal-token", sealUrl: "https://gated.sealai.cc" } diff --git a/src/core/config/types.ts b/src/core/config/types.ts index 6dc976d..2605e74 100644 --- a/src/core/config/types.ts +++ b/src/core/config/types.ts @@ -28,20 +28,17 @@ export const HoseSealSourceSchema = z.object({ } }); -export const DirectSealSourceSchema = z.object({ - type: z.literal("direct"), - token: z.string(), - sealUrl: z.string().url(), - expiresIn: z.number().int().positive().default(3600), - staffId: z.string().default("direct"), - corpId: z.string().optional() -}); +const UtcSecondTimestampSchema = z.string().regex( + /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/, + "Timestamp must be an ISO 8601 UTC timestamp without milliseconds" +); export const NativeSealSourceSchema = z.object({ type: z.literal("seal"), token: z.string(), sealUrl: z.string().url(), expiresIn: z.number().int().positive().default(3600), + expiresAt: UtcSecondTimestampSchema.optional(), staffId: z.string().default("seal"), corpId: z.string().optional(), tenantId: z.string().optional(), @@ -54,7 +51,6 @@ export const NativeSealSourceSchema = z.object({ export const SealSourceSchema = z.discriminatedUnion("type", [ HoseSealSourceSchema, - DirectSealSourceSchema, NativeSealSourceSchema ]); @@ -137,7 +133,6 @@ export const GlobalConfigSchema = z.object({ export type CorpEnvironment = z.infer; export type HoseSealSource = z.infer; -export type DirectSealSource = z.infer; export type NativeSealSource = z.infer; export type SealSource = z.infer; export type CorpAuthConfig = z.infer; diff --git a/src/core/search/fuzzy.test.ts b/src/core/search/fuzzy.test.ts index aaec9e8..76f9d14 100644 --- a/src/core/search/fuzzy.test.ts +++ b/src/core/search/fuzzy.test.ts @@ -21,7 +21,7 @@ function makeCorp(id: string, name: string, overrides: Partial = {}) } }, source: { - type: "direct", + type: "seal", token: `${id}-token`, sealUrl: `https://${id}.seal.test`, expiresIn: 3600, diff --git a/src/domains/hose/flow.test.ts b/src/domains/hose/flow.test.ts index 23e1414..133fd91 100644 --- a/src/domains/hose/flow.test.ts +++ b/src/domains/hose/flow.test.ts @@ -467,7 +467,7 @@ describe("Hose Flow Domain", () => { name: "Direct Corp", environment: "production", source: { - type: "direct", + type: "seal", token: "tok", sealUrl: "https://test.sealai.cc", expiresIn: 3600, diff --git a/src/domains/seal/approval-runs-export.test.ts b/src/domains/seal/approval-runs-export.test.ts index fb49010..184589e 100644 --- a/src/domains/seal/approval-runs-export.test.ts +++ b/src/domains/seal/approval-runs-export.test.ts @@ -199,7 +199,7 @@ describe("exportApprovalRunsToExcel integration", () => { } }, source: { - type: "direct", + type: "seal", token: "test-token", sealUrl: "https://mock.sealai.cc", expiresIn: 3600, diff --git a/src/domains/seal/insight-export.test.ts b/src/domains/seal/insight-export.test.ts index 87e4088..a7087ba 100644 --- a/src/domains/seal/insight-export.test.ts +++ b/src/domains/seal/insight-export.test.ts @@ -110,7 +110,7 @@ describe("insight-export domain", () => { tenantSlug: "test" }, source: { - type: "direct", + type: "seal", token: "fake-token", sealUrl: "https://seal.example.com" } @@ -170,7 +170,7 @@ describe("insight-export domain", () => { } }, source: { - type: "direct", + type: "seal", token: "mock-token", sealUrl: "https://mock.sealai.cc", expiresIn: 3600, @@ -199,7 +199,7 @@ describe("insight-export domain", () => { } }, source: { - type: "direct", + type: "seal", token: "mock-token", sealUrl: "https://mock.sealai.cc", expiresIn: 3600, diff --git a/src/domains/seal/material-pack/resource-pack-export.test.ts b/src/domains/seal/material-pack/resource-pack-export.test.ts index a5c1cc8..fefdfbe 100644 --- a/src/domains/seal/material-pack/resource-pack-export.test.ts +++ b/src/domains/seal/material-pack/resource-pack-export.test.ts @@ -16,7 +16,7 @@ const mockCorp: CorpConfig = { name: "测试研发企业", environment: "test", source: { - type: "direct", + type: "seal", token: "mock-token", sealUrl: "https://seal.example.com", expiresIn: 3600, diff --git a/src/domains/seal/search.test.ts b/src/domains/seal/search.test.ts index cad0c41..b54e628 100644 --- a/src/domains/seal/search.test.ts +++ b/src/domains/seal/search.test.ts @@ -84,7 +84,7 @@ function fakeCorp(): CorpConfig { } }, source: { - type: "direct", + type: "seal", token: "tok", sealUrl: "https://seal.test", expiresIn: 3600, diff --git a/src/domains/seal/tools.test.ts b/src/domains/seal/tools.test.ts index 5c20d1b..14903b0 100644 --- a/src/domains/seal/tools.test.ts +++ b/src/domains/seal/tools.test.ts @@ -1173,7 +1173,7 @@ function fakeContext(): { corp: CorpConfig } { } }, source: { - type: "direct", + type: "seal", token: "token", sealUrl: "https://seal.test", expiresIn: 3600,