@commercetools-backend/express 20.10.4 → 20.12.3
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.
|
@@ -62,12 +62,12 @@ var getFirstOrThrow = function getFirstOrThrow(value, errorMessage) {
|
|
|
62
62
|
throw new Error(errorMessage);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
return _Array$isArray__default[
|
|
65
|
+
return _Array$isArray__default["default"](value) ? value[0] : value;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default[
|
|
68
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
69
69
|
|
|
70
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context4; _forEachInstanceProperty__default[
|
|
70
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context4; _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source), true)).call(_context4, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context5; _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(source))).call(_context5, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
71
71
|
var decodedTokenKey = 'decoded_token'; // Assign a session object to the request object.
|
|
72
72
|
|
|
73
73
|
var writeSessionContext = function writeSessionContext(request) {
|
|
@@ -130,7 +130,7 @@ var mapToLegacyIssuer = function mapToLegacyIssuer(cloudIdentifier) {
|
|
|
130
130
|
|
|
131
131
|
var throwIfIssuerIsNotAValidUrl = function throwIfIssuerIsNotAValidUrl(issuer) {
|
|
132
132
|
try {
|
|
133
|
-
new _URL__default[
|
|
133
|
+
new _URL__default["default"](issuer);
|
|
134
134
|
} catch (error) {
|
|
135
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/custom-applications/main-concepts/api-gateway#hostnames."));
|
|
136
136
|
}
|
|
@@ -167,13 +167,13 @@ var getConfiguredAudience = function getConfiguredAudience(options, requestPath)
|
|
|
167
167
|
var _context, _context2;
|
|
168
168
|
|
|
169
169
|
// remove the trailing slash
|
|
170
|
-
var url = new _URL__default[
|
|
170
|
+
var url = new _URL__default["default"](_concatInstanceProperty__default["default"](_context = "".concat(options.audience.replace(/\/?$/, ''))).call(_context, requestPath));
|
|
171
171
|
|
|
172
172
|
if (requestPath === '/') {
|
|
173
173
|
return url.origin;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
return _concatInstanceProperty__default[
|
|
176
|
+
return _concatInstanceProperty__default["default"](_context2 = "".concat(url.origin)).call(_context2, url.pathname);
|
|
177
177
|
};
|
|
178
178
|
|
|
179
179
|
function createSessionAuthVerifier(options) {
|
|
@@ -181,12 +181,12 @@ function createSessionAuthVerifier(options) {
|
|
|
181
181
|
var configuredDefaultIssuer = getConfiguredDefaultIssuer(options); // Returns an async HTTP handler.
|
|
182
182
|
|
|
183
183
|
return /*#__PURE__*/function () {
|
|
184
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default[
|
|
184
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(request, response) {
|
|
185
185
|
var _mapCloudIdentifierTo, _request$originalUrl;
|
|
186
186
|
|
|
187
187
|
var cloudIdentifierHeader, issuer, proxyForwardVersion, _mapToLegacyIssuer, requestUrlPath, audience;
|
|
188
188
|
|
|
189
|
-
return _regeneratorRuntime__default[
|
|
189
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context3) {
|
|
190
190
|
while (1) {
|
|
191
191
|
switch (_context3.prev = _context3.next) {
|
|
192
192
|
case 0:
|
|
@@ -205,11 +205,11 @@ function createSessionAuthVerifier(options) {
|
|
|
205
205
|
|
|
206
206
|
requestUrlPath = (_request$originalUrl = request.originalUrl) !== null && _request$originalUrl !== void 0 ? _request$originalUrl : request.url;
|
|
207
207
|
audience = getConfiguredAudience(options, requestUrlPath);
|
|
208
|
-
return _context3.abrupt("return", new _Promise__default[
|
|
209
|
-
expressJwtMiddleware__default[
|
|
208
|
+
return _context3.abrupt("return", new _Promise__default["default"](function (resolve, reject) {
|
|
209
|
+
expressJwtMiddleware__default["default"]({
|
|
210
210
|
// Dynamically provide a signing key based on the kid in the header
|
|
211
211
|
// and the singing keys provided by the JWKS endpoint
|
|
212
|
-
secret: jwksRsa__default[
|
|
212
|
+
secret: jwksRsa__default["default"].expressJwtSecret(_objectSpread(_objectSpread({
|
|
213
213
|
// Default options
|
|
214
214
|
cache: true,
|
|
215
215
|
rateLimit: true,
|
|
@@ -253,8 +253,8 @@ function createSessionAuthVerifier(options) {
|
|
|
253
253
|
function createSessionMiddleware(options) {
|
|
254
254
|
var sessionAuthVerifier = createSessionAuthVerifier(options);
|
|
255
255
|
return /*#__PURE__*/function () {
|
|
256
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default[
|
|
257
|
-
return _regeneratorRuntime__default[
|
|
256
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(request, response, next) {
|
|
257
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
258
258
|
while (1) {
|
|
259
259
|
switch (_context.prev = _context.next) {
|
|
260
260
|
case 0:
|
|
@@ -62,12 +62,12 @@ var getFirstOrThrow = function getFirstOrThrow(value, errorMessage) {
|
|
|
62
62
|
throw new Error(errorMessage);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
return _Array$isArray__default[
|
|
65
|
+
return _Array$isArray__default["default"](value) ? value[0] : value;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default[
|
|
68
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
69
69
|
|
|
70
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context4; _forEachInstanceProperty__default[
|
|
70
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context4; _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source), true)).call(_context4, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context5; _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(source))).call(_context5, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
71
71
|
var decodedTokenKey = 'decoded_token'; // Assign a session object to the request object.
|
|
72
72
|
|
|
73
73
|
var writeSessionContext = function writeSessionContext(request) {
|
|
@@ -130,7 +130,7 @@ var mapToLegacyIssuer = function mapToLegacyIssuer(cloudIdentifier) {
|
|
|
130
130
|
|
|
131
131
|
var throwIfIssuerIsNotAValidUrl = function throwIfIssuerIsNotAValidUrl(issuer) {
|
|
132
132
|
try {
|
|
133
|
-
new _URL__default[
|
|
133
|
+
new _URL__default["default"](issuer);
|
|
134
134
|
} catch (error) {
|
|
135
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/custom-applications/main-concepts/api-gateway#hostnames."));
|
|
136
136
|
}
|
|
@@ -167,13 +167,13 @@ var getConfiguredAudience = function getConfiguredAudience(options, requestPath)
|
|
|
167
167
|
var _context, _context2;
|
|
168
168
|
|
|
169
169
|
// remove the trailing slash
|
|
170
|
-
var url = new _URL__default[
|
|
170
|
+
var url = new _URL__default["default"](_concatInstanceProperty__default["default"](_context = "".concat(options.audience.replace(/\/?$/, ''))).call(_context, requestPath));
|
|
171
171
|
|
|
172
172
|
if (requestPath === '/') {
|
|
173
173
|
return url.origin;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
return _concatInstanceProperty__default[
|
|
176
|
+
return _concatInstanceProperty__default["default"](_context2 = "".concat(url.origin)).call(_context2, url.pathname);
|
|
177
177
|
};
|
|
178
178
|
|
|
179
179
|
function createSessionAuthVerifier(options) {
|
|
@@ -181,12 +181,12 @@ function createSessionAuthVerifier(options) {
|
|
|
181
181
|
var configuredDefaultIssuer = getConfiguredDefaultIssuer(options); // Returns an async HTTP handler.
|
|
182
182
|
|
|
183
183
|
return /*#__PURE__*/function () {
|
|
184
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default[
|
|
184
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(request, response) {
|
|
185
185
|
var _mapCloudIdentifierTo, _request$originalUrl;
|
|
186
186
|
|
|
187
187
|
var cloudIdentifierHeader, issuer, proxyForwardVersion, _mapToLegacyIssuer, requestUrlPath, audience;
|
|
188
188
|
|
|
189
|
-
return _regeneratorRuntime__default[
|
|
189
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context3) {
|
|
190
190
|
while (1) {
|
|
191
191
|
switch (_context3.prev = _context3.next) {
|
|
192
192
|
case 0:
|
|
@@ -205,11 +205,11 @@ function createSessionAuthVerifier(options) {
|
|
|
205
205
|
|
|
206
206
|
requestUrlPath = (_request$originalUrl = request.originalUrl) !== null && _request$originalUrl !== void 0 ? _request$originalUrl : request.url;
|
|
207
207
|
audience = getConfiguredAudience(options, requestUrlPath);
|
|
208
|
-
return _context3.abrupt("return", new _Promise__default[
|
|
209
|
-
expressJwtMiddleware__default[
|
|
208
|
+
return _context3.abrupt("return", new _Promise__default["default"](function (resolve, reject) {
|
|
209
|
+
expressJwtMiddleware__default["default"]({
|
|
210
210
|
// Dynamically provide a signing key based on the kid in the header
|
|
211
211
|
// and the singing keys provided by the JWKS endpoint
|
|
212
|
-
secret: jwksRsa__default[
|
|
212
|
+
secret: jwksRsa__default["default"].expressJwtSecret(_objectSpread(_objectSpread({
|
|
213
213
|
// Default options
|
|
214
214
|
cache: true,
|
|
215
215
|
rateLimit: true,
|
|
@@ -253,8 +253,8 @@ function createSessionAuthVerifier(options) {
|
|
|
253
253
|
function createSessionMiddleware(options) {
|
|
254
254
|
var sessionAuthVerifier = createSessionAuthVerifier(options);
|
|
255
255
|
return /*#__PURE__*/function () {
|
|
256
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default[
|
|
257
|
-
return _regeneratorRuntime__default[
|
|
256
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(request, response, next) {
|
|
257
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
258
258
|
while (1) {
|
|
259
259
|
switch (_context.prev = _context.next) {
|
|
260
260
|
case 0:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-backend/express",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.12.3",
|
|
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": {
|
|
@@ -11,24 +11,22 @@
|
|
|
11
11
|
"homepage": "https://docs.commercetools.com/custom-applications",
|
|
12
12
|
"keywords": ["javascript", "nodejs", "express", "http", "server", "toolkit"],
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"private": false,
|
|
15
14
|
"publishConfig": {
|
|
16
15
|
"access": "public"
|
|
17
16
|
},
|
|
18
|
-
"scripts": {},
|
|
19
17
|
"main": "dist/commercetools-backend-express.cjs.js",
|
|
20
18
|
"module": "dist/commercetools-backend-express.esm.js",
|
|
21
19
|
"files": ["dist", "package.json", "LICENSE", "README.md"],
|
|
22
20
|
"dependencies": {
|
|
23
|
-
"@babel/runtime": "7.
|
|
24
|
-
"@babel/runtime-corejs3": "7.
|
|
25
|
-
"@types/node": "
|
|
21
|
+
"@babel/runtime": "7.16.5",
|
|
22
|
+
"@babel/runtime-corejs3": "7.16.5",
|
|
23
|
+
"@types/node": "16.11.14",
|
|
26
24
|
"express": "4.17.1",
|
|
27
25
|
"express-jwt": "6.1.0",
|
|
28
26
|
"jwks-rsa": "2.0.5"
|
|
29
27
|
},
|
|
30
28
|
"devDependencies": {
|
|
31
29
|
"jose": "2.0.5",
|
|
32
|
-
"msw": "0.
|
|
30
|
+
"msw": "0.36.3"
|
|
33
31
|
}
|
|
34
32
|
}
|