mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 21:03:42 +00:00
Use dynamic import for http module in OAuth files
Prevents browser bundles from failing on import. The http module is only loaded when login functions are actually called.
This commit is contained in:
parent
481bc79f83
commit
3bf168615a
2 changed files with 14 additions and 4 deletions
|
|
@ -6,7 +6,7 @@
|
|||
* It is only intended for CLI use, not browser environments.
|
||||
*/
|
||||
|
||||
import { createServer, type Server } from "http";
|
||||
import type { Server } from "http";
|
||||
import { generatePKCE } from "./pkce.js";
|
||||
import type { OAuthCredentials } from "./types.js";
|
||||
|
||||
|
|
@ -36,7 +36,12 @@ const DEFAULT_PROJECT_ID = "rising-fact-p41fc";
|
|||
/**
|
||||
* Start a local HTTP server to receive the OAuth callback
|
||||
*/
|
||||
function startCallbackServer(): Promise<{ server: Server; getCode: () => Promise<{ code: string; state: string }> }> {
|
||||
async function startCallbackServer(): Promise<{
|
||||
server: Server;
|
||||
getCode: () => Promise<{ code: string; state: string }>;
|
||||
}> {
|
||||
const { createServer } = await import("http");
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let codeResolve: (value: { code: string; state: string }) => void;
|
||||
let codeReject: (error: Error) => void;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
* It is only intended for CLI use, not browser environments.
|
||||
*/
|
||||
|
||||
import { createServer, type Server } from "http";
|
||||
import type { Server } from "http";
|
||||
import { generatePKCE } from "./pkce.js";
|
||||
import type { OAuthCredentials } from "./types.js";
|
||||
|
||||
|
|
@ -28,7 +28,12 @@ const CODE_ASSIST_ENDPOINT = "https://cloudcode-pa.googleapis.com";
|
|||
/**
|
||||
* Start a local HTTP server to receive the OAuth callback
|
||||
*/
|
||||
function startCallbackServer(): Promise<{ server: Server; getCode: () => Promise<{ code: string; state: string }> }> {
|
||||
async function startCallbackServer(): Promise<{
|
||||
server: Server;
|
||||
getCode: () => Promise<{ code: string; state: string }>;
|
||||
}> {
|
||||
const { createServer } = await import("http");
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let codeResolve: (value: { code: string; state: string }) => void;
|
||||
let codeReject: (error: Error) => void;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue