(knowledgeBaseId: string)
| 131 | * Consumes the return context and shows a toast notification. |
| 132 | */ |
| 133 | export function useOAuthReturnForKBConnectors(knowledgeBaseId: string) { |
| 134 | useEffect(() => { |
| 135 | const ctx = readOAuthReturnContext() |
| 136 | if (!ctx || ctx.origin !== 'kb-connectors') return |
| 137 | if (ctx.knowledgeBaseId !== knowledgeBaseId) return |
| 138 | consumeOAuthReturnContext() |
| 139 | if (Date.now() - ctx.requestedAt > CONTEXT_MAX_AGE_MS) return |
| 140 | |
| 141 | void (async () => { |
| 142 | const message = await resolveOAuthMessage(ctx) |
| 143 | toast.success(message) |
| 144 | dispatchCredentialUpdate(ctx) |
| 145 | })() |
| 146 | }, [knowledgeBaseId]) |
| 147 | } |
no test coverage detected