( callbackUrl: string | undefined, )
| 2186 | } |
| 2187 | |
| 2188 | function buildCallbackRouteProof( |
| 2189 | callbackUrl: string | undefined, |
| 2190 | ): Pick<SmokeStep, "callbackRoute" | "callbackRouteFingerprint"> { |
| 2191 | if (!callbackUrl) { |
| 2192 | return {}; |
| 2193 | } |
| 2194 | try { |
| 2195 | const url = new URL(callbackUrl); |
| 2196 | const workspaceId = url.searchParams.get("workspaceId")?.trim(); |
| 2197 | const integrationId = url.searchParams.get("integrationId")?.trim(); |
| 2198 | if (url.pathname !== "/api/integrations/feishu/events" || !workspaceId || !integrationId) { |
| 2199 | return {}; |
| 2200 | } |
| 2201 | const routeKey = `${url.pathname}?workspaceId=${workspaceId}&integrationId=${integrationId}`; |
| 2202 | return { |
| 2203 | callbackRoute: url.pathname, |
| 2204 | callbackRouteFingerprint: `sha256:${createHash("sha256").update(routeKey, "utf8").digest("hex").slice(0, 16)}`, |
| 2205 | }; |
| 2206 | } catch { |
| 2207 | return {}; |
| 2208 | } |
| 2209 | } |
| 2210 | |
| 2211 | function hasValidCallbackRouteProof(step: unknown): boolean { |
| 2212 | if (!step || typeof step !== "object") { |
no test coverage detected