Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Aug 25, 2024
1 parent 4b2c8a4 commit 6c70bb4
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions packages/keychain/src/pages/session.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"use client";

import { Policy } from "@cartridge/controller";
import { CreateController, CreateSession as CreateSessionComp } from "components/connect";
import {
CreateController,
CreateSession as CreateSessionComp,
} from "components/connect";

import { useConnection } from "hooks/connection";
import { useRouter } from "next/router";
Expand All @@ -20,8 +23,7 @@ export default function CreateRemoteSession() {
const router = useRouter();
const queries = router.query as SessionQueryParams;

const { controller, policies, origin } =
useConnection();
const { controller, policies, origin } = useConnection();

const navigateBackHere = useCallback(() => {
router.replace({
Expand Down Expand Up @@ -116,7 +118,10 @@ export default function CreateRemoteSession() {
}, [controller, origin, policies, onCallback]);

return controller ? (
<CreateController loginMode={LoginMode.Controller} onCreated={navigateBackHere} />
<CreateController
loginMode={LoginMode.Controller}
onCreated={navigateBackHere}
/>
) : (
<CreateSessionComp onConnect={onConnect} />
);
Expand All @@ -129,12 +134,15 @@ function sanitizeCallbackUrl(url: string): URL | undefined {
try {
const parsed = new URL(url);

if (parsed.hostname.endsWith("cartridge.gg") || (parsed.pathname !== "/" && parsed.pathname !== "/callback")) {
if (
parsed.hostname.endsWith("cartridge.gg") ||
(parsed.pathname !== "/" && parsed.pathname !== "/callback")
) {
throw new Error(`Invalid callback url: ${url}`);
}

return parsed;
} catch (e) {
console.error(e);

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
}
}
}

0 comments on commit 6c70bb4

Please sign in to comment.