@@ -5,17 +5,27 @@ export const frameworkSettings: { framework: string; frameworkVersion: string }
5
5
frameworkVersion : "" ,
6
6
} ;
7
7
8
+ interface ExchangeAuthCodeParams {
9
+ urlParams : URLSearchParams ;
10
+ domain : string ;
11
+ clientId : string ;
12
+ redirectURL : string ;
13
+ }
14
+
15
+ interface ExchangeAuthCodeResult {
16
+ success : boolean ;
17
+ error ?: string ;
18
+ [ StorageKeys . accessToken ] ?: string ;
19
+ [ StorageKeys . idToken ] ?: string ;
20
+ [ StorageKeys . refreshToken ] ?: string ;
21
+ }
22
+
8
23
export const exchangeAuthCode = async ( {
9
24
urlParams,
10
25
domain,
11
26
clientId,
12
27
redirectURL,
13
- } : {
14
- urlParams : URLSearchParams ;
15
- domain : string ;
16
- clientId : string ;
17
- redirectURL : string ;
18
- } ) : Promise < unknown > => {
28
+ } : ExchangeAuthCodeParams ) : Promise < ExchangeAuthCodeResult > => {
19
29
const state = urlParams . get ( "state" ) ;
20
30
const code = urlParams . get ( "code" ) ;
21
31
@@ -31,7 +41,6 @@ export const exchangeAuthCode = async ({
31
41
if ( ! activeStorage ) {
32
42
throw new Error ( "No active storage found" ) ;
33
43
}
34
- activeStorage . getSessionItem ( StorageKeys . state ) ;
35
44
36
45
// warn if framework and version has not been set
37
46
if ( ! frameworkSettings . framework || ! frameworkSettings . frameworkVersion ) {
@@ -90,9 +99,9 @@ export const exchangeAuthCode = async ({
90
99
activeStorage . removeItems ( StorageKeys . state , StorageKeys . codeVerifier ) ;
91
100
92
101
// Clear all url params
93
- // const url = new URL(window.location.toString());
94
- // url.search = "";
95
- // window.history.pushState({}, "", url);
102
+ const url = new URL ( window . location . toString ( ) ) ;
103
+ url . search = "" ;
104
+ window . history . pushState ( { } , "" , url ) ;
96
105
97
106
return {
98
107
success : true ,
0 commit comments