@commercetools-frontend/mc-dev-authentication 25.0.0 → 25.2.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.
|
@@ -4,19 +4,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
6
6
|
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
7
|
+
var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
7
8
|
var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
8
9
|
|
|
9
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
10
11
|
|
|
11
12
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
12
13
|
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
14
|
+
var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
|
|
13
15
|
var _URL__default = /*#__PURE__*/_interopDefault(_URL);
|
|
14
16
|
|
|
15
17
|
const trimTrailingSlash = value => value.replace(/\/$/, '');
|
|
16
18
|
function createMcDevAuthenticationMiddleware(applicationConfig) {
|
|
17
19
|
const isDevAuthenticationMiddlewareDisabled = String(applicationConfig.env.disableAuthRoutesOfDevServer) === 'true' || applicationConfig.env.servedByProxy;
|
|
18
20
|
return (request, response, next) => {
|
|
19
|
-
var _applicationConfig$en;
|
|
20
21
|
// This endpoint is meant to be used in Cypress tests to ensure
|
|
21
22
|
// that the primary origin is set to localhost.
|
|
22
23
|
if (request.originalUrl === '/api/health') {
|
|
@@ -28,7 +29,7 @@ function createMcDevAuthenticationMiddleware(applicationConfig) {
|
|
|
28
29
|
}));
|
|
29
30
|
} else {
|
|
30
31
|
response.setHeader('Content-Type', 'text/html');
|
|
31
|
-
response.end(
|
|
32
|
+
response.end(`healthy = true`);
|
|
32
33
|
}
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
@@ -36,16 +37,16 @@ function createMcDevAuthenticationMiddleware(applicationConfig) {
|
|
|
36
37
|
response.statusCode = 404;
|
|
37
38
|
response.setHeader('Content-Type', 'application/json');
|
|
38
39
|
response.end(_JSON$stringify__default["default"]({
|
|
39
|
-
message:
|
|
40
|
+
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.`
|
|
40
41
|
}));
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
43
|
-
if (
|
|
44
|
+
if (applicationConfig.env.__DEVELOPMENT__?.oidc?.authorizeUrl) {
|
|
44
45
|
var _context;
|
|
45
46
|
// Handle login page for OIDC workflow when developing against a local MC API.
|
|
46
47
|
if (_startsWithInstanceProperty__default["default"](_context = applicationConfig.env.__DEVELOPMENT__.oidc.authorizeUrl).call(_context, 'http://localhost')) {
|
|
47
|
-
var
|
|
48
|
-
if ((
|
|
48
|
+
var _context2, _context3;
|
|
49
|
+
if (((_context2 = request.originalUrl) == null ? void 0 : _bindInstanceProperty__default["default"](_context3 = Function.call).call(_context3, _startsWithInstanceProperty__default["default"](_context2), _context2))?.('/login/authorize')) {
|
|
49
50
|
if (!isDevAuthenticationMiddlewareDisabled) {
|
|
50
51
|
// Redirect to the MC API to initiate the authorize flow.
|
|
51
52
|
const redirectTo = new _URL__default["default"](request.originalUrl, trimTrailingSlash(applicationConfig.env.mcApiUrl));
|
|
@@ -4,19 +4,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
6
6
|
var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
|
|
7
|
+
var _bindInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/bind');
|
|
7
8
|
var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
8
9
|
|
|
9
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
10
11
|
|
|
11
12
|
var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
|
|
12
13
|
var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
|
|
14
|
+
var _bindInstanceProperty__default = /*#__PURE__*/_interopDefault(_bindInstanceProperty);
|
|
13
15
|
var _URL__default = /*#__PURE__*/_interopDefault(_URL);
|
|
14
16
|
|
|
15
17
|
const trimTrailingSlash = value => value.replace(/\/$/, '');
|
|
16
18
|
function createMcDevAuthenticationMiddleware(applicationConfig) {
|
|
17
19
|
const isDevAuthenticationMiddlewareDisabled = String(applicationConfig.env.disableAuthRoutesOfDevServer) === 'true' || applicationConfig.env.servedByProxy;
|
|
18
20
|
return (request, response, next) => {
|
|
19
|
-
var _applicationConfig$en;
|
|
20
21
|
// This endpoint is meant to be used in Cypress tests to ensure
|
|
21
22
|
// that the primary origin is set to localhost.
|
|
22
23
|
if (request.originalUrl === '/api/health') {
|
|
@@ -28,7 +29,7 @@ function createMcDevAuthenticationMiddleware(applicationConfig) {
|
|
|
28
29
|
}));
|
|
29
30
|
} else {
|
|
30
31
|
response.setHeader('Content-Type', 'text/html');
|
|
31
|
-
response.end(
|
|
32
|
+
response.end(`healthy = true`);
|
|
32
33
|
}
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
@@ -36,16 +37,16 @@ function createMcDevAuthenticationMiddleware(applicationConfig) {
|
|
|
36
37
|
response.statusCode = 404;
|
|
37
38
|
response.setHeader('Content-Type', 'application/json');
|
|
38
39
|
response.end(_JSON$stringify__default["default"]({
|
|
39
|
-
message:
|
|
40
|
+
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.`
|
|
40
41
|
}));
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
43
|
-
if (
|
|
44
|
+
if (applicationConfig.env.__DEVELOPMENT__?.oidc?.authorizeUrl) {
|
|
44
45
|
var _context;
|
|
45
46
|
// Handle login page for OIDC workflow when developing against a local MC API.
|
|
46
47
|
if (_startsWithInstanceProperty__default["default"](_context = applicationConfig.env.__DEVELOPMENT__.oidc.authorizeUrl).call(_context, 'http://localhost')) {
|
|
47
|
-
var
|
|
48
|
-
if ((
|
|
48
|
+
var _context2, _context3;
|
|
49
|
+
if (((_context2 = request.originalUrl) == null ? void 0 : _bindInstanceProperty__default["default"](_context3 = Function.call).call(_context3, _startsWithInstanceProperty__default["default"](_context2), _context2))?.('/login/authorize')) {
|
|
49
50
|
if (!isDevAuthenticationMiddlewareDisabled) {
|
|
50
51
|
// Redirect to the MC API to initiate the authorize flow.
|
|
51
52
|
const redirectTo = new _URL__default["default"](request.originalUrl, trimTrailingSlash(applicationConfig.env.mcApiUrl));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
2
2
|
import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
|
|
3
|
+
import _bindInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/bind';
|
|
3
4
|
import _URL from '@babel/runtime-corejs3/core-js-stable/url';
|
|
4
5
|
|
|
5
6
|
const trimTrailingSlash = value => value.replace(/\/$/, '');
|
|
6
7
|
function createMcDevAuthenticationMiddleware(applicationConfig) {
|
|
7
8
|
const isDevAuthenticationMiddlewareDisabled = String(applicationConfig.env.disableAuthRoutesOfDevServer) === 'true' || applicationConfig.env.servedByProxy;
|
|
8
9
|
return (request, response, next) => {
|
|
9
|
-
var _applicationConfig$en;
|
|
10
10
|
// This endpoint is meant to be used in Cypress tests to ensure
|
|
11
11
|
// that the primary origin is set to localhost.
|
|
12
12
|
if (request.originalUrl === '/api/health') {
|
|
@@ -18,7 +18,7 @@ function createMcDevAuthenticationMiddleware(applicationConfig) {
|
|
|
18
18
|
}));
|
|
19
19
|
} else {
|
|
20
20
|
response.setHeader('Content-Type', 'text/html');
|
|
21
|
-
response.end(
|
|
21
|
+
response.end(`healthy = true`);
|
|
22
22
|
}
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
@@ -26,16 +26,16 @@ function createMcDevAuthenticationMiddleware(applicationConfig) {
|
|
|
26
26
|
response.statusCode = 404;
|
|
27
27
|
response.setHeader('Content-Type', 'application/json');
|
|
28
28
|
response.end(_JSON$stringify({
|
|
29
|
-
message:
|
|
29
|
+
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.`
|
|
30
30
|
}));
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
if (
|
|
33
|
+
if (applicationConfig.env.__DEVELOPMENT__?.oidc?.authorizeUrl) {
|
|
34
34
|
var _context;
|
|
35
35
|
// Handle login page for OIDC workflow when developing against a local MC API.
|
|
36
36
|
if (_startsWithInstanceProperty(_context = applicationConfig.env.__DEVELOPMENT__.oidc.authorizeUrl).call(_context, 'http://localhost')) {
|
|
37
|
-
var
|
|
38
|
-
if ((
|
|
37
|
+
var _context2, _context3;
|
|
38
|
+
if (((_context2 = request.originalUrl) == null ? void 0 : _bindInstanceProperty(_context3 = Function.call).call(_context3, _startsWithInstanceProperty(_context2), _context2))?.('/login/authorize')) {
|
|
39
39
|
if (!isDevAuthenticationMiddlewareDisabled) {
|
|
40
40
|
// Redirect to the MC API to initiate the authorize flow.
|
|
41
41
|
const redirectTo = new _URL(request.originalUrl, trimTrailingSlash(applicationConfig.env.mcApiUrl));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/mc-dev-authentication",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.2.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/node22": "^22.0.0",
|
|
37
37
|
"@types/connect": "^3.4.36",
|
|
38
38
|
"connect": "^3.7.0",
|
|
39
|
-
"@commercetools-frontend/application-config": "25.
|
|
39
|
+
"@commercetools-frontend/application-config": "25.2.0"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": "18.x || 20.x || >=22.0.0"
|