Skip to content

Commit 99735fa

Browse files
committed
wip
1 parent 66d58ce commit 99735fa

File tree

5 files changed

+77
-4
lines changed

5 files changed

+77
-4
lines changed

packages/connect-react/src/components/append/AppendInitScreen.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ const AppendInitScreen = () => {
154154

155155
const handleSubmit = useCallback(
156156
async (attestationOptions: string, showErrorIfCancelled: boolean) => {
157-
console.log('handleSubmit', attestationOptions);
158157
if (appendLoading || skipping) {
159158
return;
160159
}

packages/connect-react/src/components/login-second-factor/InitScreen.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ const InitScreen = () => {
113113
return handleSituation(LoginSituationCode.CboApiNotAvailablePostAuthenticator);
114114
}
115115

116-
console.log('loginContinue', res.val);
117-
118116
try {
119117
await config.onComplete(res.val.session);
120118
} catch {

packages/connect-react/src/components/passkeyList/PasskeyListScreen.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ const PasskeyListScreen = () => {
166166
return handleSituation(PasskeyListSituationCode.CboApiNotAvailableDuringInitialLoad, passkeyList.val);
167167
}
168168

169-
console.log('passkeyList', passkeyList.val.passkeys);
170169
setPasskeyListToken(listTokenRes);
171170
setPasskeyList(passkeyList.val.passkeys);
172171
statefulLoader.current.finish();
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use server';
2+
3+
import { cookies } from 'next/headers';
4+
import { ConnectTokenType } from '@corbado/types';
5+
6+
export async function getCorbadoToken(tokenType: ConnectTokenType) {
7+
const cookieStore = await cookies();
8+
const identifier = cookieStore.get('identifier');
9+
if (!identifier) {
10+
return null;
11+
}
12+
13+
// call backend API to get token
14+
const payload = {
15+
type: tokenType,
16+
data: {
17+
identifier: identifier.value,
18+
},
19+
};
20+
21+
const body = JSON.stringify(payload);
22+
23+
const url = `${process.env.CORBADO_BACKEND_API_URL}/v2/connectTokens`;
24+
const response = await fetch(url, {
25+
method: 'POST',
26+
headers: {
27+
Authorization: `Basic ${process.env.CORBADO_BACKEND_API_BASIC_AUTH}`,
28+
'Content-Type': 'application/json',
29+
},
30+
cache: 'no-cache',
31+
body: body,
32+
});
33+
34+
const out = await response.json();
35+
console.log(out);
36+
37+
return out.secret;
38+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
'use client';
2+
import { useEffect, useState } from 'react';
3+
4+
export const runtime = 'edge';
5+
6+
import { CorbadoConnectPasskeyList } from '@corbado/connect-react';
7+
import { getCorbadoToken } from './actions';
8+
import { getAppendToken } from '../actions';
9+
10+
export default function PasskeyListPage() {
11+
const searchParams = new URLSearchParams(window.location.search);
12+
const identifier = searchParams.get('identifier');
13+
const [loading, setLoading] = useState(true);
14+
15+
useEffect(() => {
16+
if (identifier) {
17+
document.cookie = `identifier=${identifier}; path=/;`;
18+
setLoading(false);
19+
}
20+
}, []);
21+
22+
if (loading) {
23+
return <div>Loading...</div>;
24+
}
25+
26+
return (
27+
<div className='w-full flex justify-center'>
28+
<div className='w-full my-4 mx-4'>
29+
<div className='mb-2 flex justify-between w-full'>
30+
<CorbadoConnectPasskeyList
31+
connectTokenProvider={async tokenType =>
32+
tokenType === 'passkey-append' ? await getAppendToken() : await getCorbadoToken(tokenType)
33+
}
34+
/>
35+
</div>
36+
</div>
37+
</div>
38+
);
39+
}

0 commit comments

Comments
 (0)