@verdaccio/middleware 9.0.0-next-9.3 → 9.0.0-next-9.4
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.
- package/build/_virtual/_rolldown/runtime.js +23 -0
- package/build/index.js +60 -221
- package/build/index.mjs +22 -0
- package/build/middlewares/allow.js +42 -50
- package/build/middlewares/allow.js.map +1 -1
- package/build/middlewares/allow.mjs +44 -0
- package/build/middlewares/allow.mjs.map +1 -0
- package/build/middlewares/antiLoop.d.ts +2 -2
- package/build/middlewares/antiLoop.js +22 -40
- package/build/middlewares/antiLoop.js.map +1 -1
- package/build/middlewares/antiLoop.mjs +25 -0
- package/build/middlewares/antiLoop.mjs.map +1 -0
- package/build/middlewares/api_urls.js +66 -59
- package/build/middlewares/api_urls.js.map +1 -1
- package/build/middlewares/api_urls.mjs +59 -0
- package/build/middlewares/api_urls.mjs.map +1 -0
- package/build/middlewares/dotfiles.d.ts +1 -1
- package/build/middlewares/dotfiles.js +25 -28
- package/build/middlewares/dotfiles.js.map +1 -1
- package/build/middlewares/dotfiles.mjs +27 -0
- package/build/middlewares/dotfiles.mjs.map +1 -0
- package/build/middlewares/encode-pkg.d.ts +1 -1
- package/build/middlewares/encode-pkg.js +20 -36
- package/build/middlewares/encode-pkg.js.map +1 -1
- package/build/middlewares/encode-pkg.mjs +22 -0
- package/build/middlewares/encode-pkg.mjs.map +1 -0
- package/build/middlewares/error.d.ts +3 -3
- package/build/middlewares/error.js +53 -71
- package/build/middlewares/error.js.map +1 -1
- package/build/middlewares/error.mjs +53 -0
- package/build/middlewares/error.mjs.map +1 -0
- package/build/middlewares/final.d.ts +2 -2
- package/build/middlewares/final.js +46 -57
- package/build/middlewares/final.js.map +1 -1
- package/build/middlewares/final.mjs +46 -0
- package/build/middlewares/final.mjs.map +1 -0
- package/build/middlewares/json.d.ts +1 -1
- package/build/middlewares/json.js +8 -11
- package/build/middlewares/json.js.map +1 -1
- package/build/middlewares/json.mjs +10 -0
- package/build/middlewares/json.mjs.map +1 -0
- package/build/middlewares/log.d.ts +1 -1
- package/build/middlewares/log.js +97 -125
- package/build/middlewares/log.js.map +1 -1
- package/build/middlewares/log.mjs +96 -0
- package/build/middlewares/log.mjs.map +1 -0
- package/build/middlewares/make-url-relative.d.ts +1 -1
- package/build/middlewares/make-url-relative.js +26 -41
- package/build/middlewares/make-url-relative.js.map +1 -1
- package/build/middlewares/make-url-relative.mjs +28 -0
- package/build/middlewares/make-url-relative.mjs.map +1 -0
- package/build/middlewares/match.js +8 -13
- package/build/middlewares/match.js.map +1 -1
- package/build/middlewares/match.mjs +11 -0
- package/build/middlewares/match.mjs.map +1 -0
- package/build/middlewares/media.js +15 -19
- package/build/middlewares/media.js.map +1 -1
- package/build/middlewares/media.mjs +17 -0
- package/build/middlewares/media.mjs.map +1 -0
- package/build/middlewares/rate-limit.d.ts +2 -2
- package/build/middlewares/rate-limit.js +8 -10
- package/build/middlewares/rate-limit.js.map +1 -1
- package/build/middlewares/rate-limit.mjs +9 -0
- package/build/middlewares/rate-limit.mjs.map +1 -0
- package/build/middlewares/request-options.d.ts +2 -2
- package/build/middlewares/request-options.js +18 -27
- package/build/middlewares/request-options.js.map +1 -1
- package/build/middlewares/request-options.mjs +19 -0
- package/build/middlewares/request-options.mjs.map +1 -0
- package/build/middlewares/user-agent.d.ts +1 -1
- package/build/middlewares/user-agent.js +11 -12
- package/build/middlewares/user-agent.js.map +1 -1
- package/build/middlewares/user-agent.mjs +13 -0
- package/build/middlewares/user-agent.mjs.map +1 -0
- package/build/middlewares/validation.d.ts +1 -1
- package/build/middlewares/validation.js +11 -18
- package/build/middlewares/validation.js.map +1 -1
- package/build/middlewares/validation.mjs +14 -0
- package/build/middlewares/validation.mjs.map +1 -0
- package/build/middlewares/web/index.js +4 -35
- package/build/middlewares/web/index.mjs +4 -0
- package/build/middlewares/web/render-web.d.ts +1 -1
- package/build/middlewares/web/render-web.js +80 -109
- package/build/middlewares/web/render-web.js.map +1 -1
- package/build/middlewares/web/render-web.mjs +79 -0
- package/build/middlewares/web/render-web.mjs.map +1 -0
- package/build/middlewares/web/security.js +29 -41
- package/build/middlewares/web/security.js.map +1 -1
- package/build/middlewares/web/security.mjs +30 -0
- package/build/middlewares/web/security.mjs.map +1 -0
- package/build/middlewares/web/utils/manifest.js +17 -18
- package/build/middlewares/web/utils/manifest.js.map +1 -1
- package/build/middlewares/web/utils/manifest.mjs +21 -0
- package/build/middlewares/web/utils/manifest.mjs.map +1 -0
- package/build/middlewares/web/utils/renderHTML.d.ts +5 -5
- package/build/middlewares/web/utils/renderHTML.js +109 -136
- package/build/middlewares/web/utils/renderHTML.js.map +1 -1
- package/build/middlewares/web/utils/renderHTML.mjs +113 -0
- package/build/middlewares/web/utils/renderHTML.mjs.map +1 -0
- package/build/middlewares/web/utils/template.d.ts +2 -2
- package/build/middlewares/web/utils/template.js +19 -20
- package/build/middlewares/web/utils/template.js.map +1 -1
- package/build/middlewares/web/utils/template.mjs +35 -0
- package/build/middlewares/web/utils/template.mjs.map +1 -0
- package/build/middlewares/web/utils/web-utils.js +17 -18
- package/build/middlewares/web/utils/web-utils.js.map +1 -1
- package/build/middlewares/web/utils/web-utils.mjs +18 -0
- package/build/middlewares/web/utils/web-utils.mjs.map +1 -0
- package/build/middlewares/web/web-api.d.ts +1 -2
- package/build/middlewares/web/web-api.js +18 -27
- package/build/middlewares/web/web-api.js.map +1 -1
- package/build/middlewares/web/web-api.mjs +19 -0
- package/build/middlewares/web/web-api.mjs.map +1 -0
- package/build/middlewares/web/web-middleware.js +16 -23
- package/build/middlewares/web/web-middleware.js.map +1 -1
- package/build/middlewares/web/web-middleware.mjs +16 -0
- package/build/middlewares/web/web-middleware.mjs.map +1 -0
- package/build/middlewares/web/web-urls.js +28 -29
- package/build/middlewares/web/web-urls.js.map +1 -1
- package/build/middlewares/web/web-urls.mjs +32 -0
- package/build/middlewares/web/web-urls.mjs.map +1 -0
- package/build/types.d.ts +2 -2
- package/package.json +22 -11
- package/build/index.js.map +0 -1
- package/build/middlewares/web/index.js.map +0 -1
- package/build/types.js +0 -6
- package/build/types.js.map +0 -1
|
@@ -1,61 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}({});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}({});
|
|
33
|
-
let PACKAGE_API_ENDPOINTS = exports.PACKAGE_API_ENDPOINTS = /*#__PURE__*/function (PACKAGE_API_ENDPOINTS) {
|
|
34
|
-
PACKAGE_API_ENDPOINTS["get_package_by_version"] = "/:package{/:version}";
|
|
35
|
-
PACKAGE_API_ENDPOINTS["get_package_tarball"] = "/:package/-/:filename";
|
|
36
|
-
return PACKAGE_API_ENDPOINTS;
|
|
37
|
-
}({});
|
|
38
|
-
let DIST_TAGS_API_ENDPOINTS = exports.DIST_TAGS_API_ENDPOINTS = /*#__PURE__*/function (DIST_TAGS_API_ENDPOINTS) {
|
|
39
|
-
DIST_TAGS_API_ENDPOINTS["tagging"] = "/:package/:tag";
|
|
40
|
-
DIST_TAGS_API_ENDPOINTS["tagging_package"] = "/-/package/:package/dist-tags/:tag";
|
|
41
|
-
DIST_TAGS_API_ENDPOINTS["get_dist_tags"] = "/-/package/:package/dist-tags";
|
|
42
|
-
return DIST_TAGS_API_ENDPOINTS;
|
|
43
|
-
}({});
|
|
44
|
-
let PROFILE_API_ENDPOINTS = exports.PROFILE_API_ENDPOINTS = /*#__PURE__*/function (PROFILE_API_ENDPOINTS) {
|
|
45
|
-
PROFILE_API_ENDPOINTS["get_profile"] = "/-/npm/v1/user";
|
|
46
|
-
return PROFILE_API_ENDPOINTS;
|
|
47
|
-
}({});
|
|
48
|
-
let TOKEN_API_ENDPOINTS = exports.TOKEN_API_ENDPOINTS = /*#__PURE__*/function (TOKEN_API_ENDPOINTS) {
|
|
49
|
-
TOKEN_API_ENDPOINTS["get_tokens"] = "/-/npm/v1/tokens";
|
|
50
|
-
TOKEN_API_ENDPOINTS["delete_token"] = "/-/npm/v1/tokens/token/:tokenKey";
|
|
51
|
-
return TOKEN_API_ENDPOINTS;
|
|
52
|
-
}({});
|
|
53
|
-
let LOGIN_API_ENDPOINTS = exports.LOGIN_API_ENDPOINTS = /*#__PURE__*/function (LOGIN_API_ENDPOINTS) {
|
|
54
|
-
LOGIN_API_ENDPOINTS["login"] = "/-/v1/login";
|
|
55
|
-
LOGIN_API_ENDPOINTS["login_cli"] = "/-/v1/login_cli";
|
|
56
|
-
LOGIN_API_ENDPOINTS["login_cli_session"] = "/-/v1/login_cli/:sessionId";
|
|
57
|
-
LOGIN_API_ENDPOINTS["login_done"] = "/-/v1/done";
|
|
58
|
-
LOGIN_API_ENDPOINTS["login_done_session"] = "/-/v1/done/:sessionId";
|
|
59
|
-
return LOGIN_API_ENDPOINTS;
|
|
1
|
+
//#region src/middlewares/api_urls.ts
|
|
2
|
+
var USER_API_ENDPOINTS = /* @__PURE__ */ function(USER_API_ENDPOINTS) {
|
|
3
|
+
USER_API_ENDPOINTS["whoami"] = "/-/whoami";
|
|
4
|
+
USER_API_ENDPOINTS["get_user"] = "/-/user/:org_couchdb_user";
|
|
5
|
+
USER_API_ENDPOINTS["add_user"] = "/-/user/:org_couchdb_user{/:_rev}{/:revision}";
|
|
6
|
+
USER_API_ENDPOINTS["user_token"] = "/-/user/token/{*subject}";
|
|
7
|
+
return USER_API_ENDPOINTS;
|
|
8
|
+
}({});
|
|
9
|
+
var STARS_API_ENDPOINTS = /* @__PURE__ */ function(STARS_API_ENDPOINTS) {
|
|
10
|
+
STARS_API_ENDPOINTS["get_user_starred_packages"] = "/-/_view/starredByUser";
|
|
11
|
+
return STARS_API_ENDPOINTS;
|
|
12
|
+
}({});
|
|
13
|
+
var SEARCH_API_ENDPOINTS = /* @__PURE__ */ function(SEARCH_API_ENDPOINTS) {
|
|
14
|
+
SEARCH_API_ENDPOINTS["search"] = "/-/v1/search";
|
|
15
|
+
SEARCH_API_ENDPOINTS["deprecated_search"] = "/-/all{/:since}";
|
|
16
|
+
return SEARCH_API_ENDPOINTS;
|
|
17
|
+
}({});
|
|
18
|
+
var PUBLISH_API_ENDPOINTS = /* @__PURE__ */ function(PUBLISH_API_ENDPOINTS) {
|
|
19
|
+
PUBLISH_API_ENDPOINTS["add_package"] = "/:package";
|
|
20
|
+
PUBLISH_API_ENDPOINTS["publish_package"] = "/:package/-rev/:revision";
|
|
21
|
+
PUBLISH_API_ENDPOINTS["remove_tarball"] = "/:package/-/:filename/-rev/:revision";
|
|
22
|
+
return PUBLISH_API_ENDPOINTS;
|
|
23
|
+
}({});
|
|
24
|
+
var PING_API_ENDPOINTS = /* @__PURE__ */ function(PING_API_ENDPOINTS) {
|
|
25
|
+
PING_API_ENDPOINTS["ping"] = "/-/ping";
|
|
26
|
+
return PING_API_ENDPOINTS;
|
|
27
|
+
}({});
|
|
28
|
+
var PACKAGE_API_ENDPOINTS = /* @__PURE__ */ function(PACKAGE_API_ENDPOINTS) {
|
|
29
|
+
PACKAGE_API_ENDPOINTS["get_package_by_version"] = "/:package{/:version}";
|
|
30
|
+
PACKAGE_API_ENDPOINTS["get_package_tarball"] = "/:package/-/:filename";
|
|
31
|
+
return PACKAGE_API_ENDPOINTS;
|
|
60
32
|
}({});
|
|
33
|
+
var DIST_TAGS_API_ENDPOINTS = /* @__PURE__ */ function(DIST_TAGS_API_ENDPOINTS) {
|
|
34
|
+
DIST_TAGS_API_ENDPOINTS["tagging"] = "/:package/:tag";
|
|
35
|
+
DIST_TAGS_API_ENDPOINTS["tagging_package"] = "/-/package/:package/dist-tags/:tag";
|
|
36
|
+
DIST_TAGS_API_ENDPOINTS["get_dist_tags"] = "/-/package/:package/dist-tags";
|
|
37
|
+
return DIST_TAGS_API_ENDPOINTS;
|
|
38
|
+
}({});
|
|
39
|
+
var PROFILE_API_ENDPOINTS = /* @__PURE__ */ function(PROFILE_API_ENDPOINTS) {
|
|
40
|
+
PROFILE_API_ENDPOINTS["get_profile"] = "/-/npm/v1/user";
|
|
41
|
+
return PROFILE_API_ENDPOINTS;
|
|
42
|
+
}({});
|
|
43
|
+
var TOKEN_API_ENDPOINTS = /* @__PURE__ */ function(TOKEN_API_ENDPOINTS) {
|
|
44
|
+
TOKEN_API_ENDPOINTS["get_tokens"] = "/-/npm/v1/tokens";
|
|
45
|
+
TOKEN_API_ENDPOINTS["delete_token"] = "/-/npm/v1/tokens/token/:tokenKey";
|
|
46
|
+
return TOKEN_API_ENDPOINTS;
|
|
47
|
+
}({});
|
|
48
|
+
var LOGIN_API_ENDPOINTS = /* @__PURE__ */ function(LOGIN_API_ENDPOINTS) {
|
|
49
|
+
LOGIN_API_ENDPOINTS["login"] = "/-/v1/login";
|
|
50
|
+
LOGIN_API_ENDPOINTS["login_cli"] = "/-/v1/login_cli";
|
|
51
|
+
LOGIN_API_ENDPOINTS["login_cli_session"] = "/-/v1/login_cli/:sessionId";
|
|
52
|
+
LOGIN_API_ENDPOINTS["login_done"] = "/-/v1/done";
|
|
53
|
+
LOGIN_API_ENDPOINTS["login_done_session"] = "/-/v1/done/:sessionId";
|
|
54
|
+
return LOGIN_API_ENDPOINTS;
|
|
55
|
+
}({});
|
|
56
|
+
//#endregion
|
|
57
|
+
exports.DIST_TAGS_API_ENDPOINTS = DIST_TAGS_API_ENDPOINTS;
|
|
58
|
+
exports.LOGIN_API_ENDPOINTS = LOGIN_API_ENDPOINTS;
|
|
59
|
+
exports.PACKAGE_API_ENDPOINTS = PACKAGE_API_ENDPOINTS;
|
|
60
|
+
exports.PING_API_ENDPOINTS = PING_API_ENDPOINTS;
|
|
61
|
+
exports.PROFILE_API_ENDPOINTS = PROFILE_API_ENDPOINTS;
|
|
62
|
+
exports.PUBLISH_API_ENDPOINTS = PUBLISH_API_ENDPOINTS;
|
|
63
|
+
exports.SEARCH_API_ENDPOINTS = SEARCH_API_ENDPOINTS;
|
|
64
|
+
exports.STARS_API_ENDPOINTS = STARS_API_ENDPOINTS;
|
|
65
|
+
exports.TOKEN_API_ENDPOINTS = TOKEN_API_ENDPOINTS;
|
|
66
|
+
exports.USER_API_ENDPOINTS = USER_API_ENDPOINTS;
|
|
67
|
+
|
|
61
68
|
//# sourceMappingURL=api_urls.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_urls.js","names":[
|
|
1
|
+
{"version":3,"file":"api_urls.js","names":[],"sources":["../../src/middlewares/api_urls.ts"],"sourcesContent":["export enum USER_API_ENDPOINTS {\n whoami = '/-/whoami',\n get_user = '/-/user/:org_couchdb_user',\n add_user = '/-/user/:org_couchdb_user{/:_rev}{/:revision}',\n user_token = '/-/user/token/{*subject}',\n}\n\nexport enum STARS_API_ENDPOINTS {\n get_user_starred_packages = '/-/_view/starredByUser',\n}\n\nexport enum SEARCH_API_ENDPOINTS {\n search = '/-/v1/search',\n deprecated_search = '/-/all{/:since}',\n}\n\nexport enum PUBLISH_API_ENDPOINTS {\n add_package = '/:package',\n publish_package = '/:package/-rev/:revision',\n remove_tarball = '/:package/-/:filename/-rev/:revision',\n}\n\nexport enum PING_API_ENDPOINTS {\n ping = '/-/ping',\n}\n\nexport enum PACKAGE_API_ENDPOINTS {\n get_package_by_version = '/:package{/:version}',\n get_package_tarball = '/:package/-/:filename',\n}\n\nexport enum DIST_TAGS_API_ENDPOINTS {\n tagging = '/:package/:tag',\n tagging_package = '/-/package/:package/dist-tags/:tag',\n get_dist_tags = '/-/package/:package/dist-tags',\n}\n\nexport enum PROFILE_API_ENDPOINTS {\n get_profile = '/-/npm/v1/user',\n}\n\nexport enum TOKEN_API_ENDPOINTS {\n get_tokens = '/-/npm/v1/tokens',\n delete_token = '/-/npm/v1/tokens/token/:tokenKey',\n}\n\nexport enum LOGIN_API_ENDPOINTS {\n login = '/-/v1/login',\n login_cli = '/-/v1/login_cli',\n login_cli_session = '/-/v1/login_cli/:sessionId',\n login_done = '/-/v1/done',\n login_done_session = '/-/v1/done/:sessionId',\n}\n"],"mappings":";AAAA,IAAY,qBAAL,yBAAA,oBAAA;AACL,oBAAA,YAAA;AACA,oBAAA,cAAA;AACA,oBAAA,cAAA;AACA,oBAAA,gBAAA;;KACD;AAED,IAAY,sBAAL,yBAAA,qBAAA;AACL,qBAAA,+BAAA;;KACD;AAED,IAAY,uBAAL,yBAAA,sBAAA;AACL,sBAAA,YAAA;AACA,sBAAA,uBAAA;;KACD;AAED,IAAY,wBAAL,yBAAA,uBAAA;AACL,uBAAA,iBAAA;AACA,uBAAA,qBAAA;AACA,uBAAA,oBAAA;;KACD;AAED,IAAY,qBAAL,yBAAA,oBAAA;AACL,oBAAA,UAAA;;KACD;AAED,IAAY,wBAAL,yBAAA,uBAAA;AACL,uBAAA,4BAAA;AACA,uBAAA,yBAAA;;KACD;AAED,IAAY,0BAAL,yBAAA,yBAAA;AACL,yBAAA,aAAA;AACA,yBAAA,qBAAA;AACA,yBAAA,mBAAA;;KACD;AAED,IAAY,wBAAL,yBAAA,uBAAA;AACL,uBAAA,iBAAA;;KACD;AAED,IAAY,sBAAL,yBAAA,qBAAA;AACL,qBAAA,gBAAA;AACA,qBAAA,kBAAA;;KACD;AAED,IAAY,sBAAL,yBAAA,qBAAA;AACL,qBAAA,WAAA;AACA,qBAAA,eAAA;AACA,qBAAA,uBAAA;AACA,qBAAA,gBAAA;AACA,qBAAA,wBAAA;;KACD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//#region src/middlewares/api_urls.ts
|
|
2
|
+
var USER_API_ENDPOINTS = /* @__PURE__ */ function(USER_API_ENDPOINTS) {
|
|
3
|
+
USER_API_ENDPOINTS["whoami"] = "/-/whoami";
|
|
4
|
+
USER_API_ENDPOINTS["get_user"] = "/-/user/:org_couchdb_user";
|
|
5
|
+
USER_API_ENDPOINTS["add_user"] = "/-/user/:org_couchdb_user{/:_rev}{/:revision}";
|
|
6
|
+
USER_API_ENDPOINTS["user_token"] = "/-/user/token/{*subject}";
|
|
7
|
+
return USER_API_ENDPOINTS;
|
|
8
|
+
}({});
|
|
9
|
+
var STARS_API_ENDPOINTS = /* @__PURE__ */ function(STARS_API_ENDPOINTS) {
|
|
10
|
+
STARS_API_ENDPOINTS["get_user_starred_packages"] = "/-/_view/starredByUser";
|
|
11
|
+
return STARS_API_ENDPOINTS;
|
|
12
|
+
}({});
|
|
13
|
+
var SEARCH_API_ENDPOINTS = /* @__PURE__ */ function(SEARCH_API_ENDPOINTS) {
|
|
14
|
+
SEARCH_API_ENDPOINTS["search"] = "/-/v1/search";
|
|
15
|
+
SEARCH_API_ENDPOINTS["deprecated_search"] = "/-/all{/:since}";
|
|
16
|
+
return SEARCH_API_ENDPOINTS;
|
|
17
|
+
}({});
|
|
18
|
+
var PUBLISH_API_ENDPOINTS = /* @__PURE__ */ function(PUBLISH_API_ENDPOINTS) {
|
|
19
|
+
PUBLISH_API_ENDPOINTS["add_package"] = "/:package";
|
|
20
|
+
PUBLISH_API_ENDPOINTS["publish_package"] = "/:package/-rev/:revision";
|
|
21
|
+
PUBLISH_API_ENDPOINTS["remove_tarball"] = "/:package/-/:filename/-rev/:revision";
|
|
22
|
+
return PUBLISH_API_ENDPOINTS;
|
|
23
|
+
}({});
|
|
24
|
+
var PING_API_ENDPOINTS = /* @__PURE__ */ function(PING_API_ENDPOINTS) {
|
|
25
|
+
PING_API_ENDPOINTS["ping"] = "/-/ping";
|
|
26
|
+
return PING_API_ENDPOINTS;
|
|
27
|
+
}({});
|
|
28
|
+
var PACKAGE_API_ENDPOINTS = /* @__PURE__ */ function(PACKAGE_API_ENDPOINTS) {
|
|
29
|
+
PACKAGE_API_ENDPOINTS["get_package_by_version"] = "/:package{/:version}";
|
|
30
|
+
PACKAGE_API_ENDPOINTS["get_package_tarball"] = "/:package/-/:filename";
|
|
31
|
+
return PACKAGE_API_ENDPOINTS;
|
|
32
|
+
}({});
|
|
33
|
+
var DIST_TAGS_API_ENDPOINTS = /* @__PURE__ */ function(DIST_TAGS_API_ENDPOINTS) {
|
|
34
|
+
DIST_TAGS_API_ENDPOINTS["tagging"] = "/:package/:tag";
|
|
35
|
+
DIST_TAGS_API_ENDPOINTS["tagging_package"] = "/-/package/:package/dist-tags/:tag";
|
|
36
|
+
DIST_TAGS_API_ENDPOINTS["get_dist_tags"] = "/-/package/:package/dist-tags";
|
|
37
|
+
return DIST_TAGS_API_ENDPOINTS;
|
|
38
|
+
}({});
|
|
39
|
+
var PROFILE_API_ENDPOINTS = /* @__PURE__ */ function(PROFILE_API_ENDPOINTS) {
|
|
40
|
+
PROFILE_API_ENDPOINTS["get_profile"] = "/-/npm/v1/user";
|
|
41
|
+
return PROFILE_API_ENDPOINTS;
|
|
42
|
+
}({});
|
|
43
|
+
var TOKEN_API_ENDPOINTS = /* @__PURE__ */ function(TOKEN_API_ENDPOINTS) {
|
|
44
|
+
TOKEN_API_ENDPOINTS["get_tokens"] = "/-/npm/v1/tokens";
|
|
45
|
+
TOKEN_API_ENDPOINTS["delete_token"] = "/-/npm/v1/tokens/token/:tokenKey";
|
|
46
|
+
return TOKEN_API_ENDPOINTS;
|
|
47
|
+
}({});
|
|
48
|
+
var LOGIN_API_ENDPOINTS = /* @__PURE__ */ function(LOGIN_API_ENDPOINTS) {
|
|
49
|
+
LOGIN_API_ENDPOINTS["login"] = "/-/v1/login";
|
|
50
|
+
LOGIN_API_ENDPOINTS["login_cli"] = "/-/v1/login_cli";
|
|
51
|
+
LOGIN_API_ENDPOINTS["login_cli_session"] = "/-/v1/login_cli/:sessionId";
|
|
52
|
+
LOGIN_API_ENDPOINTS["login_done"] = "/-/v1/done";
|
|
53
|
+
LOGIN_API_ENDPOINTS["login_done_session"] = "/-/v1/done/:sessionId";
|
|
54
|
+
return LOGIN_API_ENDPOINTS;
|
|
55
|
+
}({});
|
|
56
|
+
//#endregion
|
|
57
|
+
export { DIST_TAGS_API_ENDPOINTS, LOGIN_API_ENDPOINTS, PACKAGE_API_ENDPOINTS, PING_API_ENDPOINTS, PROFILE_API_ENDPOINTS, PUBLISH_API_ENDPOINTS, SEARCH_API_ENDPOINTS, STARS_API_ENDPOINTS, TOKEN_API_ENDPOINTS, USER_API_ENDPOINTS };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=api_urls.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api_urls.mjs","names":[],"sources":["../../src/middlewares/api_urls.ts"],"sourcesContent":["export enum USER_API_ENDPOINTS {\n whoami = '/-/whoami',\n get_user = '/-/user/:org_couchdb_user',\n add_user = '/-/user/:org_couchdb_user{/:_rev}{/:revision}',\n user_token = '/-/user/token/{*subject}',\n}\n\nexport enum STARS_API_ENDPOINTS {\n get_user_starred_packages = '/-/_view/starredByUser',\n}\n\nexport enum SEARCH_API_ENDPOINTS {\n search = '/-/v1/search',\n deprecated_search = '/-/all{/:since}',\n}\n\nexport enum PUBLISH_API_ENDPOINTS {\n add_package = '/:package',\n publish_package = '/:package/-rev/:revision',\n remove_tarball = '/:package/-/:filename/-rev/:revision',\n}\n\nexport enum PING_API_ENDPOINTS {\n ping = '/-/ping',\n}\n\nexport enum PACKAGE_API_ENDPOINTS {\n get_package_by_version = '/:package{/:version}',\n get_package_tarball = '/:package/-/:filename',\n}\n\nexport enum DIST_TAGS_API_ENDPOINTS {\n tagging = '/:package/:tag',\n tagging_package = '/-/package/:package/dist-tags/:tag',\n get_dist_tags = '/-/package/:package/dist-tags',\n}\n\nexport enum PROFILE_API_ENDPOINTS {\n get_profile = '/-/npm/v1/user',\n}\n\nexport enum TOKEN_API_ENDPOINTS {\n get_tokens = '/-/npm/v1/tokens',\n delete_token = '/-/npm/v1/tokens/token/:tokenKey',\n}\n\nexport enum LOGIN_API_ENDPOINTS {\n login = '/-/v1/login',\n login_cli = '/-/v1/login_cli',\n login_cli_session = '/-/v1/login_cli/:sessionId',\n login_done = '/-/v1/done',\n login_done_session = '/-/v1/done/:sessionId',\n}\n"],"mappings":";AAAA,IAAY,qBAAL,yBAAA,oBAAA;AACL,oBAAA,YAAA;AACA,oBAAA,cAAA;AACA,oBAAA,cAAA;AACA,oBAAA,gBAAA;;KACD;AAED,IAAY,sBAAL,yBAAA,qBAAA;AACL,qBAAA,+BAAA;;KACD;AAED,IAAY,uBAAL,yBAAA,sBAAA;AACL,sBAAA,YAAA;AACA,sBAAA,uBAAA;;KACD;AAED,IAAY,wBAAL,yBAAA,uBAAA;AACL,uBAAA,iBAAA;AACA,uBAAA,qBAAA;AACA,uBAAA,oBAAA;;KACD;AAED,IAAY,qBAAL,yBAAA,oBAAA;AACL,oBAAA,UAAA;;KACD;AAED,IAAY,wBAAL,yBAAA,uBAAA;AACL,uBAAA,4BAAA;AACA,uBAAA,yBAAA;;KACD;AAED,IAAY,0BAAL,yBAAA,yBAAA;AACL,yBAAA,aAAA;AACA,yBAAA,qBAAA;AACA,yBAAA,mBAAA;;KACD;AAED,IAAY,wBAAL,yBAAA,uBAAA;AACL,uBAAA,iBAAA;;KACD;AAED,IAAY,sBAAL,yBAAA,qBAAA;AACL,qBAAA,gBAAA;AACA,qBAAA,kBAAA;;KACD;AAED,IAAY,sBAAL,yBAAA,qBAAA;AACL,qBAAA,WAAA;AACA,qBAAA,eAAA;AACA,qBAAA,uBAAA;AACA,qBAAA,gBAAA;AACA,qBAAA,wBAAA;;KACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';
|
|
2
2
|
export type DotfilesPolicy = 'allow' | 'deny' | 'ignore';
|
|
3
3
|
/**
|
|
4
4
|
* Middleware that controls how requests with dotfile path segments
|
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.dotfiles = dotfiles;
|
|
7
|
-
var _core = require("@verdaccio/core");
|
|
1
|
+
require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let _verdaccio_core = require("@verdaccio/core");
|
|
3
|
+
//#region src/middlewares/dotfiles.ts
|
|
8
4
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function dotfiles(policy =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
next();
|
|
29
|
-
};
|
|
5
|
+
* Middleware that controls how requests with dotfile path segments
|
|
6
|
+
* (e.g. /.env, /.well-known/, /.git/) are handled.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors the semantics of serve-static's `dotfiles` option:
|
|
9
|
+
* - 'deny': respond with 403
|
|
10
|
+
* - 'ignore': respond with 404 (default)
|
|
11
|
+
* - 'allow': pass through to next middleware
|
|
12
|
+
*/
|
|
13
|
+
function dotfiles(policy = "ignore") {
|
|
14
|
+
return function dotfilesMiddleware(req, res, next) {
|
|
15
|
+
if (policy !== "allow" && req.path.split("/").some((segment) => segment.startsWith(".") && segment.length > 1)) {
|
|
16
|
+
if (policy === "deny") {
|
|
17
|
+
res.statusCode = _verdaccio_core.HTTP_STATUS.FORBIDDEN;
|
|
18
|
+
res.end();
|
|
19
|
+
} else next(_verdaccio_core.errorUtils.getNotFound("resource not found"));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
next();
|
|
23
|
+
};
|
|
30
24
|
}
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.dotfiles = dotfiles;
|
|
27
|
+
|
|
31
28
|
//# sourceMappingURL=dotfiles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dotfiles.js","names":[
|
|
1
|
+
{"version":3,"file":"dotfiles.js","names":[],"sources":["../../src/middlewares/dotfiles.ts"],"sourcesContent":["import { HTTP_STATUS, errorUtils } from '@verdaccio/core';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nexport type DotfilesPolicy = 'allow' | 'deny' | 'ignore';\n\n/**\n * Middleware that controls how requests with dotfile path segments\n * (e.g. /.env, /.well-known/, /.git/) are handled.\n *\n * Mirrors the semantics of serve-static's `dotfiles` option:\n * - 'deny': respond with 403\n * - 'ignore': respond with 404 (default)\n * - 'allow': pass through to next middleware\n */\nexport function dotfiles(policy: DotfilesPolicy = 'ignore') {\n return function dotfilesMiddleware(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): void {\n if (\n policy !== 'allow' &&\n req.path.split('/').some((segment) => segment.startsWith('.') && segment.length > 1)\n ) {\n if (policy === 'deny') {\n res.statusCode = HTTP_STATUS.FORBIDDEN;\n res.end();\n } else {\n next(errorUtils.getNotFound('resource not found'));\n }\n return;\n }\n next();\n };\n}\n"],"mappings":";;;;;;;;;;;;AAeA,SAAgB,SAAS,SAAyB,UAAU;AAC1D,QAAO,SAAS,mBACd,KACA,KACA,MACM;AACN,MACE,WAAW,WACX,IAAI,KAAK,MAAM,IAAI,CAAC,MAAM,YAAY,QAAQ,WAAW,IAAI,IAAI,QAAQ,SAAS,EAAE,EACpF;AACA,OAAI,WAAW,QAAQ;AACrB,QAAI,aAAa,gBAAA,YAAY;AAC7B,QAAI,KAAK;SAET,MAAK,gBAAA,WAAW,YAAY,qBAAqB,CAAC;AAEpD;;AAEF,QAAM"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { HTTP_STATUS, errorUtils } from "@verdaccio/core";
|
|
2
|
+
//#region src/middlewares/dotfiles.ts
|
|
3
|
+
/**
|
|
4
|
+
* Middleware that controls how requests with dotfile path segments
|
|
5
|
+
* (e.g. /.env, /.well-known/, /.git/) are handled.
|
|
6
|
+
*
|
|
7
|
+
* Mirrors the semantics of serve-static's `dotfiles` option:
|
|
8
|
+
* - 'deny': respond with 403
|
|
9
|
+
* - 'ignore': respond with 404 (default)
|
|
10
|
+
* - 'allow': pass through to next middleware
|
|
11
|
+
*/
|
|
12
|
+
function dotfiles(policy = "ignore") {
|
|
13
|
+
return function dotfilesMiddleware(req, res, next) {
|
|
14
|
+
if (policy !== "allow" && req.path.split("/").some((segment) => segment.startsWith(".") && segment.length > 1)) {
|
|
15
|
+
if (policy === "deny") {
|
|
16
|
+
res.statusCode = HTTP_STATUS.FORBIDDEN;
|
|
17
|
+
res.end();
|
|
18
|
+
} else next(errorUtils.getNotFound("resource not found"));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
next();
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { dotfiles };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=dotfiles.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dotfiles.mjs","names":[],"sources":["../../src/middlewares/dotfiles.ts"],"sourcesContent":["import { HTTP_STATUS, errorUtils } from '@verdaccio/core';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nexport type DotfilesPolicy = 'allow' | 'deny' | 'ignore';\n\n/**\n * Middleware that controls how requests with dotfile path segments\n * (e.g. /.env, /.well-known/, /.git/) are handled.\n *\n * Mirrors the semantics of serve-static's `dotfiles` option:\n * - 'deny': respond with 403\n * - 'ignore': respond with 404 (default)\n * - 'allow': pass through to next middleware\n */\nexport function dotfiles(policy: DotfilesPolicy = 'ignore') {\n return function dotfilesMiddleware(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): void {\n if (\n policy !== 'allow' &&\n req.path.split('/').some((segment) => segment.startsWith('.') && segment.length > 1)\n ) {\n if (policy === 'deny') {\n res.statusCode = HTTP_STATUS.FORBIDDEN;\n res.end();\n } else {\n next(errorUtils.getNotFound('resource not found'));\n }\n return;\n }\n next();\n };\n}\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,SAAS,SAAyB,UAAU;AAC1D,QAAO,SAAS,mBACd,KACA,KACA,MACM;AACN,MACE,WAAW,WACX,IAAI,KAAK,MAAM,IAAI,CAAC,MAAM,YAAY,QAAQ,WAAW,IAAI,IAAI,QAAQ,SAAS,EAAE,EACpF;AACA,OAAI,WAAW,QAAQ;AACrB,QAAI,aAAa,YAAY;AAC7B,QAAI,KAAK;SAET,MAAK,WAAW,YAAY,qBAAqB,CAAC;AAEpD;;AAEF,QAAM"}
|
|
@@ -1,40 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
8
|
-
var _core = require("@verdaccio/core");
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
const debug = (0, _debug.default)('verdaccio:middleware:encode');
|
|
11
|
-
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let _verdaccio_core = require("@verdaccio/core");
|
|
3
|
+
let debug = require("debug");
|
|
4
|
+
debug = require_runtime.__toESM(debug);
|
|
5
|
+
//#region src/middlewares/encode-pkg.ts
|
|
6
|
+
var debug$1 = (0, debug.default)("verdaccio:middleware:encode");
|
|
12
7
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
* Encode / in a scoped package name to be matched as a single parameter in routes
|
|
9
|
+
* @param req
|
|
10
|
+
* @param res
|
|
11
|
+
* @param next
|
|
12
|
+
*/
|
|
18
13
|
function encodeScopePackage(req, res, next) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// If the @ sign is encoded, we need to decode it first
|
|
27
|
-
// e.g.: /%40org/pkg/1.2.3 -> /@org/pkg/1.2.3
|
|
28
|
-
// For scoped packages, encode the slash to make it a single path segment/parameter
|
|
29
|
-
// e.g.: /@org/pkg/1.2.3 -> /@org%2Fpkg/1.2.3, /@org%2Fpkg/1.2.3 -> /@org%2Fpkg/1.2.3
|
|
30
|
-
// also handle cases for dist-tags where package is in the middle of the path and not at the beginning
|
|
31
|
-
// e.g.: /-/package/@org/pkg/dist-tags/latest -> /-/package/@org%2Fpkg/dist-tags/latest
|
|
32
|
-
req.url = req.url.replace(/\/%40/, '/@').replace(/(\/@[^\/%]+)\/(?!$)/, '$1%2F');
|
|
33
|
-
if (original !== req.url) {
|
|
34
|
-
debug('encodeScopePackage: %o -> %o', original, req.url);
|
|
35
|
-
} else {
|
|
36
|
-
debug('encodeScopePackage: %o (unchanged)', original);
|
|
37
|
-
}
|
|
38
|
-
next();
|
|
14
|
+
const original = req.url;
|
|
15
|
+
if (!req.url.startsWith("/")) return next(_verdaccio_core.errorUtils.getBadRequest(`Invalid URL: ${req.url} (must be relative)`));
|
|
16
|
+
req.url = req.url.replace(/\/%40/, "/@").replace(/(\/@[^\/%]+)\/(?!$)/, "$1%2F");
|
|
17
|
+
if (original !== req.url) debug$1("encodeScopePackage: %o -> %o", original, req.url);
|
|
18
|
+
else debug$1("encodeScopePackage: %o (unchanged)", original);
|
|
19
|
+
next();
|
|
39
20
|
}
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.encodeScopePackage = encodeScopePackage;
|
|
23
|
+
|
|
40
24
|
//# sourceMappingURL=encode-pkg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode-pkg.js","names":[
|
|
1
|
+
{"version":3,"file":"encode-pkg.js","names":[],"sources":["../../src/middlewares/encode-pkg.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport { errorUtils } from '@verdaccio/core';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:encode');\n\n/**\n * Encode / in a scoped package name to be matched as a single parameter in routes\n * @param req\n * @param res\n * @param next\n */\nexport function encodeScopePackage(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n): void {\n const original = req.url;\n\n // Expect relative URLs i.e. should call makeURLrelative before this middleware\n if (!req.url.startsWith('/')) {\n return next(errorUtils.getBadRequest(`Invalid URL: ${req.url} (must be relative)`));\n }\n\n // If the @ sign is encoded, we need to decode it first\n // e.g.: /%40org/pkg/1.2.3 -> /@org/pkg/1.2.3\n // For scoped packages, encode the slash to make it a single path segment/parameter\n // e.g.: /@org/pkg/1.2.3 -> /@org%2Fpkg/1.2.3, /@org%2Fpkg/1.2.3 -> /@org%2Fpkg/1.2.3\n // also handle cases for dist-tags where package is in the middle of the path and not at the beginning\n // e.g.: /-/package/@org/pkg/dist-tags/latest -> /-/package/@org%2Fpkg/dist-tags/latest\n req.url = req.url.replace(/\\/%40/, '/@').replace(/(\\/@[^\\/%]+)\\/(?!$)/, '$1%2F');\n\n if (original !== req.url) {\n debug('encodeScopePackage: %o -> %o', original, req.url);\n } else {\n debug('encodeScopePackage: %o (unchanged)', original);\n }\n next();\n}\n"],"mappings":";;;;;AAMA,IAAM,WAAA,GAAA,MAAA,SAAmB,8BAA8B;;;;;;;AAQvD,SAAgB,mBACd,KACA,KACA,MACM;CACN,MAAM,WAAW,IAAI;AAGrB,KAAI,CAAC,IAAI,IAAI,WAAW,IAAI,CAC1B,QAAO,KAAK,gBAAA,WAAW,cAAc,gBAAgB,IAAI,IAAI,qBAAqB,CAAC;AASrF,KAAI,MAAM,IAAI,IAAI,QAAQ,SAAS,KAAK,CAAC,QAAQ,uBAAuB,QAAQ;AAEhF,KAAI,aAAa,IAAI,IACnB,SAAM,gCAAgC,UAAU,IAAI,IAAI;KAExD,SAAM,sCAAsC,SAAS;AAEvD,OAAM"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { errorUtils } from "@verdaccio/core";
|
|
2
|
+
import buildDebug from "debug";
|
|
3
|
+
//#region src/middlewares/encode-pkg.ts
|
|
4
|
+
var debug = buildDebug("verdaccio:middleware:encode");
|
|
5
|
+
/**
|
|
6
|
+
* Encode / in a scoped package name to be matched as a single parameter in routes
|
|
7
|
+
* @param req
|
|
8
|
+
* @param res
|
|
9
|
+
* @param next
|
|
10
|
+
*/
|
|
11
|
+
function encodeScopePackage(req, res, next) {
|
|
12
|
+
const original = req.url;
|
|
13
|
+
if (!req.url.startsWith("/")) return next(errorUtils.getBadRequest(`Invalid URL: ${req.url} (must be relative)`));
|
|
14
|
+
req.url = req.url.replace(/\/%40/, "/@").replace(/(\/@[^\/%]+)\/(?!$)/, "$1%2F");
|
|
15
|
+
if (original !== req.url) debug("encodeScopePackage: %o -> %o", original, req.url);
|
|
16
|
+
else debug("encodeScopePackage: %o (unchanged)", original);
|
|
17
|
+
next();
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { encodeScopePackage };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=encode-pkg.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode-pkg.mjs","names":[],"sources":["../../src/middlewares/encode-pkg.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport { errorUtils } from '@verdaccio/core';\n\nimport type { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';\n\nconst debug = buildDebug('verdaccio:middleware:encode');\n\n/**\n * Encode / in a scoped package name to be matched as a single parameter in routes\n * @param req\n * @param res\n * @param next\n */\nexport function encodeScopePackage(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n): void {\n const original = req.url;\n\n // Expect relative URLs i.e. should call makeURLrelative before this middleware\n if (!req.url.startsWith('/')) {\n return next(errorUtils.getBadRequest(`Invalid URL: ${req.url} (must be relative)`));\n }\n\n // If the @ sign is encoded, we need to decode it first\n // e.g.: /%40org/pkg/1.2.3 -> /@org/pkg/1.2.3\n // For scoped packages, encode the slash to make it a single path segment/parameter\n // e.g.: /@org/pkg/1.2.3 -> /@org%2Fpkg/1.2.3, /@org%2Fpkg/1.2.3 -> /@org%2Fpkg/1.2.3\n // also handle cases for dist-tags where package is in the middle of the path and not at the beginning\n // e.g.: /-/package/@org/pkg/dist-tags/latest -> /-/package/@org%2Fpkg/dist-tags/latest\n req.url = req.url.replace(/\\/%40/, '/@').replace(/(\\/@[^\\/%]+)\\/(?!$)/, '$1%2F');\n\n if (original !== req.url) {\n debug('encodeScopePackage: %o -> %o', original, req.url);\n } else {\n debug('encodeScopePackage: %o (unchanged)', original);\n }\n next();\n}\n"],"mappings":";;;AAMA,IAAM,QAAQ,WAAW,8BAA8B;;;;;;;AAQvD,SAAgB,mBACd,KACA,KACA,MACM;CACN,MAAM,WAAW,IAAI;AAGrB,KAAI,CAAC,IAAI,IAAI,WAAW,IAAI,CAC1B,QAAO,KAAK,WAAW,cAAc,gBAAgB,IAAI,IAAI,qBAAqB,CAAC;AASrF,KAAI,MAAM,IAAI,IAAI,QAAQ,SAAS,KAAK,CAAC,QAAQ,uBAAuB,QAAQ;AAEhF,KAAI,aAAa,IAAI,IACnB,OAAM,gCAAgC,UAAU,IAAI,IAAI;KAExD,OAAM,sCAAsC,SAAS;AAEvD,OAAM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { HttpError } from 'http-errors';
|
|
2
|
+
import { Logger } from '@verdaccio/types';
|
|
3
|
+
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types';
|
|
4
4
|
export declare const handleError: (logger: Logger) => (err: HttpError, req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) => any;
|
|
5
5
|
export declare const errorReportingMiddleware: (logger: Logger) => (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) => void;
|
|
@@ -1,75 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
debug('set locals error report ref');
|
|
26
|
-
res.locals.report_error(err);
|
|
27
|
-
} else {
|
|
28
|
-
// Fall to Middleware.final
|
|
29
|
-
debug('no error to report, jump next layer');
|
|
30
|
-
return next(err);
|
|
31
|
-
}
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let _verdaccio_core = require("@verdaccio/core");
|
|
3
|
+
let debug = require("debug");
|
|
4
|
+
debug = require_runtime.__toESM(debug);
|
|
5
|
+
let lodash = require("lodash");
|
|
6
|
+
lodash = require_runtime.__toESM(lodash);
|
|
7
|
+
//#region src/middlewares/error.ts
|
|
8
|
+
var debug$1 = (0, debug.default)("verdaccio:middleware:error");
|
|
9
|
+
var handleError = (logger) => function handleError(err, req, res, next) {
|
|
10
|
+
debug$1("error handler init");
|
|
11
|
+
if (lodash.default.isError(err)) {
|
|
12
|
+
debug$1("is native error");
|
|
13
|
+
if (err.code === "ECONNABORT" && res.statusCode === _verdaccio_core.HTTP_STATUS.NOT_MODIFIED) return next();
|
|
14
|
+
if (lodash.default.isFunction(res.locals.report_error) === false) {
|
|
15
|
+
debug$1("is locals error report ref");
|
|
16
|
+
errorReportingMiddleware(logger)(req, res, lodash.default.noop);
|
|
17
|
+
}
|
|
18
|
+
debug$1("set locals error report ref");
|
|
19
|
+
res.locals.report_error(err);
|
|
20
|
+
} else {
|
|
21
|
+
debug$1("no error to report, jump next layer");
|
|
22
|
+
return next(err);
|
|
23
|
+
}
|
|
32
24
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
debug('send internal error %o', err);
|
|
61
|
-
res.status(_core.HTTP_STATUS.INTERNAL_ERROR);
|
|
62
|
-
next({
|
|
63
|
-
error: _core.API_ERROR.INTERNAL_SERVER_ERROR
|
|
64
|
-
});
|
|
65
|
-
} else {
|
|
66
|
-
// socket should be already closed
|
|
67
|
-
debug('this should not happen, otherwise report %o', err);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
debug('error report middleware end (skip next layer) next()');
|
|
72
|
-
next();
|
|
25
|
+
var errorReportingMiddleware = (logger) => function errorReportingMiddleware(req, res, next) {
|
|
26
|
+
debug$1("error report middleware start");
|
|
27
|
+
res.locals.report_error = res.locals.report_error || function(err) {
|
|
28
|
+
if (err.status && err.status >= _verdaccio_core.HTTP_STATUS.BAD_REQUEST && err.status < 600) {
|
|
29
|
+
debug$1("is error > 409 %o", err?.status);
|
|
30
|
+
if (lodash.default.isNil(res.headersSent) === false) {
|
|
31
|
+
debug$1("send status %o", err?.status);
|
|
32
|
+
res.status(err.status);
|
|
33
|
+
debug$1("next layer %o", err?.message);
|
|
34
|
+
next({ error: err.message || _verdaccio_core.API_ERROR.UNKNOWN_ERROR });
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
debug$1("is error < 409 %o", err?.status);
|
|
38
|
+
logger.error({ err }, "unexpected error: @{!err.message}\n@{err.stack}");
|
|
39
|
+
if (!res.status || !res.send) {
|
|
40
|
+
logger.error("this is an error in express.js, please report this");
|
|
41
|
+
debug$1("this is an error in express.js, please report this, destroy response %o", err);
|
|
42
|
+
res.destroy();
|
|
43
|
+
} else if (!res.headersSent) {
|
|
44
|
+
debug$1("send internal error %o", err);
|
|
45
|
+
res.status(_verdaccio_core.HTTP_STATUS.INTERNAL_ERROR);
|
|
46
|
+
next({ error: _verdaccio_core.API_ERROR.INTERNAL_SERVER_ERROR });
|
|
47
|
+
} else debug$1("this should not happen, otherwise report %o", err);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
debug$1("error report middleware end (skip next layer) next()");
|
|
51
|
+
next();
|
|
73
52
|
};
|
|
53
|
+
//#endregion
|
|
74
54
|
exports.errorReportingMiddleware = errorReportingMiddleware;
|
|
55
|
+
exports.handleError = handleError;
|
|
56
|
+
|
|
75
57
|
//# sourceMappingURL=error.js.map
|