File tree Expand file tree Collapse file tree
packages/connect-react/src/components
playground/connect-next/app/passkey-list-wv Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff 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 ( ) ;
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ import { useSearchParams } from 'next/navigation' ;
10+
11+ export default function PasskeyListPage ( ) {
12+ const searchParams = useSearchParams ( ) ;
13+ const identifier = searchParams . get ( 'identifier' ) ;
14+ const email = searchParams . get ( 'email' ) ;
15+ const [ loading , setLoading ] = useState ( true ) ;
16+
17+ useEffect ( ( ) => {
18+ if ( identifier ) {
19+ document . cookie = `identifier=${ identifier } ; path=/;` ;
20+ document . cookie = `displayName=${ email } ; path=/;` ;
21+ setLoading ( false ) ;
22+ }
23+ } , [ ] ) ;
24+
25+ if ( loading ) {
26+ return < div > Loading...</ div > ;
27+ }
28+
29+ return (
30+ < div className = 'w-full flex justify-center' >
31+ < div className = 'w-full my-4 mx-4' >
32+ < div className = 'mb-2 flex justify-between w-full' >
33+ < CorbadoConnectPasskeyList
34+ connectTokenProvider = { async tokenType =>
35+ tokenType === 'passkey-append' ? await getAppendToken ( ) : await getCorbadoToken ( tokenType )
36+ }
37+ />
38+ </ div >
39+ </ div >
40+ </ div >
41+ ) ;
42+ }
You can’t perform that action at this time.
0 commit comments