@commercetools-frontend/mc-dev-authentication 19.0.0 → 21.0.0-rc.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,41 @@
1
1
  # @commercetools-frontend/mc-dev-authentication
2
2
 
3
+ ## 21.0.0-rc.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#2430](https://github.com/commercetools/merchant-center-application-kit/pull/2430) [`1c363fad`](https://github.com/commercetools/merchant-center-application-kit/commit/1c363fad7ab770a739ac8080358e41ae4af42074) Thanks [@emmenko](https://github.com/emmenko)! - Drop Node.js `v12`. Recommended min Node.js version is `v14` or `v16`.
8
+
9
+ * [#2430](https://github.com/commercetools/merchant-center-application-kit/pull/2430) [`07f5b00f`](https://github.com/commercetools/merchant-center-application-kit/commit/07f5b00f3045a3e30462a1150e6ba85fcecc9098) Thanks [@emmenko](https://github.com/emmenko)! - Following breaking changes were introduced:
10
+
11
+ - In `mc-scripts`, the `build` command additionally compiles the `index.html` by default.
12
+ - 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`.
13
+ - 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.
14
+ - The `--inline-csp` of `compile-html` has been dropped, as it's now the built-in behavior.
15
+ - The `dist` folder created by the `build` command has been removed. Instead, the `build` command writes the production bundles directly into the `public` folder.
16
+
17
+ For more information see [Release notes v21](https://docs.commercetools.com/custom-applications/releases/2022-01-31-custom-applications-v21).
18
+
19
+ ## 20.10.6
20
+
21
+ ### Patch Changes
22
+
23
+ - [#2386](https://github.com/commercetools/merchant-center-application-kit/pull/2386) [`d7fcf6fc`](https://github.com/commercetools/merchant-center-application-kit/commit/d7fcf6fc8495d4eae68e0a4f4c1f1b3e0e394454) Thanks [@emmenko](https://github.com/emmenko)! - Upgrade to Yarn v3
24
+
25
+ ## 20.10.3
26
+
27
+ ### Patch Changes
28
+
29
+ - [#2376](https://github.com/commercetools/merchant-center-application-kit/pull/2376) [`9d879503`](https://github.com/commercetools/merchant-center-application-kit/commit/9d879503f7af467729291d66a35625b6e7cbb385) Thanks [@emmenko](https://github.com/emmenko)! - > For commercetools only.
30
+
31
+ Allow to use OIDC login when developing against a local running MC API.
32
+
33
+ ## 20.10.1
34
+
35
+ ### Patch Changes
36
+
37
+ - [#2356](https://github.com/commercetools/merchant-center-application-kit/pull/2356) [`e34fe076`](https://github.com/commercetools/merchant-center-application-kit/commit/e34fe076aab6681cdcc54622d84123f2c22020e6) Thanks [@ByronDWall](https://github.com/ByronDWall)! - set node version to 16.8 in nvmrc to avoid a bug in node/v8
38
+
3
39
  ## 19.0.0
4
40
 
5
41
  ### Major Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/mc-dev-authentication",
3
- "version": "19.0.0",
3
+ "version": "21.0.0-rc.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": {
@@ -8,11 +8,9 @@
8
8
  "url": "https://github.com/commercetools/merchant-center-application-kit.git",
9
9
  "directory": "packages/mc-dev-authentication"
10
10
  },
11
- "scripts": {},
12
11
  "homepage": "https://docs.commercetools.com/custom-applications",
13
12
  "keywords": ["javascript", "frontend", "react", "toolkit"],
14
13
  "license": "MIT",
15
- "private": false,
16
14
  "publishConfig": {
17
15
  "access": "public"
18
16
  },
@@ -20,6 +18,6 @@
20
18
  "pug": "3.0.2"
21
19
  },
22
20
  "engines": {
23
- "node": ">=12 || >=14"
21
+ "node": ">=14"
24
22
  }
25
23
  }
@@ -14,7 +14,7 @@ const compileLogoutView = pug.compileFile(
14
14
  const appDirectory = fs.realpathSync(process.cwd());
15
15
  const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);
16
16
  const paths = {
17
- appPublic: resolveApp('public'),
17
+ appBuild: resolveApp('public'),
18
18
  };
19
19
 
20
20
  // This transformer will generate a development `login` and `logout` HTML files
@@ -26,23 +26,23 @@ module.exports = ({ env }) => {
26
26
 
27
27
  fs.copyFileSync(
28
28
  path.join(__dirname, 'views', 'login.css'),
29
- path.join(paths.appPublic, 'login.css')
29
+ path.join(paths.appBuild, 'login.css')
30
30
  );
31
31
  fs.copyFileSync(
32
32
  path.join(__dirname, 'views', 'login.js'),
33
- path.join(paths.appPublic, 'login.js')
33
+ path.join(paths.appBuild, 'login.js')
34
34
  );
35
35
  fs.copyFileSync(
36
36
  path.join(__dirname, 'views', 'logout.js'),
37
- path.join(paths.appPublic, 'logout.js')
37
+ path.join(paths.appBuild, 'logout.js')
38
38
  );
39
39
  fs.writeFileSync(
40
- path.join(paths.appPublic, 'login.html'),
40
+ path.join(paths.appBuild, 'login.html'),
41
41
  loginViewHtml,
42
42
  'utf8'
43
43
  );
44
44
  fs.writeFileSync(
45
- path.join(paths.appPublic, 'logout.html'),
45
+ path.join(paths.appBuild, 'logout.html'),
46
46
  logoutViewHtml,
47
47
  'utf8'
48
48
  );
package/views/login.js CHANGED
@@ -20,6 +20,16 @@ window.addEventListener('load', function loaded() {
20
20
  password: data.get('password'),
21
21
  };
22
22
 
23
+ var queryParams = new URLSearchParams(window.location.search);
24
+ if (queryParams.has('response_type')) {
25
+ // OIDC params
26
+ payload.client_id = queryParams.get('client_id');
27
+ payload.response_type = queryParams.get('response_type');
28
+ payload.scope = queryParams.get('scope');
29
+ payload.state = queryParams.get('state');
30
+ payload.nonce = queryParams.get('nonce');
31
+ }
32
+
23
33
  var container = document.getElementById('errors');
24
34
  // Clean up error message elements
25
35
  while (container.firstChild) {
@@ -40,11 +50,16 @@ window.addEventListener('load', function loaded() {
40
50
  })
41
51
  .then(function handleResponse(response) {
42
52
  if (response.ok) {
43
- return response.json().then(function onSuccess() {
44
- window.localStorage.setItem('isAuthenticated', true);
45
- var searchParams = new URLSearchParams(window.location.search);
46
- var redirectTo = searchParams.get('redirectTo') || '/';
47
- window.location.replace(redirectTo);
53
+ return response.json().then(function onSuccess(result) {
54
+ // Handle OIDC redirect.
55
+ if (queryParams.has('response_type')) {
56
+ window.location.replace(result.redirectTo);
57
+ } else {
58
+ window.localStorage.setItem('isAuthenticated', true);
59
+ var searchParams = new URLSearchParams(window.location.search);
60
+ var redirectTo = searchParams.get('redirectTo') || '/';
61
+ window.location.replace(redirectTo);
62
+ }
48
63
  });
49
64
  }
50
65
  return response.text().then(function onError(responseText) {