Skip to content

Commit 3a0bd77

Browse files
committed
fix: inline webauthn imports in click handlers only — no module-level import
1 parent 74e3b88 commit 3a0bd77

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/app/login/LoginForm.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
import { useState } from 'react';
44
import Link from 'next/link';
55
import { useRouter, useSearchParams } from 'next/navigation';
6-
// Dynamic import to prevent SSR/hydration crashes
7-
const startAuthentication = async (opts: any) => {
8-
const { startAuthentication: fn } = await import('@simplewebauthn/browser');
9-
return fn(opts);
10-
};
116

127
export default function LoginForm() {
138
const router = useRouter();
@@ -166,6 +161,7 @@ export default function LoginForm() {
166161
}
167162

168163
// 2. Browser WebAuthn prompt
164+
const { startAuthentication } = await import('@simplewebauthn/browser');
169165
const credential = await startAuthentication({ optionsJSON: optData.options });
170166

171167
// 3. Verify with server

src/app/settings/security/page.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ import { useState, useEffect } from 'react';
44
import { useRouter } from 'next/navigation';
55
import Link from 'next/link';
66
import { authFetch } from '@/lib/auth/client';
7-
// Dynamic import to prevent SSR/hydration crashes
8-
const startRegistration = async (opts: any) => {
9-
const { startRegistration: fn } = await import('@simplewebauthn/browser');
10-
return fn(opts);
11-
};
7+
128

139
interface Passkey {
1410
id: string;
@@ -70,6 +66,7 @@ export default function SecuritySettingsPage() {
7066
}
7167

7268
// 2. Start WebAuthn registration (browser prompt)
69+
const { startRegistration } = await import('@simplewebauthn/browser');
7370
const credential = await startRegistration({ optionsJSON: optResult.data.options });
7471

7572
// 3. Verify with server

0 commit comments

Comments
 (0)