Split packages into platform and extensions
This commit is contained in:
1 parent
f175d4b96b
commit
e8969fba11
992 files changed
+2
-1
No files matched your search
@@ -0,0 +1,37 @@
|
||||
// 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
|
||||
* LINK: https://github.com/IdentityModel/oidc-client-js/wiki#configuration
|
||||
*
|
||||
* @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 settings = {
|
||||
...oidcSettings,
|
||||
silent_redirect_uri: '/silent-refresh.html',
|
||||
automaticSilentRenew: true,
|
||||
revokeAccessTokenOnSignout: true,
|
||||
filterProtocolClaims: true,
|
||||
loadUserInfo: true,
|
||||
};
|
||||
|
||||
const userManager = createUserManager(settings);
|
||||
|
||||
loadUser(store, userManager);
|
||||
|
||||
return userManager;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import getUserManagerForOpenIdConnectClient from './getUserManagerForOpenIdConnectClient.js';
|
||||
|
||||
describe('getUserManagerForOpenIdConnectClient', () => {
|
||||
it('returns undefined if store is not provided', () => {
|
||||
const expectedReturnVal = undefined;
|
||||
const returnVal = getUserManagerForOpenIdConnectClient(undefined, {});
|
||||
|
||||
expect(returnVal).toEqual(expectedReturnVal);
|
||||
});
|
||||
|
||||
it('returns undefined if oidcSettings are not provided', () => {
|
||||
const expectedReturnVal = undefined;
|
||||
const returnVal = getUserManagerForOpenIdConnectClient({}, undefined);
|
||||
|
||||
expect(returnVal).toEqual(expectedReturnVal);
|
||||
});
|
||||
|
||||
it('does not return undefined when store and oidcSettings are defined', () => {
|
||||
const returnVal = getUserManagerForOpenIdConnectClient({}, {});
|
||||
|
||||
expect(returnVal).not.toBe(undefined);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
import getUserManagerForOpenIdConnectClient from './getUserManagerForOpenIdConnectClient.js';
|
||||
import initWebWorkers from './initWebWorkers.js';
|
||||
|
||||
export { getUserManagerForOpenIdConnectClient, initWebWorkers };
|
||||
@@ -0,0 +1,11 @@
|
||||
import * as utils from './index.js';
|
||||
|
||||
describe('utils', () => {
|
||||
it('has the expected exports', () => {
|
||||
const utilExports = Object.keys(utils).sort();
|
||||
|
||||
expect(utilExports).toEqual(
|
||||
['getUserManagerForOpenIdConnectClient', 'initWebWorkers'].sort()
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {String} baseDirectory
|
||||
* @param {String} webWorkScriptsPath
|
||||
*/
|
||||
export default function initWebWorkers(
|
||||
baseDirectory = '/',
|
||||
webWorkScriptsPath = ''
|
||||
) {
|
||||
let scriptsPath = `${window.location.protocol}//${
|
||||
window.location.host
|
||||
}${baseDirectory}${webWorkScriptsPath}`;
|
||||
|
||||
// Ensure the last character is a slash
|
||||
if (scriptsPath[scriptsPath.length - 1] !== '/') {
|
||||
scriptsPath += '/';
|
||||
}
|
||||
|
||||
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