@commercetools-backend/express 24.10.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.
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
6
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
6
7
  var _Map = require('@babel/runtime-corejs3/core-js-stable/map');
7
8
  var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
8
9
  var jose = require('jose');
@@ -14,6 +15,7 @@ var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-arr
14
15
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
15
16
 
16
17
  var _URL__default = /*#__PURE__*/_interopDefault(_URL);
18
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
17
19
  var _Map__default = /*#__PURE__*/_interopDefault(_Map);
18
20
  var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
19
21
  var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
@@ -79,14 +81,14 @@ const getFirstHeaderValueOrThrow = (headers, headerKey, errorMessage) => {
79
81
 
80
82
  // Assign a session object to the request object.
81
83
  const writeSessionContext = (request, verifiedToken) => {
82
- const publicClaimForProjectKey = `${verifiedToken.iss}/claims/project_key`;
83
- const publicClaimForUserPermissionsKey = `${verifiedToken.iss}/claims/user_permissions`;
84
+ const publicClaimForProjectKey = "".concat(verifiedToken.iss, "/claims/project_key");
85
+ const publicClaimForUserPermissionsKey = "".concat(verifiedToken.iss, "/claims/user_permissions");
84
86
  request.session = {
85
87
  userId: verifiedToken.sub,
86
88
  projectKey: verifiedToken[publicClaimForProjectKey]
87
89
  };
88
90
  const userPermissions = verifiedToken[publicClaimForUserPermissionsKey];
89
- if (Boolean(userPermissions?.length)) {
91
+ if (Boolean(userPermissions === null || userPermissions === void 0 ? void 0 : userPermissions.length)) {
90
92
  request.session.userPermissions = userPermissions;
91
93
  }
92
94
  };
@@ -130,16 +132,16 @@ const throwIfIssuerIsNotAValidUrl = issuer => {
130
132
  try {
131
133
  new _URL__default["default"](issuer);
132
134
  } catch (error) {
133
- throw new Error(`Invalid issuer URL "${issuer}". Expected a valid URL to the Merchant Center API Gateway, or a cloud identifier to one of the available cloud regions. See https://docs.commercetools.com/merchant-center-customizations/concepts/merchant-center-api#hostnames.`);
135
+ throw new Error("Invalid issuer URL \"".concat(issuer, "\". Expected a valid URL to the Merchant Center API Gateway, or a cloud identifier to one of the available cloud regions. See https://docs.commercetools.com/merchant-center-customizations/concepts/merchant-center-api#hostnames."));
134
136
  }
135
137
  };
136
138
  // Validates required option values.
137
139
  const validateRequiredValues = options => {
138
140
  if (!options.audience) {
139
- throw new Error(`Missing required option "audience"`);
141
+ throw new Error("Missing required option \"audience\"");
140
142
  }
141
143
  if (!options.issuer) {
142
- throw new Error(`Missing required option "issuer"`);
144
+ throw new Error("Missing required option \"issuer\"");
143
145
  }
144
146
  };
145
147
  // Attempt to parse the given issuer. If the value is a cloud identifier, it will
@@ -157,17 +159,19 @@ const getConfiguredDefaultIssuer = options => {
157
159
  // If the request path is `/`, do not append it to the audience, otherwise
158
160
  // the token validation might fail because of mismatching audiences.
159
161
  const getConfiguredAudience = (options, requestPath) => {
162
+ var _context;
160
163
  // remove the trailing slash
161
- const url = new _URL__default["default"](`${options.audience.replace(/\/?$/, '')}${requestPath}`);
164
+ const url = new _URL__default["default"](_concatInstanceProperty__default["default"](_context = "".concat(options.audience.replace(/\/?$/, ''))).call(_context, requestPath));
162
165
  switch (options.audiencePolicy) {
163
166
  case 'forward-url-origin':
164
167
  return url.origin;
165
168
  default:
166
169
  {
170
+ var _context2;
167
171
  if (requestPath === '/') {
168
172
  return url.origin;
169
173
  }
170
- return `${url.origin}${url.pathname}`;
174
+ return _concatInstanceProperty__default["default"](_context2 = "".concat(url.origin)).call(_context2, url.pathname);
171
175
  }
172
176
  }
173
177
  };
@@ -177,7 +181,7 @@ function getJwksClientByIssuer(issuer) {
177
181
  if (client) {
178
182
  return client;
179
183
  }
180
- const newClient = jose.createRemoteJWKSet(new _URL__default["default"](`/.well-known/jwks.json`, issuer));
184
+ const newClient = jose.createRemoteJWKSet(new _URL__default["default"]("/.well-known/jwks.json", issuer));
181
185
  jwksClientByIssuer.set(issuer, newClient);
182
186
  return newClient;
183
187
  }
@@ -187,25 +191,27 @@ function createSessionAuthVerifier(options) {
187
191
 
188
192
  // Returns an async HTTP handler.
189
193
  return async request => {
194
+ var _mapCloudIdentifierTo, _request$originalUrl;
190
195
  // Get the cloud identifier header, forwarded by the `/proxy/forward-to` endpoint.
191
- const cloudIdentifierHeader = getFirstHeaderValueOrThrow(request.headers, MC_API_PROXY_HEADERS.CLOUD_IDENTIFIER, `Missing "X-MC-API-Cloud-Identifier" header.`);
192
- let issuer = options.inferIssuer && cloudIdentifierHeader ? mapCloudIdentifierToIssuer(cloudIdentifierHeader) ?? configuredDefaultIssuer : configuredDefaultIssuer;
196
+ const cloudIdentifierHeader = getFirstHeaderValueOrThrow(request.headers, MC_API_PROXY_HEADERS.CLOUD_IDENTIFIER, "Missing \"X-MC-API-Cloud-Identifier\" header.");
197
+ let issuer = options.inferIssuer && cloudIdentifierHeader ? (_mapCloudIdentifierTo = mapCloudIdentifierToIssuer(cloudIdentifierHeader)) !== null && _mapCloudIdentifierTo !== void 0 ? _mapCloudIdentifierTo : configuredDefaultIssuer : configuredDefaultIssuer;
193
198
 
194
199
  // Get the `Accept-version` header, forwarded by the `/proxy/forward-to` endpoint.
195
200
  // The version should be sent by the client making the request, to use the features of v2.
196
- const proxyForwardVersion = getFirstHeaderValueOrThrow(request.headers, MC_API_PROXY_HEADERS.FORWARD_TO_VERSION, `Missing "X-MC-API-Forward-To-Version" header.`);
201
+ const proxyForwardVersion = getFirstHeaderValueOrThrow(request.headers, MC_API_PROXY_HEADERS.FORWARD_TO_VERSION, "Missing \"X-MC-API-Forward-To-Version\" header.");
197
202
  if (proxyForwardVersion === 'v1') {
203
+ var _mapToLegacyIssuer;
198
204
  // Fall back to legacy issuer domains
199
- issuer = mapToLegacyIssuer(cloudIdentifierHeader) ?? issuer;
205
+ issuer = (_mapToLegacyIssuer = mapToLegacyIssuer(cloudIdentifierHeader)) !== null && _mapToLegacyIssuer !== void 0 ? _mapToLegacyIssuer : issuer;
200
206
  }
201
- const requestUrlPath = options.getRequestUrl ? options.getRequestUrl(request) : request.originalUrl ?? request.url;
207
+ const requestUrlPath = options.getRequestUrl ? options.getRequestUrl(request) : (_request$originalUrl = request.originalUrl) !== null && _request$originalUrl !== void 0 ? _request$originalUrl : request.url;
202
208
  if (!requestUrlPath || !_startsWithInstanceProperty__default["default"](requestUrlPath).call(requestUrlPath, '/')) {
203
- throw new Error(`Invalid request URI path "${requestUrlPath}". Please make sure that the "request" object has either a property "originalUrl" or "url". If not, you should implement the "getRequestUrl" function and make sure to return a valid URI path value starting with "/". More info at https://docs.commercetools.com/merchant-center-customizations/concepts/integrate-with-your-own-api#validating-the-json-web-token`);
209
+ throw new Error("Invalid request URI path \"".concat(requestUrlPath, "\". Please make sure that the \"request\" object has either a property \"originalUrl\" or \"url\". If not, you should implement the \"getRequestUrl\" function and make sure to return a valid URI path value starting with \"/\". More info at https://docs.commercetools.com/merchant-center-customizations/concepts/integrate-with-your-own-api#validating-the-json-web-token"));
204
210
  }
205
211
  const audience = getConfiguredAudience(options, requestUrlPath);
206
212
  const authorizationHeader = request.headers['authorization'];
207
213
  if (typeof authorizationHeader !== 'string') {
208
- throw new Error(`Missing "authorization" header`);
214
+ throw new Error("Missing \"authorization\" header");
209
215
  }
210
216
  const exchangeToken = authorizationHeader.replace(/^Bearer (.*)$/, '$1');
211
217
  const jwksClient = getJwksClientByIssuer(issuer);
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
6
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
6
7
  var _Map = require('@babel/runtime-corejs3/core-js-stable/map');
7
8
  var _startsWithInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/starts-with');
8
9
  var jose = require('jose');
@@ -14,6 +15,7 @@ var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-arr
14
15
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
15
16
 
16
17
  var _URL__default = /*#__PURE__*/_interopDefault(_URL);
18
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
17
19
  var _Map__default = /*#__PURE__*/_interopDefault(_Map);
18
20
  var _startsWithInstanceProperty__default = /*#__PURE__*/_interopDefault(_startsWithInstanceProperty);
19
21
  var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
@@ -79,14 +81,14 @@ const getFirstHeaderValueOrThrow = (headers, headerKey, errorMessage) => {
79
81
 
80
82
  // Assign a session object to the request object.
81
83
  const writeSessionContext = (request, verifiedToken) => {
82
- const publicClaimForProjectKey = `${verifiedToken.iss}/claims/project_key`;
83
- const publicClaimForUserPermissionsKey = `${verifiedToken.iss}/claims/user_permissions`;
84
+ const publicClaimForProjectKey = "".concat(verifiedToken.iss, "/claims/project_key");
85
+ const publicClaimForUserPermissionsKey = "".concat(verifiedToken.iss, "/claims/user_permissions");
84
86
  request.session = {
85
87
  userId: verifiedToken.sub,
86
88
  projectKey: verifiedToken[publicClaimForProjectKey]
87
89
  };
88
90
  const userPermissions = verifiedToken[publicClaimForUserPermissionsKey];
89
- if (Boolean(userPermissions?.length)) {
91
+ if (Boolean(userPermissions === null || userPermissions === void 0 ? void 0 : userPermissions.length)) {
90
92
  request.session.userPermissions = userPermissions;
91
93
  }
92
94
  };
@@ -130,16 +132,16 @@ const throwIfIssuerIsNotAValidUrl = issuer => {
130
132
  try {
131
133
  new _URL__default["default"](issuer);
132
134
  } catch (error) {
133
- throw new Error(`Invalid issuer URL "${issuer}". Expected a valid URL to the Merchant Center API Gateway, or a cloud identifier to one of the available cloud regions. See https://docs.commercetools.com/merchant-center-customizations/concepts/merchant-center-api#hostnames.`);
135
+ throw new Error("Invalid issuer URL \"".concat(issuer, "\". Expected a valid URL to the Merchant Center API Gateway, or a cloud identifier to one of the available cloud regions. See https://docs.commercetools.com/merchant-center-customizations/concepts/merchant-center-api#hostnames."));
134
136
  }
135
137
  };
136
138
  // Validates required option values.
137
139
  const validateRequiredValues = options => {
138
140
  if (!options.audience) {
139
- throw new Error(`Missing required option "audience"`);
141
+ throw new Error("Missing required option \"audience\"");
140
142
  }
141
143
  if (!options.issuer) {
142
- throw new Error(`Missing required option "issuer"`);
144
+ throw new Error("Missing required option \"issuer\"");
143
145
  }
144
146
  };
145
147
  // Attempt to parse the given issuer. If the value is a cloud identifier, it will
@@ -157,17 +159,19 @@ const getConfiguredDefaultIssuer = options => {
157
159
  // If the request path is `/`, do not append it to the audience, otherwise
158
160
  // the token validation might fail because of mismatching audiences.
159
161
  const getConfiguredAudience = (options, requestPath) => {
162
+ var _context;
160
163
  // remove the trailing slash
161
- const url = new _URL__default["default"](`${options.audience.replace(/\/?$/, '')}${requestPath}`);
164
+ const url = new _URL__default["default"](_concatInstanceProperty__default["default"](_context = "".concat(options.audience.replace(/\/?$/, ''))).call(_context, requestPath));
162
165
  switch (options.audiencePolicy) {
163
166
  case 'forward-url-origin':
164
167
  return url.origin;
165
168
  default:
166
169
  {
170
+ var _context2;
167
171
  if (requestPath === '/') {
168
172
  return url.origin;
169
173
  }
170
- return `${url.origin}${url.pathname}`;
174
+ return _concatInstanceProperty__default["default"](_context2 = "".concat(url.origin)).call(_context2, url.pathname);
171
175
  }
172
176
  }
173
177
  };
@@ -177,7 +181,7 @@ function getJwksClientByIssuer(issuer) {
177
181
  if (client) {
178
182
  return client;
179
183
  }
180
- const newClient = jose.createRemoteJWKSet(new _URL__default["default"](`/.well-known/jwks.json`, issuer));
184
+ const newClient = jose.createRemoteJWKSet(new _URL__default["default"]("/.well-known/jwks.json", issuer));
181
185
  jwksClientByIssuer.set(issuer, newClient);
182
186
  return newClient;
183
187
  }
@@ -187,25 +191,27 @@ function createSessionAuthVerifier(options) {
187
191
 
188
192
  // Returns an async HTTP handler.
189
193
  return async request => {
194
+ var _mapCloudIdentifierTo, _request$originalUrl;
190
195
  // Get the cloud identifier header, forwarded by the `/proxy/forward-to` endpoint.
191
- const cloudIdentifierHeader = getFirstHeaderValueOrThrow(request.headers, MC_API_PROXY_HEADERS.CLOUD_IDENTIFIER, `Missing "X-MC-API-Cloud-Identifier" header.`);
192
- let issuer = options.inferIssuer && cloudIdentifierHeader ? mapCloudIdentifierToIssuer(cloudIdentifierHeader) ?? configuredDefaultIssuer : configuredDefaultIssuer;
196
+ const cloudIdentifierHeader = getFirstHeaderValueOrThrow(request.headers, MC_API_PROXY_HEADERS.CLOUD_IDENTIFIER, "Missing \"X-MC-API-Cloud-Identifier\" header.");
197
+ let issuer = options.inferIssuer && cloudIdentifierHeader ? (_mapCloudIdentifierTo = mapCloudIdentifierToIssuer(cloudIdentifierHeader)) !== null && _mapCloudIdentifierTo !== void 0 ? _mapCloudIdentifierTo : configuredDefaultIssuer : configuredDefaultIssuer;
193
198
 
194
199
  // Get the `Accept-version` header, forwarded by the `/proxy/forward-to` endpoint.
195
200
  // The version should be sent by the client making the request, to use the features of v2.
196
- const proxyForwardVersion = getFirstHeaderValueOrThrow(request.headers, MC_API_PROXY_HEADERS.FORWARD_TO_VERSION, `Missing "X-MC-API-Forward-To-Version" header.`);
201
+ const proxyForwardVersion = getFirstHeaderValueOrThrow(request.headers, MC_API_PROXY_HEADERS.FORWARD_TO_VERSION, "Missing \"X-MC-API-Forward-To-Version\" header.");
197
202
  if (proxyForwardVersion === 'v1') {
203
+ var _mapToLegacyIssuer;
198
204
  // Fall back to legacy issuer domains
199
- issuer = mapToLegacyIssuer(cloudIdentifierHeader) ?? issuer;
205
+ issuer = (_mapToLegacyIssuer = mapToLegacyIssuer(cloudIdentifierHeader)) !== null && _mapToLegacyIssuer !== void 0 ? _mapToLegacyIssuer : issuer;
200
206
  }
201
- const requestUrlPath = options.getRequestUrl ? options.getRequestUrl(request) : request.originalUrl ?? request.url;
207
+ const requestUrlPath = options.getRequestUrl ? options.getRequestUrl(request) : (_request$originalUrl = request.originalUrl) !== null && _request$originalUrl !== void 0 ? _request$originalUrl : request.url;
202
208
  if (!requestUrlPath || !_startsWithInstanceProperty__default["default"](requestUrlPath).call(requestUrlPath, '/')) {
203
- throw new Error(`Invalid request URI path "${requestUrlPath}". Please make sure that the "request" object has either a property "originalUrl" or "url". If not, you should implement the "getRequestUrl" function and make sure to return a valid URI path value starting with "/". More info at https://docs.commercetools.com/merchant-center-customizations/concepts/integrate-with-your-own-api#validating-the-json-web-token`);
209
+ throw new Error("Invalid request URI path \"".concat(requestUrlPath, "\". Please make sure that the \"request\" object has either a property \"originalUrl\" or \"url\". If not, you should implement the \"getRequestUrl\" function and make sure to return a valid URI path value starting with \"/\". More info at https://docs.commercetools.com/merchant-center-customizations/concepts/integrate-with-your-own-api#validating-the-json-web-token"));
204
210
  }
205
211
  const audience = getConfiguredAudience(options, requestUrlPath);
206
212
  const authorizationHeader = request.headers['authorization'];
207
213
  if (typeof authorizationHeader !== 'string') {
208
- throw new Error(`Missing "authorization" header`);
214
+ throw new Error("Missing \"authorization\" header");
209
215
  }
210
216
  const exchangeToken = authorizationHeader.replace(/^Bearer (.*)$/, '$1');
211
217
  const jwksClient = getJwksClientByIssuer(issuer);
@@ -1,4 +1,5 @@
1
1
  import _URL from '@babel/runtime-corejs3/core-js-stable/url';
2
+ import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
2
3
  import _Map from '@babel/runtime-corejs3/core-js-stable/map';
3
4
  import _startsWithInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/starts-with';
4
5
  import { jwtVerify, createRemoteJWKSet } from 'jose';
@@ -66,14 +67,14 @@ const getFirstHeaderValueOrThrow = (headers, headerKey, errorMessage) => {
66
67
 
67
68
  // Assign a session object to the request object.
68
69
  const writeSessionContext = (request, verifiedToken) => {
69
- const publicClaimForProjectKey = `${verifiedToken.iss}/claims/project_key`;
70
- const publicClaimForUserPermissionsKey = `${verifiedToken.iss}/claims/user_permissions`;
70
+ const publicClaimForProjectKey = "".concat(verifiedToken.iss, "/claims/project_key");
71
+ const publicClaimForUserPermissionsKey = "".concat(verifiedToken.iss, "/claims/user_permissions");
71
72
  request.session = {
72
73
  userId: verifiedToken.sub,
73
74
  projectKey: verifiedToken[publicClaimForProjectKey]
74
75
  };
75
76
  const userPermissions = verifiedToken[publicClaimForUserPermissionsKey];
76
- if (Boolean(userPermissions?.length)) {
77
+ if (Boolean(userPermissions === null || userPermissions === void 0 ? void 0 : userPermissions.length)) {
77
78
  request.session.userPermissions = userPermissions;
78
79
  }
79
80
  };
@@ -117,16 +118,16 @@ const throwIfIssuerIsNotAValidUrl = issuer => {
117
118
  try {
118
119
  new _URL(issuer);
119
120
  } catch (error) {
120
- throw new Error(`Invalid issuer URL "${issuer}". Expected a valid URL to the Merchant Center API Gateway, or a cloud identifier to one of the available cloud regions. See https://docs.commercetools.com/merchant-center-customizations/concepts/merchant-center-api#hostnames.`);
121
+ throw new Error("Invalid issuer URL \"".concat(issuer, "\". Expected a valid URL to the Merchant Center API Gateway, or a cloud identifier to one of the available cloud regions. See https://docs.commercetools.com/merchant-center-customizations/concepts/merchant-center-api#hostnames."));
121
122
  }
122
123
  };
123
124
  // Validates required option values.
124
125
  const validateRequiredValues = options => {
125
126
  if (!options.audience) {
126
- throw new Error(`Missing required option "audience"`);
127
+ throw new Error("Missing required option \"audience\"");
127
128
  }
128
129
  if (!options.issuer) {
129
- throw new Error(`Missing required option "issuer"`);
130
+ throw new Error("Missing required option \"issuer\"");
130
131
  }
131
132
  };
132
133
  // Attempt to parse the given issuer. If the value is a cloud identifier, it will
@@ -144,17 +145,19 @@ const getConfiguredDefaultIssuer = options => {
144
145
  // If the request path is `/`, do not append it to the audience, otherwise
145
146
  // the token validation might fail because of mismatching audiences.
146
147
  const getConfiguredAudience = (options, requestPath) => {
148
+ var _context;
147
149
  // remove the trailing slash
148
- const url = new _URL(`${options.audience.replace(/\/?$/, '')}${requestPath}`);
150
+ const url = new _URL(_concatInstanceProperty(_context = "".concat(options.audience.replace(/\/?$/, ''))).call(_context, requestPath));
149
151
  switch (options.audiencePolicy) {
150
152
  case 'forward-url-origin':
151
153
  return url.origin;
152
154
  default:
153
155
  {
156
+ var _context2;
154
157
  if (requestPath === '/') {
155
158
  return url.origin;
156
159
  }
157
- return `${url.origin}${url.pathname}`;
160
+ return _concatInstanceProperty(_context2 = "".concat(url.origin)).call(_context2, url.pathname);
158
161
  }
159
162
  }
160
163
  };
@@ -164,7 +167,7 @@ function getJwksClientByIssuer(issuer) {
164
167
  if (client) {
165
168
  return client;
166
169
  }
167
- const newClient = createRemoteJWKSet(new _URL(`/.well-known/jwks.json`, issuer));
170
+ const newClient = createRemoteJWKSet(new _URL("/.well-known/jwks.json", issuer));
168
171
  jwksClientByIssuer.set(issuer, newClient);
169
172
  return newClient;
170
173
  }
@@ -174,25 +177,27 @@ function createSessionAuthVerifier(options) {
174
177
 
175
178
  // Returns an async HTTP handler.
176
179
  return async request => {
180
+ var _mapCloudIdentifierTo, _request$originalUrl;
177
181
  // Get the cloud identifier header, forwarded by the `/proxy/forward-to` endpoint.
178
- const cloudIdentifierHeader = getFirstHeaderValueOrThrow(request.headers, MC_API_PROXY_HEADERS.CLOUD_IDENTIFIER, `Missing "X-MC-API-Cloud-Identifier" header.`);
179
- let issuer = options.inferIssuer && cloudIdentifierHeader ? mapCloudIdentifierToIssuer(cloudIdentifierHeader) ?? configuredDefaultIssuer : configuredDefaultIssuer;
182
+ const cloudIdentifierHeader = getFirstHeaderValueOrThrow(request.headers, MC_API_PROXY_HEADERS.CLOUD_IDENTIFIER, "Missing \"X-MC-API-Cloud-Identifier\" header.");
183
+ let issuer = options.inferIssuer && cloudIdentifierHeader ? (_mapCloudIdentifierTo = mapCloudIdentifierToIssuer(cloudIdentifierHeader)) !== null && _mapCloudIdentifierTo !== void 0 ? _mapCloudIdentifierTo : configuredDefaultIssuer : configuredDefaultIssuer;
180
184
 
181
185
  // Get the `Accept-version` header, forwarded by the `/proxy/forward-to` endpoint.
182
186
  // The version should be sent by the client making the request, to use the features of v2.
183
- const proxyForwardVersion = getFirstHeaderValueOrThrow(request.headers, MC_API_PROXY_HEADERS.FORWARD_TO_VERSION, `Missing "X-MC-API-Forward-To-Version" header.`);
187
+ const proxyForwardVersion = getFirstHeaderValueOrThrow(request.headers, MC_API_PROXY_HEADERS.FORWARD_TO_VERSION, "Missing \"X-MC-API-Forward-To-Version\" header.");
184
188
  if (proxyForwardVersion === 'v1') {
189
+ var _mapToLegacyIssuer;
185
190
  // Fall back to legacy issuer domains
186
- issuer = mapToLegacyIssuer(cloudIdentifierHeader) ?? issuer;
191
+ issuer = (_mapToLegacyIssuer = mapToLegacyIssuer(cloudIdentifierHeader)) !== null && _mapToLegacyIssuer !== void 0 ? _mapToLegacyIssuer : issuer;
187
192
  }
188
- const requestUrlPath = options.getRequestUrl ? options.getRequestUrl(request) : request.originalUrl ?? request.url;
193
+ const requestUrlPath = options.getRequestUrl ? options.getRequestUrl(request) : (_request$originalUrl = request.originalUrl) !== null && _request$originalUrl !== void 0 ? _request$originalUrl : request.url;
189
194
  if (!requestUrlPath || !_startsWithInstanceProperty(requestUrlPath).call(requestUrlPath, '/')) {
190
- throw new Error(`Invalid request URI path "${requestUrlPath}". Please make sure that the "request" object has either a property "originalUrl" or "url". If not, you should implement the "getRequestUrl" function and make sure to return a valid URI path value starting with "/". More info at https://docs.commercetools.com/merchant-center-customizations/concepts/integrate-with-your-own-api#validating-the-json-web-token`);
195
+ throw new Error("Invalid request URI path \"".concat(requestUrlPath, "\". Please make sure that the \"request\" object has either a property \"originalUrl\" or \"url\". If not, you should implement the \"getRequestUrl\" function and make sure to return a valid URI path value starting with \"/\". More info at https://docs.commercetools.com/merchant-center-customizations/concepts/integrate-with-your-own-api#validating-the-json-web-token"));
191
196
  }
192
197
  const audience = getConfiguredAudience(options, requestUrlPath);
193
198
  const authorizationHeader = request.headers['authorization'];
194
199
  if (typeof authorizationHeader !== 'string') {
195
- throw new Error(`Missing "authorization" header`);
200
+ throw new Error("Missing \"authorization\" header");
196
201
  }
197
202
  const exchangeToken = authorizationHeader.replace(/^Bearer (.*)$/, '$1');
198
203
  const jwksClient = getJwksClientByIssuer(issuer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-backend/express",
3
- "version": "24.10.0",
3
+ "version": "24.12.0",
4
4
  "description": "Zero-config HTTP server as Express.js to facilitate development",
5
5
  "bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
6
6
  "repository": {