Skip to content

Commit

Permalink
Add HTTPSCRAMAuth to authed fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttrinh authored and diksipav committed Sep 6, 2024
1 parent fd82d48 commit 1be3174
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/ai/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ import type {
RAGRequest,
StreamingMessage,
} from "./types.js";
import { getHTTPSCRAMAuth } from "edgedb/dist/httpScram.js";
import browserCryptoUtils from "edgedb/dist/browserCrypto.js";

export function createAI(client: Client, options: AIOptions) {
return new EdgeDBAI(client, options);
}

const httpSCRAMAuth = getHTTPSCRAMAuth(browserCryptoUtils.default);

export class EdgeDBAI {
/** @internal */
private readonly authenticatedFetch: Promise<AuthenticatedFetch>;
Expand All @@ -46,7 +50,7 @@ export class EdgeDBAI {
await (client as any).pool._getNormalizedConnectConfig()
).connectionParams;

return getAuthenticatedFetch(connectConfig, "ext/ai/");
return getAuthenticatedFetch(connectConfig, httpSCRAMAuth, "ext/ai/");
}

withConfig(options: Partial<AIOptions>) {
Expand Down

0 comments on commit 1be3174

Please sign in to comment.