@commercetools-frontend/mc-dev-authentication 24.11.0 → 24.12.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.
@@ -16,6 +16,7 @@ const trimTrailingSlash = value => value.replace(/\/$/, '');
16
16
  function createMcDevAuthenticationMiddleware(applicationConfig) {
17
17
  const isDevAuthenticationMiddlewareDisabled = String(applicationConfig.env.disableAuthRoutesOfDevServer) === 'true' || applicationConfig.env.servedByProxy;
18
18
  return (request, response, next) => {
19
+ var _applicationConfig$en;
19
20
  // This endpoint is meant to be used in Cypress tests to ensure
20
21
  // that the primary origin is set to localhost.
21
22
  if (request.originalUrl === '/api/health') {
@@ -27,7 +28,7 @@ function createMcDevAuthenticationMiddleware(applicationConfig) {
27
28
  }));
28
29
  } else {
29
30
  response.setHeader('Content-Type', 'text/html');
30
- response.end(`healthy = true`);
31
+ response.end("healthy = true");
31
32
  }
32
33
  return;
33
34
  }
@@ -35,15 +36,16 @@ function createMcDevAuthenticationMiddleware(applicationConfig) {
35
36
  response.statusCode = 404;
36
37
  response.setHeader('Content-Type', 'application/json');
37
38
  response.end(_JSON$stringify__default["default"]({
38
- 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.`
39
+ 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."
39
40
  }));
40
41
  return;
41
42
  }
42
- if (applicationConfig.env.__DEVELOPMENT__?.oidc?.authorizeUrl) {
43
+ if ((_applicationConfig$en = applicationConfig.env.__DEVELOPMENT__) !== null && _applicationConfig$en !== void 0 && (_applicationConfig$en = _applicationConfig$en.oidc) !== null && _applicationConfig$en !== void 0 && _applicationConfig$en.authorizeUrl) {
43
44
  var _context;
44
45
  // Handle login page for OIDC workflow when developing against a local MC API.
45
46
  if (_startsWithInstanceProperty__default["default"](_context = applicationConfig.env.__DEVELOPMENT__.oidc.authorizeUrl).call(_context, 'http://localhost')) {
46
- if (request.originalUrl?.startsWith('/login/authorize')) {
47
+ var _request$originalUrl;
48
+ if ((_request$originalUrl = request.originalUrl) !== null && _request$originalUrl !== void 0 && _startsWithInstanceProperty__default["default"](_request$originalUrl).call(_request$originalUrl, '/login/authorize')) {
47
49
  if (!isDevAuthenticationMiddlewareDisabled) {
48
50
  // Redirect to the MC API to initiate the authorize flow.
49
51
  const redirectTo = new _URL__default["default"](request.originalUrl, trimTrailingSlash(applicationConfig.env.mcApiUrl));
@@ -16,6 +16,7 @@ const trimTrailingSlash = value => value.replace(/\/$/, '');
16
16
  function createMcDevAuthenticationMiddleware(applicationConfig) {
17
17
  const isDevAuthenticationMiddlewareDisabled = String(applicationConfig.env.disableAuthRoutesOfDevServer) === 'true' || applicationConfig.env.servedByProxy;
18
18
  return (request, response, next) => {
19
+ var _applicationConfig$en;
19
20
  // This endpoint is meant to be used in Cypress tests to ensure
20
21
  // that the primary origin is set to localhost.
21
22
  if (request.originalUrl === '/api/health') {
@@ -27,7 +28,7 @@ function createMcDevAuthenticationMiddleware(applicationConfig) {
27
28
  }));
28
29
  } else {
29
30
  response.setHeader('Content-Type', 'text/html');
30
- response.end(`healthy = true`);
31
+ response.end("healthy = true");
31
32
  }
32
33
  return;
33
34
  }
@@ -35,15 +36,16 @@ function createMcDevAuthenticationMiddleware(applicationConfig) {
35
36
  response.statusCode = 404;
36
37
  response.setHeader('Content-Type', 'application/json');
37
38
  response.end(_JSON$stringify__default["default"]({
38
- 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.`
39
+ 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."
39
40
  }));
40
41
  return;
41
42
  }
