@commercetools-frontend/mc-dev-authentication 21.0.0-rc.0 → 21.4.0
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
CHANGED
|
@@ -1,5 +1,71 @@
|
|
|
1
1
|
# @commercetools-frontend/mc-dev-authentication
|
|
2
2
|
|
|
3
|
+
## 21.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2568](https://github.com/commercetools/merchant-center-application-kit/pull/2568) [`5bcf106a`](https://github.com/commercetools/merchant-center-application-kit/commit/5bcf106a1b82cb2854550a78280554abf1004c62) Thanks [@emmenko](https://github.com/emmenko)! - Enable opt-in support for using [Vite.js](https://vitejs.dev/) bundler. To enable it, set the environment variable `ENABLE_EXPERIMENTAL_VITE_BUNDLER="true"` in your dotenv file.
|
|
8
|
+
|
|
9
|
+
# Why Vite
|
|
10
|
+
|
|
11
|
+
Vite (French word for "quick", pronounced /vit/, like "veet") is a build tool that aims to provide a faster and leaner development experience for modern web projects.
|
|
12
|
+
|
|
13
|
+
You can learn more about the rationale behind the project in the [Why Vite](https://vitejs.dev/guide/why.html) documentation.
|
|
14
|
+
|
|
15
|
+
# Native ES Modules support
|
|
16
|
+
|
|
17
|
+
Vite is optimized for using native [ES Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) via `<script type="module">` tags and ES Modules dynamic import.
|
|
18
|
+
|
|
19
|
+
# CLI compatibility
|
|
20
|
+
|
|
21
|
+
All the `mc-scripts` CLI commands are fully compatible with the new bundler, so you can continue using them as before.
|
|
22
|
+
|
|
23
|
+
## Unsupported features
|
|
24
|
+
|
|
25
|
+
The `cdnUrl` value is not supported at the moment when using Vite.
|
|
26
|
+
|
|
27
|
+
# Required file extensions
|
|
28
|
+
|
|
29
|
+
Vite relies on the file extensions to determine how to process the file in the best possible way. For example, a file using JSX should use the extension `.jsx`, or `.tsx` for TypeScript.
|
|
30
|
+
|
|
31
|
+
Up until now we didn't enforce this with Webpack, so using `.js` or `.jsx` works in both cases. If you are still using `.js` for files including the JSX syntax, you need to rename the file to `.jsx`.
|
|
32
|
+
|
|
33
|
+
To help with the renaming, you can use our codemod `rename-js-to-jsx`:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
npx @commercetools-frontend/codemod rename-js-to-jsx 'src/**/*.js'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- [#2568](https://github.com/commercetools/merchant-center-application-kit/pull/2568) [`5bcf106a`](https://github.com/commercetools/merchant-center-application-kit/commit/5bcf106a1b82cb2854550a78280554abf1004c62) Thanks [@emmenko](https://github.com/emmenko)! - Expose new middleware `createMcDevAuthenticationMiddleware`. This is mostly used for internal development.
|
|
42
|
+
|
|
43
|
+
## 21.0.0
|
|
44
|
+
|
|
45
|
+
### Major Changes
|
|
46
|
+
|
|
47
|
+
- [#2430](https://github.com/commercetools/merchant-center-application-kit/pull/2430) [`bb1f7d75`](https://github.com/commercetools/merchant-center-application-kit/commit/bb1f7d75ff54f7fef05c4d2b3328b88e400b4867) Thanks [@emmenko](https://github.com/emmenko)! - Drop Node.js `v12`. Recommended min Node.js version is `v14` or `v16`.
|
|
48
|
+
|
|
49
|
+
* [#2430](https://github.com/commercetools/merchant-center-application-kit/pull/2430) [`bb1f7d75`](https://github.com/commercetools/merchant-center-application-kit/commit/bb1f7d75ff54f7fef05c4d2b3328b88e400b4867) Thanks [@emmenko](https://github.com/emmenko)! - Following breaking changes were introduced:
|
|
50
|
+
|
|
51
|
+
- In `mc-scripts`, the `build` command additionally compiles the `index.html` by default.
|
|
52
|
+
- Running the `compile-html` command by default should not be necessary anymore. However, you can pass `--build-only` to the `build` command to opt-out of the compilation step, in case you want to run it separately, for example to use the `--transformer`.
|
|
53
|
+
- Running the `compile-html` command by default does not print to `stdout` the JSON string with the security headers. You can opt into the old behavior by passing the `--print-security-headers` option.
|
|
54
|
+
- The `--inline-csp` of `compile-html` has been dropped, as it's now the built-in behavior.
|
|
55
|
+
- The `dist` folder created by the `build` command has been removed. Instead, the `build` command writes the production bundles directly into the `public` folder.
|
|
56
|
+
|
|
57
|
+
For more information see [Release notes v21](https://docs.commercetools.com/custom-applications/releases/2022-01-31-custom-applications-v21).
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- [#2430](https://github.com/commercetools/merchant-center-application-kit/pull/2430) [`bb1f7d75`](https://github.com/commercetools/merchant-center-application-kit/commit/bb1f7d75ff54f7fef05c4d2b3328b88e400b4867) Thanks [@emmenko](https://github.com/emmenko)! - Use version range for Babel packages.
|
|
62
|
+
|
|
63
|
+
## 21.0.0-rc.1
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- [#2430](https://github.com/commercetools/merchant-center-application-kit/pull/2430) [`5ea8baf1`](https://github.com/commercetools/merchant-center-application-kit/commit/5ea8baf1b2ca2661aac9a6a572d2c8e596ee0b2c) Thanks [@emmenko](https://github.com/emmenko)! - Use version range for Babel packages.
|
|
68
|
+
|
|
3
69
|
## 21.0.0-rc.0
|
|
4
70
|
|
|
5
71
|
### Major Changes
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const pug = require('pug');
|
|
3
|
+
const { logout } = require('../routes');
|
|
4
|
+
|
|
5
|
+
const compileLoginView = pug.compileFile(
|
|
6
|
+
path.join(__dirname, '../views/login.pug')
|
|
7
|
+
);
|
|
8
|
+
const compileLogoutView = pug.compileFile(
|
|
9
|
+
path.join(__dirname, '../views/logout.pug')
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
function createMcDevAuthenticationMiddleware(applicationConfig) {
|
|
13
|
+
const htmlLogin = compileLoginView({ env: applicationConfig.env });
|
|
14
|
+
const htmlLogout = compileLogoutView({ env: applicationConfig.env });
|
|
15
|
+
|
|
16
|
+
const isDevAuthenticationMiddlewareDisabled =
|
|
17
|
+
String(applicationConfig.env.disableAuthRoutesOfDevServer) === 'true' ||
|
|
18
|
+
applicationConfig.env.servedByProxy;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @type {import('express').RequestHandler}
|
|
22
|
+
*/
|
|
23
|
+
return (request, response, next) => {
|
|
24
|
+
if (request.originalUrl === '/api/graphql') {
|
|
25
|
+
response.statusCode = 404;
|
|
26
|
+
response.setHeader('Content-Type', 'application/json');
|
|
27
|
+
response.end(
|
|
28
|
+
JSON.stringify({
|
|
29
|
+
message: `This GraphQL endpoint is only available in production in the [Merchant Center Proxy Router](https://docs.commercetools.com/custom-applications/concepts/merchant-center-proxy-router). Please check that you are not calling this endpoint in development mode.`,
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (applicationConfig.env.__DEVELOPMENT__?.oidc?.authorizeUrl) {
|
|
36
|
+
// Handle login page for OIDC workflow when developing against a local MC API.
|
|
37
|
+
if (
|
|
38
|
+
applicationConfig.env.__DEVELOPMENT__?.oidc?.authorizeUrl.startsWith(
|
|
39
|
+
'http://localhost'
|
|
40
|
+
)
|
|
41
|
+
) {
|
|
42
|
+
if (request.originalUrl.startsWith('/login/authorize')) {
|
|
43
|
+
if (isDevAuthenticationMiddlewareDisabled) {
|
|
44
|
+
next();
|
|
45
|
+
} else {
|
|
46
|
+
response.end(htmlLogin);
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
if (request.originalUrl === '/login') {
|
|
53
|
+
if (isDevAuthenticationMiddlewareDisabled) {
|
|
54
|
+
next();
|
|
55
|
+
} else {
|
|
56
|
+
response.end(htmlLogin);
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (request.originalUrl === '/logout') {
|
|
61
|
+
logout(response);
|
|
62
|
+
|
|
63
|
+
if (isDevAuthenticationMiddlewareDisabled) {
|
|
64
|
+
next();
|
|
65
|
+
} else {
|
|
66
|
+
response.end(htmlLogout);
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
next();
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = createMcDevAuthenticationMiddleware;
|
package/middlewares/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
const createLoginMiddleware = require('./create-login-middleware');
|
|
2
2
|
const createLogoutMiddleware = require('./create-logout-middleware');
|
|
3
|
+
const createMcDevAuthenticationMiddleware = require('./create-mc-dev-authentication-middleware');
|
|
3
4
|
|
|
4
5
|
module.exports = {
|
|
5
6
|
createLoginMiddleware,
|
|
6
7
|
createLogoutMiddleware,
|
|
8
|
+
createMcDevAuthenticationMiddleware,
|
|
7
9
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/mc-dev-authentication",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.4.0",
|
|
4
4
|
"description": "Authentication views when running webpack-dev-server in development mode",
|
|
5
5
|
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
"repository": {
|
package/transformer-local.js
CHANGED
|
@@ -24,18 +24,6 @@ module.exports = ({ env }) => {
|
|
|
24
24
|
const loginViewHtml = compileLoginView({ env });
|
|
25
25
|
const logoutViewHtml = compileLogoutView({ env });
|
|
26
26
|
|
|
27
|
-
fs.copyFileSync(
|
|
28
|
-
path.join(__dirname, 'views', 'login.css'),
|
|
29
|
-
path.join(paths.appBuild, 'login.css')
|
|
30
|
-
);
|
|
31
|
-
fs.copyFileSync(
|
|
32
|
-
path.join(__dirname, 'views', 'login.js'),
|
|
33
|
-
path.join(paths.appBuild, 'login.js')
|
|
34
|
-
);
|
|
35
|
-
fs.copyFileSync(
|
|
36
|
-
path.join(__dirname, 'views', 'logout.js'),
|
|
37
|
-
path.join(paths.appBuild, 'logout.js')
|
|
38
|
-
);
|
|
39
27
|
fs.writeFileSync(
|
|
40
28
|
path.join(paths.appBuild, 'login.html'),
|
|
41
29
|
loginViewHtml,
|