@commercetools-frontend/mc-dev-authentication 22.30.3 → 22.32.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.
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
6
|
-
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
7
6
|
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
8
7
|
var fs = require('fs');
|
|
9
8
|
var path = require('path');
|
|
@@ -11,7 +10,6 @@ var path = require('path');
|
|
|
11
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
12
11
|
|
|
13
12
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
14
|
-
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
15
13
|
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
16
14
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
17
15
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
@@ -22,9 +20,9 @@ function logoutRoute(response) {
|
|
|
22
20
|
// NOTE: removing the cookie only works if your are running the MC API
|
|
23
21
|
// locally, otherwise the cookie won't get removed as it's set to a
|
|
24
22
|
// proper domain (e.g. commercetools.com), which we can't unset from localhost.
|
|
25
|
-
response.setHeader('Set-Cookie', _concatInstanceProperty__default["default"](_context = [
|
|
23
|
+
response.setHeader('Set-Cookie', _concatInstanceProperty__default["default"](_context = [`mcAccessToken=''`,
|
|
26
24
|
// <-- unset the value
|
|
27
|
-
'Path=/',
|
|
25
|
+
'Path=/', `Expires=${new Date(0).toUTCString()}`,
|
|
28
26
|
// <-- put a date in the past
|
|
29
27
|
'HttpOnly']).call(_context, additionalCookieParameters).join('; '));
|
|
30
28
|
}
|
|
@@ -40,21 +38,18 @@ function createMcDevAuthenticationMiddleware(applicationConfig) {
|
|
|
40
38
|
const htmlLogout = pages$1.logoutPage;
|
|
41
39
|
const isDevAuthenticationMiddlewareDisabled = String(applicationConfig.env.disableAuthRoutesOfDevServer) === 'true' || applicationConfig.env.servedByProxy;
|
|
42
40
|
return (request, response, next) => {
|
|
43
|
-
var _applicationConfig$en;
|
|
44
41
|
if (request.originalUrl === '/api/graphql') {
|
|
45
42
|
response.statusCode = 404;
|
|
46
43
|
response.setHeader('Content-Type', 'application/json');
|
|
47
44
|
response.end(_JSON$stringify__default["default"]({
|
|
48
|
-
message:
|
|
45
|
+
message: `This GraphQL endpoint is only available in production in the [Merchant Center Proxy Router](https://docs.commercetools.com/merchant-center-customizations/concepts/merchant-center-proxy-router). Please check that you are not calling this endpoint in development mode.`
|
|
49
46
|
}));
|
|
50
47
|
return;
|
|
51
48
|
}
|
|
52
|
-
if (
|
|
53
|
-
var _applicationConfig$en2, _context;
|
|
49
|
+
if (applicationConfig.env.__DEVELOPMENT__?.oidc?.authorizeUrl) {
|
|
54
50
|
// Handle login page for OIDC workflow when developing against a local MC API.
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
if ((_request$originalUrl = request.originalUrl) !== null && _request$originalUrl !== void 0 && _startsWithInstanceProperty__default["default"](_request$originalUrl).call(_request$originalUrl, '/login/authorize')) {
|
|
51
|
+
if (applicationConfig.env.__DEVELOPMENT__?.oidc?.authorizeUrl.startsWith('http://localhost')) {
|
|
52
|
+
if (request.originalUrl?.startsWith('/login/authorize')) {
|
|
58
53
|
if (isDevAuthenticationMiddlewareDisabled) {
|
|
59
54
|
next();
|
|
60
55
|
} else {
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
6
|
-
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
7
6
|
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
8
7
|
var fs = require('fs');
|
|
9
8
|
var path = require('path');
|
|
@@ -11,7 +10,6 @@ var path = require('path');
|
|
|
11
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
12
11
|
|
|
13
12
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
14
|
-
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
15
13
|
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
16
14
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
17
15
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
@@ -22,9 +20,9 @@ function logoutRoute(response) {
|
|
|
22
20
|
// NOTE: removing the cookie only works if your are running the MC API
|
|
23
21
|
// locally, otherwise the cookie won't get removed as it's set to a
|
|
24
22
|
// proper domain (e.g. commercetools.com), which we can't unset from localhost.
|
|
25
|
-
response.setHeader('Set-Cookie', _concatInstanceProperty__default["default"](_context = [
|
|
23
|
+
response.setHeader('Set-Cookie', _concatInstanceProperty__default["default"](_context = [`mcAccessToken=''`,
|
|
26
24
|
// <-- unset the value
|
|
27
|
-
'Path=/',
|
|
25
|
+
'Path=/', `Expires=${new Date(0).toUTCString()}`,
|
|
28
26
|
// <-- put a date in the past
|
|
29
27
|
'HttpOnly']).call(_context, additionalCookieParameters).join('; '));
|
|
30
28
|
}
|
|
@@ -40,21 +38,18 @@ function createMcDevAuthenticationMiddleware(applicationConfig) {
|
|
|
40
38
|
const htmlLogout = pages$1.logoutPage;
|
|
41
39
|
const isDevAuthenticationMiddlewareDisabled = String(applicationConfig.env.disableAuthRoutesOfDevServer) === 'true' || applicationConfig.env.servedByProxy;
|
|
42
40
|
return (request, response, next) => {
|
|
43
|
-
var _applicationConfig$en;
|
|
44
41
|
if (request.originalUrl === '/api/graphql') {
|
|
45
42
|
response.statusCode = 404;
|
|
46
43
|
response.setHeader('Content-Type', 'application/json');
|
|
47
44
|
response.end(_JSON$stringify__default["default"]({
|
|
48
|
-
message:
|
|
45
|
+
message: `This GraphQL endpoint is only available in production in the [Merchant Center Proxy Router](https://docs.commercetools.com/merchant-center-customizations/concepts/merchant-center-proxy-router). Please check that you are not calling this endpoint in development mode.`
|
|
49
46
|
}));
|
|
50
47
|
return;
|
|
51
48
|
}
|
|
52
|
-
if (
|
|
53
|
-
var _applicationConfig$en2, _context;
|
|
49
|
+
if (applicationConfig.env.__DEVELOPMENT__?.oidc?.authorizeUrl) {
|
|
54
50
|
// Handle login page for OIDC workflow when developing against a local MC API.
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
if ((_request$originalUrl = request.originalUrl) !== null && _request$originalUrl !== void 0 && _startsWithInstanceProperty__default["default"](_request$originalUrl).call(_request$originalUrl, '/login/authorize')) {
|
|
51
|
+
if (applicationConfig.env.__DEVELOPMENT__?.oidc?.authorizeUrl.startsWith('http://localhost')) {
|
|
52
|
+
if (request.originalUrl?.startsWith('/login/authorize')) {
|
|
58
53
|
if (isDevAuthenticationMiddlewareDisabled) {
|
|
59
54
|
next();
|
|
60
55
|
} else {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
2
|
-
import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
|
|
3
2
|
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
4
3
|
import fs from 'fs';
|
|
5
4
|
import path from 'path';
|
|
@@ -10,9 +9,9 @@ function logoutRoute(response) {
|
|
|
10
9
|
// NOTE: removing the cookie only works if your are running the MC API
|
|
11
10
|
// locally, otherwise the cookie won't get removed as it's set to a
|
|
12
11
|
// proper domain (e.g. commercetools.com), which we can't unset from localhost.
|
|
13
|
-
response.setHeader('Set-Cookie', _concatInstanceProperty(_context = [
|
|
12
|
+
response.setHeader('Set-Cookie', _concatInstanceProperty(_context = [`mcAccessToken=''`,
|
|
14
13
|
// <-- unset the value
|
|
15
|
-
'Path=/',
|
|
14
|
+
'Path=/', `Expires=${new Date(0).toUTCString()}`,
|
|
16
15
|
// <-- put a date in the past
|
|
17
16
|
'HttpOnly']).call(_context, additionalCookieParameters).join('; '));
|
|
18
17
|
}
|
|
@@ -28,21 +27,18 @@ function createMcDevAuthenticationMiddleware(applicationConfig) {
|
|
|
28
27
|
const htmlLogout = pages$1.logoutPage;
|
|
29
28
|
const isDevAuthenticationMiddlewareDisabled = String(applicationConfig.env.disableAuthRoutesOfDevServer) === 'true' || applicationConfig.env.servedByProxy;
|
|
30
29
|
return (request, response, next) => {
|
|
31
|
-
var _applicationConfig$en;
|
|
32
30
|
if (request.originalUrl === '/api/graphql') {
|
|
33
31
|
response.statusCode = 404;
|
|
34
32
|
response.setHeader('Content-Type', 'application/json');
|
|
35
33
|
response.end(_JSON$stringify({
|
|
36
|
-
message:
|
|
34
|
+
message: `This GraphQL endpoint is only available in production in the [Merchant Center Proxy Router](https://docs.commercetools.com/merchant-center-customizations/concepts/merchant-center-proxy-router). Please check that you are not calling this endpoint in development mode.`
|
|
37
35
|
}));
|
|
38
36
|
return;
|
|
39
37
|
}
|
|
40
|
-
if (
|
|
41
|
-
var _applicationConfig$en2, _context;
|
|
38
|
+
if (applicationConfig.env.__DEVELOPMENT__?.oidc?.authorizeUrl) {
|
|
42
39
|
// Handle login page for OIDC workflow when developing against a local MC API.
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
if ((_request$originalUrl = request.originalUrl) !== null && _request$originalUrl !== void 0 && _startsWithInstanceProperty(_request$originalUrl).call(_request$originalUrl, '/login/authorize')) {
|
|
40
|
+
if (applicationConfig.env.__DEVELOPMENT__?.oidc?.authorizeUrl.startsWith('http://localhost')) {
|
|
41
|
+
if (request.originalUrl?.startsWith('/login/authorize')) {
|
|
46
42
|
if (isDevAuthenticationMiddlewareDisabled) {
|
|
47
43
|
next();
|
|
48
44
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/mc-dev-authentication",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.32.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": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@tsconfig/node16": "^16.1.1",
|
|
37
37
|
"@types/connect": "^3.4.36",
|
|
38
38
|
"connect": "^3.7.0",
|
|
39
|
-
"@commercetools-frontend/application-config": "22.
|
|
39
|
+
"@commercetools-frontend/application-config": "22.32.0"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": "16.x || >=18.0.0"
|