42
- if (applicationConfig.env.__DEVELOPMENT__?.oidc?.authorizeUrl) {
43
+ if ((_applicationConfig$en = applicationConfig.env.__DEVELOPMENT__) !== null && _applicationConfig$en !== void 0 && (_applicationConfig$en = _applicationConfig$en.oidc) !== null && _applicationConfig$en !== void 0 && _applicationConfig$en.authorizeUrl) {
43
44
  var _context;
44
45
  // Handle login page for OIDC workflow when developing against a local MC API.
45
46
  if (_startsWithInstanceProperty__default["default"](_context = applicationConfig.env.__DEVELOPMENT__.oidc.authorizeUrl).call(_context, 'http://localhost')) {
46
- if (request.originalUrl?.startsWith('/login/authorize')) {
47
+ var _request$originalUrl;
48
+ if ((_request$originalUrl = request.originalUrl) !== null && _request$originalUrl !== void 0 && _startsWithInstanceProperty__default["default"](_request$originalUrl).call(_request$originalUrl, '/login/authorize')) {
47
49
  if (!isDevAuthenticationMiddlewareDisabled) {
48
50
  // Redirect to the MC API to initiate the authorize flow.
49
51
  const redirectTo = new _URL__default["default"](request.originalUrl, trimTrailingSlash(applicationConfig.env.mcApiUrl));
@@ -6,6 +6,7 @@ const trimTrailingSlash = value => value.replace(/\/$/, '');
6
6
  function createMcDevAuthenticationMiddleware(applicationConfig) {
7
7
  const isDevAuthenticationMiddlewareDisabled = String(applicationConfig.env.disableAuthRoutesOfDevServer) === 'true' || applicationConfig.env.servedByProxy;
8
8
  return (request, response, next) => {
9
+ var _applicationConfig$en;
9
10
  // This endpoint is meant to be used in Cypress tests to ensure
10
11
  // that the primary origin is set to localhost.
11
12
  if (request.originalUrl === '/api/health') {
@@ -17,7 +18,7 @@ function createMcDevAuthenticationMiddleware(applicationConfig) {
17
18
  }));
18
19
  } else {
19
20
  response.setHeader('Content-Type', 'text/html');
20
- response.end(`healthy = true`);
21
+ response.end("healthy = true");
21
22
  }
22
23
  return;
23
24
  }
@@ -25,15 +26,16 @@ function createMcDevAuthenticationMiddleware(applicationConfig) {
25
26
  response.statusCode = 404;
26
27
  response.setHeader('Content-Type', 'application/json');
27
28
  response.end(_JSON$stringify({
28
- 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.`
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."
29
30
  }));
30
31
  return;
31
32
  }
32
- if (applicationConfig.env.__DEVELOPMENT__?.oidc?.authorizeUrl) {
33
+ if ((_applicationConfig$en = applicationConfig.env.__DEVELOPMENT__) !== null && _applicationConfig$en !== void 0 && (_applicationConfig$en = _applicationConfig$en.oidc) !== null && _applicationConfig$en !== void 0 && _applicationConfig$en.authorizeUrl) {
33
34
  var _context;
34
35
  // Handle login page for OIDC workflow when developing against a local MC API.
35
36
  if (_startsWithInstanceProperty(_context = applicationConfig.env.__DEVELOPMENT__.oidc.authorizeUrl).call(_context, 'http://localhost')) {
36
- if (request.originalUrl?.startsWith('/login/authorize')) {
37
+ var _request$originalUrl;
38
+ if ((_request$originalUrl = request.originalUrl) !== null && _request$originalUrl !== void 0 && _startsWithInstanceProperty(_request$originalUrl).call(_request$originalUrl, '/login/authorize')) {
37
39
  if (!isDevAuthenticationMiddlewareDisabled) {
38
40
  // Redirect to the MC API to initiate the authorize flow.
39
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": "24.11.0",
3
+ "version": "24.12.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": "24.11.0"
39
+ "@commercetools-frontend/application-config": "24.12.0"
40
40
  },
41
41
  "engines": {
42
42
  "node": "18.x || 20.x || >=22.0.0"