@@ -2,7 +2,7 @@ import './style.css';
2
2
3
3
import { Config , FRUser , TokenManager } from '@forgerock/javascript-sdk' ;
4
4
import { davinci } from '@forgerock/davinci-client' ;
5
- import type { DaVinciConfig } from '@forgerock/davinci-client/types' ;
5
+ // import type { DaVinciConfig } from '@forgerock/davinci-client/types';
6
6
7
7
import usernameComponent from './components/text.js' ;
8
8
import passwordComponent from './components/password.js' ;
@@ -11,9 +11,26 @@ import protect from './components/protect.js';
11
11
import flowLinkComponent from './components/flow-link.js' ;
12
12
import socialLoginButtonComponent from './components/social-login-button.js' ;
13
13
14
- const config : DaVinciConfig = {
15
- clientId : '724ec718-c41c-4d51-98b0-84a583f450f9' ,
16
- redirectUri : window . location . origin + '/' ,
14
+ const qs = window . location . search ;
15
+ const searchParams = new URLSearchParams ( qs ) ;
16
+
17
+ const query : Record < string , string | string [ ] > = { } ;
18
+
19
+ // Get all unique keys from the searchParams
20
+ const uniqueKeys = new Set ( searchParams . keys ( ) ) ;
21
+
22
+ // Iterate over the unique keys
23
+ for ( const key of uniqueKeys ) {
24
+ const values = searchParams . getAll ( key ) ;
25
+ query [ key ] = values . length > 1 ? values : values [ 0 ] ;
26
+ }
27
+ let clientId = '724ec718-c41c-4d51-98b0-84a583f450f9' ;
28
+ if ( query . clientId && query . clientId . length > 0 ) {
29
+ clientId = query . clientId as string ;
30
+ }
31
+ const config = {
32
+ clientId,
33
+ redirectUri : `${ window . location . origin } /` ,
17
34
scope : 'openid profile email name revoke' ,
18
35
serverConfig : {
19
36
wellknown :
@@ -79,7 +96,7 @@ const config: DaVinciConfig = {
79
96
80
97
const loginBtn = document . getElementById ( 'logoutButton' ) as HTMLButtonElement ;
81
98
loginBtn . addEventListener ( 'click' , async ( ) => {
82
- await FRUser . logout ( { logoutRedirectUri : window . location . href } ) ;
99
+ await FRUser . logout ( { logoutRedirectUri : window . location . origin } ) ;
83
100
84
101
window . location . reload ( ) ;
85
102
} ) ;
@@ -179,20 +196,6 @@ const config: DaVinciConfig = {
179
196
console . log ( 'Event emitted from store:' , node ) ;
180
197
} ) ;
181
198
182
- const qs = window . location . search ;
183
- const searchParams = new URLSearchParams ( qs ) ;
184
-
185
- const query : Record < string , string | string [ ] > = { } ;
186
-
187
- // Get all unique keys from the searchParams
188
- const uniqueKeys = new Set ( searchParams . keys ( ) ) ;
189
-
190
- // Iterate over the unique keys
191
- for ( const key of uniqueKeys ) {
192
- const values = searchParams . getAll ( key ) ;
193
- query [ key ] = values . length > 1 ? values : values [ 0 ] ;
194
- }
195
- console . log ( 'query' , query ) ;
196
199
const node = await davinciClient . start ( { query } ) ;
197
200
198
201
formEl . addEventListener ( 'submit' , async ( event ) => {
0 commit comments