Skip to content

Commit 66fdfa1

Browse files
committed
fix(cross-domain): drop client plugin check
1 parent 2c37278 commit 66fdfa1

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/react-start/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ export const getCookieName = async (
1414
};
1515

1616
const requireConvexSiteUrl = (
17-
opts: { convexSiteUrl: string },
17+
opts: { convexSiteUrl: string; verbose?: boolean },
1818
calledFrom: string
1919
) => {
2020
if (!opts.convexSiteUrl) {
2121
throw new Error(`${calledFrom}: opts.convexSiteUrl is required`);
2222
}
23+
if (opts.verbose) {
24+
console.log(`${calledFrom}: opts.convexSiteUrl: ${opts.convexSiteUrl}`);
25+
}
2326
return opts.convexSiteUrl;
2427
};
2528

src/react/client.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function useAuth() {
2727
}
2828

2929
export type ConvexAuthClient = {
30-
verbose: boolean | undefined;
30+
verbose?: boolean;
3131
logger?: ConvexReactClient["logger"];
3232
};
3333

@@ -64,7 +64,7 @@ export function AuthProvider({
6464
const { data: session, isPending: isSessionPending } =
6565
authClient.useSession();
6666

67-
const verbose: boolean = (client as any).options?.verbose ?? false;
67+
const verbose: boolean = client.verbose ?? false;
6868
const logVerbose = useCallback(
6969
(message: string) => {
7070
if (verbose) {
@@ -128,17 +128,11 @@ export function AuthProvider({
128128
() => {
129129
// eslint-disable-next-line @typescript-eslint/no-floating-promises
130130
(async () => {
131-
// Return early if cross domain plugin is not configured.
132-
// Apparently there's no sane way to do this type check. Only the in
133-
// keyword narrows the type effectively but it doesn't work on functions.
134-
if (!(authClient as any)["crossDomain"]) {
135-
return;
136-
}
137-
const authClientWithCrossDomain =
138-
authClient as AuthClientWithPlugins<PluginsWithCrossDomain>;
139-
const url = new URL(window.location.href);
131+
const url = new URL(window.location?.href);
140132
const token = url.searchParams.get("ott");
141133
if (token) {
134+
const authClientWithCrossDomain =
135+
authClient as AuthClientWithPlugins<PluginsWithCrossDomain>;
142136
url.searchParams.delete("ott");
143137
const result =
144138
await authClientWithCrossDomain.crossDomain.oneTimeToken.verify({

0 commit comments

Comments
 (0)