Shift oidc and initWebworkers to own files
This commit is contained in:
1 parent
70f83f131a
commit
69fb4d7947
6 files changed
+113
-65
No files matched your search
@@ -0,0 +1,52 @@
|
||||
// https://github.com/maxmantz/redux-oidc/blob/master/docs/API.md
|
||||
import { loadUser, createUserManager } from 'redux-oidc'
|
||||
|
||||
/**
|
||||
* Creates a userManager from oidcSettings;
|
||||
* loads the user into the provided redux store
|
||||
*
|
||||
* @param {*} store
|
||||
* @param {Object} oidcSettings
|
||||
* @param {string} oidcSettings.authServerUrl,
|
||||
* @param {string} oidcSettings.clientId,
|
||||
* @param {string} oidcSettings.authRedirectUri,
|
||||
* @param {string} oidcSettings.postLogoutRedirectUri,
|
||||
* @param {string} oidcSettings.responseType,
|
||||
* @param {string} oidcSettings.extraQueryParams,
|
||||
*/
|
||||
export default function(store, oidcSettings) {
|
||||
if (!store || !oidcSettings) {
|
||||
return
|
||||
}
|
||||
|
||||
const {
|
||||
authServerUrl,
|
||||
clientId,
|
||||
authRedirectUri,
|
||||
postLogoutRedirectUri,
|
||||
responseType,
|
||||
extraQueryParams,
|
||||
} = oidcSettings
|
||||
|
||||
const settings = {
|
||||
authority: authServerUrl,
|
||||
client_id: clientId,
|
||||
redirect_uri: authRedirectUri,
|
||||
silent_redirect_uri: '/silent-refresh.html',
|
||||
post_logout_redirect_uri: postLogoutRedirectUri,
|
||||
response_type: responseType,
|
||||
// Note: Request must have scope 'openid' to be considered an OpenID Connect request
|
||||
scope: 'email profile openid',
|
||||
automaticSilentRenew: true,
|
||||
revokeAccessTokenOnSignout: true,
|
||||
filterProtocolClaims: true,
|
||||
loadUserInfo: true,
|
||||
extraQueryParams: extraQueryParams,
|
||||
}
|
||||
|
||||
const userManager = createUserManager(settings)
|
||||
|
||||
loadUser(store, userManager)
|
||||
|
||||
return userManager
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import getUserManagerForOpenIdConnectClient from './getUserManagerForOpenIdConnectClient.js'
|
||||
import initWebWorkers from './initWebWorkers.js'
|
||||
|
||||
export { getUserManagerForOpenIdConnectClient, initWebWorkers }
|
||||
@@ -0,0 +1,26 @@
|
||||
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader'
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {String} baseDirectory
|
||||
* @param {String} webWorkScriptsPath
|
||||
*/
|
||||
export default function(baseDirectory, webWorkScriptsPath) {
|
||||
const scriptsPath = `${baseDirectory}/${webWorkScriptsPath}`
|
||||
const config = {
|
||||
maxWebWorkers: Math.max(navigator.hardwareConcurrency - 1, 1),
|
||||
startWebWorkersOnDemand: true,
|
||||
webWorkerPath: `${scriptsPath}/cornerstoneWADOImageLoaderWebWorker.min.js`,
|
||||
taskConfiguration: {
|
||||
decodeTask: {
|
||||
loadCodecsOnStartup: true,
|
||||
initializeCodecsOnStartup: false,
|
||||
codecsPath: `${scriptsPath}/cornerstoneWADOImageLoaderCodecs.min.js`,
|
||||
usePDFJS: false,
|
||||
strict: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
cornerstoneWADOImageLoader.webWorkerManager.initialize(config)
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import initWebWorkers from './initWebWorkers.js'
|
||||
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader'
|
||||
|
||||
describe('initWebWorkers', () => {
|
||||
it("initializes cornerstoneWADOImageLoader's web workers", () => {
|
||||
const basePath = '/'
|
||||
const relativeWebWorkerScriptsPath = ''
|
||||
|
||||
initWebWorkers(basePath, relativeWebWorkerScriptsPath)
|
||||
|
||||
expect(
|
||||
cornerstoneWADOImageLoader.webWorkerManager.initialize
|
||||
).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user