From 1be31748c40c9055607eaf9bdaa2cba576372d16 Mon Sep 17 00:00:00 2001 From: Scott Trinh Date: Fri, 3 May 2024 12:46:38 -0400 Subject: [PATCH] Add HTTPSCRAMAuth to authed fetch --- packages/ai/src/core.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/ai/src/core.ts b/packages/ai/src/core.ts index cacc41a6c..257d2947a 100644 --- a/packages/ai/src/core.ts +++ b/packages/ai/src/core.ts @@ -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; @@ -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) {