File tree Expand file tree Collapse file tree 5 files changed +77
-4
lines changed
packages/connect-react/src/components
playground/connect-next/app/passkey-list-wv Expand file tree Collapse file tree 5 files changed +77
-4
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,6 @@ const AppendInitScreen = () => {
154
154
155
155
const handleSubmit = useCallback (
156
156
async ( attestationOptions : string , showErrorIfCancelled : boolean ) => {
157
- console . log ( 'handleSubmit' , attestationOptions ) ;
158
157
if ( appendLoading || skipping ) {
159
158
return ;
160
159
}
Original file line number Diff line number Diff line change @@ -113,8 +113,6 @@ const InitScreen = () => {
113
113
return handleSituation ( LoginSituationCode . CboApiNotAvailablePostAuthenticator ) ;
114
114
}
115
115
116
- console . log ( 'loginContinue' , res . val ) ;
117
-
118
116
try {
119
117
await config . onComplete ( res . val . session ) ;
120
118
} catch {
Original file line number Diff line number Diff line change @@ -166,7 +166,6 @@ const PasskeyListScreen = () => {
166
166
return handleSituation ( PasskeyListSituationCode . CboApiNotAvailableDuringInitialLoad , passkeyList . val ) ;
167
167
}
168
168
169
- console . log ( 'passkeyList' , passkeyList . val . passkeys ) ;
170
169
setPasskeyListToken ( listTokenRes ) ;
171
170
setPasskeyList ( passkeyList . val . passkeys ) ;
172
171
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
+
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
+ }
You can’t perform that action at this time.
0 commit comments