-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #341 from vscheuber/main
fix journey export bug and add token cache and auto token refresh
- Loading branch information
Showing
34 changed files
with
5,261 additions
and
2,802 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import util from 'util'; | ||
|
||
import { State } from '../shared/State'; | ||
import { getCurrentRealmPath } from '../utils/ForgeRockUtils'; | ||
import { generateAmApi } from './BaseApi'; | ||
|
||
const getSessionInfoURLTemplate = '%s/json%s/sessions/?_action=getSessionInfo'; | ||
const apiVersion = 'resource=4.0'; | ||
|
||
function getApiConfig() { | ||
return { | ||
apiVersion, | ||
}; | ||
} | ||
|
||
export type SessionInfoType = { | ||
username: string; | ||
universalId: string; | ||
realm: string; | ||
latestAccessTime: string; | ||
maxIdleExpirationTime: string; | ||
maxSessionExpirationTime: string; | ||
properties: { | ||
AMCtxId: string; | ||
[k: string]: string; | ||
}; | ||
}; | ||
|
||
/** | ||
* Get session info | ||
* @param {string} tokenId session token | ||
* @returns {Promise<SessionInfoType>} a promise resolving to a session info object | ||
*/ | ||
export async function getSessionInfo({ | ||
tokenId, | ||
state, | ||
}: { | ||
tokenId: string; | ||
state: State; | ||
}): Promise<SessionInfoType> { | ||
const urlString = util.format( | ||
getSessionInfoURLTemplate, | ||
state.getHost(), | ||
getCurrentRealmPath(state) | ||
); | ||
const { data } = await generateAmApi({ | ||
resource: getApiConfig(), | ||
state, | ||
}).post( | ||
urlString, | ||
{ | ||
tokenId, | ||
}, | ||
{ | ||
withCredentials: true, | ||
} | ||
); | ||
return data as SessionInfoType; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.