@@ -31,7 +31,6 @@ import {
3131 setActiveStorage ,
3232 isAuthenticated ,
3333 updateActivityTimestamp ,
34- getInsecureStorage ,
3534} from "@kinde/js-utils" ;
3635import * as storeState from "./store" ;
3736import React , {
@@ -55,6 +54,7 @@ import type {
5554 RefreshTokenResult ,
5655 Scopes ,
5756 SessionManager ,
57+ TimeoutTokenData ,
5858} from "@kinde/js-utils" ;
5959// TODO: need to look for old token store and convert.
6060storageSettings . keyPrefix = "" ;
@@ -229,39 +229,38 @@ export const KindeProvider = ({
229229 storageSettings . activityTimeoutMinutes = activityTimeout . timeoutMinutes ;
230230 storageSettings . activityTimeoutPreWarningMinutes =
231231 activityTimeout . preWarningMinutes ;
232- storageSettings . onActivityTimeout = async ( type : TimeoutActivityType ) => {
232+ storageSettings . onActivityTimeout = async (
233+ type : TimeoutActivityType ,
234+ tokens ?: TimeoutTokenData ,
235+ ) => {
233236 try {
234237 if ( type === TimeoutActivityType . timeout ) {
235- const insecureStorage = getInsecureStorage ( ) ;
236- const accessToken = await store . getSessionItem (
237- StorageKeys . accessToken ,
238- ) ;
239- const refreshToken = await insecureStorage ?. getSessionItem (
240- StorageKeys . refreshToken ,
241- ) ;
238+ const accessToken = tokens ?. accessToken ;
239+ const refreshToken = tokens ?. refreshToken ;
240+
242241 await Promise . all ( [
243242 await fetch ( `${ domain } /logout` ) ,
244243 refreshToken &&
245244 ( await fetch ( `${ domain } /oauth2/revoke` , {
246245 method : "POST" ,
247246 body : JSON . stringify ( {
248- token : await store . getSessionItem ( StorageKeys . accessToken ) ,
247+ token : refreshToken ,
249248 } ) ,
250249 headers : {
251250 "Content-Type" : "application/json" ,
252- Authorization : `Bearer ${ await store . getSessionItem ( StorageKeys . accessToken ) } ` ,
251+ Authorization : `Bearer ${ accessToken } ` ,
253252 } ,
254253 } ) ) ,
255254 ] ) ;
256255 if ( accessToken ) {
257256 await fetch ( `${ domain } /oauth2/revoke` , {
258257 method : "POST" ,
259258 body : JSON . stringify ( {
260- token : await store . getSessionItem ( StorageKeys . accessToken ) ,
259+ token : accessToken ,
261260 } ) ,
262261 headers : {
263262 "Content-Type" : "application/json" ,
264- Authorization : `Bearer ${ await store . getSessionItem ( StorageKeys . accessToken ) } ` ,
263+ Authorization : `Bearer ${ accessToken } ` ,
265264 } ,
266265 } ) ;
267266 }
0 commit comments