@2uinc/frontend-enterprise-logistration 9.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +673 -0
- package/LICENSE +661 -0
- package/LoginRedirect.js +36 -0
- package/LoginRedirect.js.map +1 -0
- package/README.rst +15 -0
- package/index.js +4 -0
- package/index.js.map +1 -0
- package/package.json +61 -0
- package/utils.js +23 -0
- package/utils.js.map +1 -0
package/LoginRedirect.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import { useParams } from 'react-router-dom';
|
|
3
|
+
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
|
|
4
|
+
import { getProxyLoginUrl } from './utils';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This wrapper component redirects the user to the enterprise proxy login view with additional query
|
|
8
|
+
* parameters if they are not already authenticated. If the user is already authenticated, simply return
|
|
9
|
+
* the children to render the rest of the application.
|
|
10
|
+
*
|
|
11
|
+
* @param {node} children The child nodes to render if there is an authenticated user.
|
|
12
|
+
* @param {element} loadingDisplay A React element to display while authenticated user is loading
|
|
13
|
+
*/
|
|
14
|
+
var LoginRedirect = function LoginRedirect(_ref) {
|
|
15
|
+
var children = _ref.children,
|
|
16
|
+
LoadingDisplay = _ref.loadingDisplay;
|
|
17
|
+
var _useParams = useParams(),
|
|
18
|
+
enterpriseSlug = _useParams.enterpriseSlug,
|
|
19
|
+
enterpriseCustomerInviteKey = _useParams.enterpriseCustomerInviteKey;
|
|
20
|
+
var user = getAuthenticatedUser();
|
|
21
|
+
if (user) {
|
|
22
|
+
return children;
|
|
23
|
+
}
|
|
24
|
+
global.location.href = getProxyLoginUrl(enterpriseSlug, enterpriseCustomerInviteKey);
|
|
25
|
+
return LoadingDisplay;
|
|
26
|
+
};
|
|
27
|
+
LoginRedirect.propTypes = {
|
|
28
|
+
children: PropTypes.node,
|
|
29
|
+
loadingDisplay: PropTypes.element
|
|
30
|
+
};
|
|
31
|
+
LoginRedirect.defaultProps = {
|
|
32
|
+
children: null,
|
|
33
|
+
loadingDisplay: null
|
|
34
|
+
};
|
|
35
|
+
export default LoginRedirect;
|
|
36
|
+
//# sourceMappingURL=LoginRedirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoginRedirect.js","names":["PropTypes","useParams","getAuthenticatedUser","getProxyLoginUrl","LoginRedirect","_ref","children","LoadingDisplay","loadingDisplay","_useParams","enterpriseSlug","enterpriseCustomerInviteKey","user","global","location","href","propTypes","node","element","defaultProps"],"sources":["../src/LoginRedirect.jsx"],"sourcesContent":["import PropTypes from 'prop-types';\nimport { useParams } from 'react-router-dom';\nimport { getAuthenticatedUser } from '@edx/frontend-platform/auth';\n\nimport { getProxyLoginUrl } from './utils';\n\n/**\n * This wrapper component redirects the user to the enterprise proxy login view with additional query\n * parameters if they are not already authenticated. If the user is already authenticated, simply return\n * the children to render the rest of the application.\n *\n * @param {node} children The child nodes to render if there is an authenticated user.\n * @param {element} loadingDisplay A React element to display while authenticated user is loading\n */\nconst LoginRedirect = ({ children, loadingDisplay: LoadingDisplay }) => {\n const {\n enterpriseSlug,\n enterpriseCustomerInviteKey,\n } = useParams();\n\n const user = getAuthenticatedUser();\n\n if (user) {\n return children;\n }\n\n global.location.href = getProxyLoginUrl(enterpriseSlug, enterpriseCustomerInviteKey);\n\n return LoadingDisplay;\n};\n\nLoginRedirect.propTypes = {\n children: PropTypes.node,\n loadingDisplay: PropTypes.element,\n};\n\nLoginRedirect.defaultProps = {\n children: null,\n loadingDisplay: null,\n};\n\nexport default LoginRedirect;\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,YAAY;AAClC,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,oBAAoB,QAAQ,6BAA6B;AAElE,SAASC,gBAAgB,QAAQ,SAAS;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,aAAa,GAAG,SAAhBA,aAAaA,CAAAC,IAAA,EAAqD;EAAA,IAA/CC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAkBC,cAAc,GAAAF,IAAA,CAA9BG,cAAc;EAC/C,IAAAC,UAAA,GAGIR,SAAS,CAAC,CAAC;IAFbS,cAAc,GAAAD,UAAA,CAAdC,cAAc;IACdC,2BAA2B,GAAAF,UAAA,CAA3BE,2BAA2B;EAG7B,IAAMC,IAAI,GAAGV,oBAAoB,CAAC,CAAC;EAEnC,IAAIU,IAAI,EAAE;IACR,OAAON,QAAQ;EACjB;EAEAO,MAAM,CAACC,QAAQ,CAACC,IAAI,GAAGZ,gBAAgB,CAACO,cAAc,EAAEC,2BAA2B,CAAC;EAEpF,OAAOJ,cAAc;AACvB,CAAC;AAEDH,aAAa,CAACY,SAAS,GAAG;EACxBV,QAAQ,EAAEN,SAAS,CAACiB,IAAI;EACxBT,cAAc,EAAER,SAAS,CAACkB;AAC5B,CAAC;AAEDd,aAAa,CAACe,YAAY,GAAG;EAC3Bb,QAAQ,EAAE,IAAI;EACdE,cAAc,EAAE;AAClB,CAAC;AAED,eAAeJ,aAAa","ignoreList":[]}
|
package/README.rst
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@edx/frontend-enterprise-logistration
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
|Build Status| |npm_version| |npm_downloads| |license|
|
|
5
|
+
|
|
6
|
+
This package exports a UI component related to logistration for Enterprise users. This package will be helpful for Enterprise micro-frontends to share logic related to redirecting enterprise users to the logistration page branded with their Enterprise Customer's logo and additional messaging.
|
|
7
|
+
|
|
8
|
+
.. |Build Status| image:: https://github.com/openedx/frontend-enterprise/actions/workflows/release.yml/badge.svg
|
|
9
|
+
:target: https://github.com/openedx/frontend-enterprise/actions
|
|
10
|
+
.. |npm_version| image:: https://img.shields.io/npm/v/@edx/frontend-enterprise-logistration.svg
|
|
11
|
+
:target: @edx/frontend-enterprise-logistration
|
|
12
|
+
.. |npm_downloads| image:: https://img.shields.io/npm/dt/@edx/frontend-enterprise-logistration.svg
|
|
13
|
+
:target: @edx/frontend-enterprise-logistration
|
|
14
|
+
.. |license| image:: https://img.shields.io/npm/l/@edx/frontend-enterprise-logistration.svg
|
|
15
|
+
:target: @edx/frontend-enterprise-logistration
|
package/index.js
ADDED
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","LoginRedirect","getProxyLoginUrl"],"sources":["../src/index.js"],"sourcesContent":["// eslint-disable-next-line import/prefer-default-export\nexport { default as LoginRedirect } from './LoginRedirect';\nexport { getProxyLoginUrl } from './utils';\n"],"mappings":"AAAA;AACA,SAASA,OAAO,IAAIC,aAAa,QAAQ,iBAAiB;AAC1D,SAASC,gBAAgB,QAAQ,SAAS","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@2uinc/frontend-enterprise-logistration",
|
|
3
|
+
"version": "9.2.1",
|
|
4
|
+
"description": "Enterprise-specific component(s) to ensure enterprise users are redirected to branded enterprise logistration flow.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/edx/frontend-enterprise.git"
|
|
8
|
+
},
|
|
9
|
+
"watch": {
|
|
10
|
+
"build": {
|
|
11
|
+
"patterns": [
|
|
12
|
+
"src"
|
|
13
|
+
],
|
|
14
|
+
"extensions": "js,jsx"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "npx npm-watch build",
|
|
19
|
+
"clean": "make clean",
|
|
20
|
+
"build": "make build",
|
|
21
|
+
"i18n_extract": "BABEL_ENV=i18n fedx-scripts babel src --quiet > /dev/null",
|
|
22
|
+
"lint": "fedx-scripts eslint --ext .js --ext .jsx .",
|
|
23
|
+
"lint:fix": "fedx-scripts eslint --fix --ext .js --ext .jsx .",
|
|
24
|
+
"snapshot": "fedx-scripts jest --updateSnapshot",
|
|
25
|
+
"test": "fedx-scripts jest --coverage --passWithNoTests",
|
|
26
|
+
"test:watch": "npm run test -- --watch"
|
|
27
|
+
},
|
|
28
|
+
"author": "edX",
|
|
29
|
+
"license": "AGPL-3.0",
|
|
30
|
+
"homepage": "https://github.com/edx/frontend-enterprise#readme",
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public",
|
|
33
|
+
"directory": "dist"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/edx/frontend-enterprise/issues"
|
|
37
|
+
},
|
|
38
|
+
"sideEffects": false,
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@edx/frontend-enterprise-utils": "^10.0.0",
|
|
41
|
+
"prop-types": "^15.8.1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@edx/browserslist-config": "^1.5.0",
|
|
45
|
+
"@edx/frontend-platform": "^8.2.1",
|
|
46
|
+
"@openedx/frontend-build": "^14.3.1",
|
|
47
|
+
"@testing-library/dom": "^10.4.0",
|
|
48
|
+
"@testing-library/jest-dom": "^5.17.0",
|
|
49
|
+
"@testing-library/react": "^16.2.0",
|
|
50
|
+
"react": "^18.3.1",
|
|
51
|
+
"react-dom": "^18.3.1",
|
|
52
|
+
"react-router-dom": "^6.29.0",
|
|
53
|
+
"react-test-renderer": "^18.3.1"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@edx/frontend-platform": "^7.0.0 || ^8.0.0",
|
|
57
|
+
"react": "^16.12.0 || ^17.0.0 || ^18.0.0",
|
|
58
|
+
"react-dom": "^16.12.0 || ^17.0.0 || ^18.0.0",
|
|
59
|
+
"react-router-dom": "^6.0.0"
|
|
60
|
+
}
|
|
61
|
+
}
|
package/utils.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given either an `enterpriseSlug` or an `enterpriseCustomerInviteKey`, returns a
|
|
3
|
+
* URL to the enterprise proxy login page in the LMS. The proxy-login page appropriately
|
|
4
|
+
* redirects enterprise users to the enterprise-specific logistration flow.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} enterpriseSlug Slug of an enterprise customer
|
|
7
|
+
* @param {string} enterpriseCustomerInviteKey UUID of an EnterpriseCustomerInviteKey
|
|
8
|
+
* @returns URL of the enterprise proxy login page in the LMS.
|
|
9
|
+
*/
|
|
10
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
11
|
+
export var getProxyLoginUrl = function getProxyLoginUrl(enterpriseSlug, enterpriseCustomerInviteKey) {
|
|
12
|
+
var queryParams = new URLSearchParams();
|
|
13
|
+
queryParams.append('next', global.location);
|
|
14
|
+
if (enterpriseSlug) {
|
|
15
|
+
queryParams.append('enterprise_slug', enterpriseSlug);
|
|
16
|
+
}
|
|
17
|
+
if (enterpriseCustomerInviteKey) {
|
|
18
|
+
queryParams.append('enterprise_customer_invite_key', enterpriseCustomerInviteKey);
|
|
19
|
+
}
|
|
20
|
+
var proxyLoginUrl = "".concat(process.env.LMS_BASE_URL, "/enterprise/proxy-login/?").concat(queryParams.toString());
|
|
21
|
+
return proxyLoginUrl;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=utils.js.map
|
package/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["getProxyLoginUrl","enterpriseSlug","enterpriseCustomerInviteKey","queryParams","URLSearchParams","append","global","location","proxyLoginUrl","concat","process","env","LMS_BASE_URL","toString"],"sources":["../src/utils.js"],"sourcesContent":["/**\n * Given either an `enterpriseSlug` or an `enterpriseCustomerInviteKey`, returns a\n * URL to the enterprise proxy login page in the LMS. The proxy-login page appropriately\n * redirects enterprise users to the enterprise-specific logistration flow.\n *\n * @param {string} enterpriseSlug Slug of an enterprise customer\n * @param {string} enterpriseCustomerInviteKey UUID of an EnterpriseCustomerInviteKey\n * @returns URL of the enterprise proxy login page in the LMS.\n */\n// eslint-disable-next-line import/prefer-default-export\nexport const getProxyLoginUrl = (enterpriseSlug, enterpriseCustomerInviteKey) => {\n const queryParams = new URLSearchParams();\n queryParams.append('next', global.location);\n if (enterpriseSlug) {\n queryParams.append('enterprise_slug', enterpriseSlug);\n }\n if (enterpriseCustomerInviteKey) {\n queryParams.append('enterprise_customer_invite_key', enterpriseCustomerInviteKey);\n }\n const proxyLoginUrl = `${process.env.LMS_BASE_URL}/enterprise/proxy-login/?${queryParams.toString()}`;\n return proxyLoginUrl;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,cAAc,EAAEC,2BAA2B,EAAK;EAC/E,IAAMC,WAAW,GAAG,IAAIC,eAAe,CAAC,CAAC;EACzCD,WAAW,CAACE,MAAM,CAAC,MAAM,EAAEC,MAAM,CAACC,QAAQ,CAAC;EAC3C,IAAIN,cAAc,EAAE;IAClBE,WAAW,CAACE,MAAM,CAAC,iBAAiB,EAAEJ,cAAc,CAAC;EACvD;EACA,IAAIC,2BAA2B,EAAE;IAC/BC,WAAW,CAACE,MAAM,CAAC,gCAAgC,EAAEH,2BAA2B,CAAC;EACnF;EACA,IAAMM,aAAa,MAAAC,MAAA,CAAMC,OAAO,CAACC,GAAG,CAACC,YAAY,+BAAAH,MAAA,CAA4BN,WAAW,CAACU,QAAQ,CAAC,CAAC,CAAE;EACrG,OAAOL,aAAa;AACtB,CAAC","ignoreList":[]}
|