@verdaccio/core 8.1.2 → 8.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.
Files changed (78) hide show
  1. package/build/_virtual/_rolldown/runtime.js +33 -0
  2. package/build/_virtual/_rolldown/runtime.mjs +13 -0
  3. package/build/auth-utils.d.ts +0 -1
  4. package/build/auth-utils.js +23 -25
  5. package/build/auth-utils.js.map +1 -1
  6. package/build/auth-utils.mjs +32 -0
  7. package/build/auth-utils.mjs.map +1 -0
  8. package/build/constants.js +201 -157
  9. package/build/constants.js.map +1 -1
  10. package/build/constants.mjs +185 -0
  11. package/build/constants.mjs.map +1 -0
  12. package/build/crypto-utils.d.ts +0 -2
  13. package/build/crypto-utils.js +33 -29
  14. package/build/crypto-utils.js.map +1 -1
  15. package/build/crypto-utils.mjs +40 -0
  16. package/build/crypto-utils.mjs.map +1 -0
  17. package/build/error-utils.js +92 -80
  18. package/build/error-utils.js.map +1 -1
  19. package/build/error-utils.mjs +107 -0
  20. package/build/error-utils.mjs.map +1 -0
  21. package/build/file-utils.js +35 -31
  22. package/build/file-utils.js.map +1 -1
  23. package/build/file-utils.mjs +35 -0
  24. package/build/file-utils.mjs.map +1 -0
  25. package/build/index.d.ts +2 -1
  26. package/build/index.js +125 -185
  27. package/build/index.mjs +15 -0
  28. package/build/ip-utils.js +52 -69
  29. package/build/ip-utils.js.map +1 -1
  30. package/build/ip-utils.mjs +60 -0
  31. package/build/ip-utils.mjs.map +1 -0
  32. package/build/pkg-utils.js +60 -76
  33. package/build/pkg-utils.js.map +1 -1
  34. package/build/pkg-utils.mjs +69 -0
  35. package/build/pkg-utils.mjs.map +1 -0
  36. package/build/plugin-utils.d.ts +0 -1
  37. package/build/plugin-utils.js +27 -78
  38. package/build/plugin-utils.js.map +1 -1
  39. package/build/plugin-utils.mjs +26 -0
  40. package/build/plugin-utils.mjs.map +1 -0
  41. package/build/schemes/publish-manifest.js +33 -43
  42. package/build/schemes/publish-manifest.js.map +1 -1
  43. package/build/schemes/publish-manifest.mjs +36 -0
  44. package/build/schemes/publish-manifest.mjs.map +1 -0
  45. package/build/schemes/unpublish-manifest.js +51 -72
  46. package/build/schemes/unpublish-manifest.js.map +1 -1
  47. package/build/schemes/unpublish-manifest.mjs +54 -0
  48. package/build/schemes/unpublish-manifest.mjs.map +1 -0
  49. package/build/search-utils.js +9 -9
  50. package/build/search-utils.js.map +1 -1
  51. package/build/search-utils.mjs +8 -0
  52. package/build/search-utils.mjs.map +1 -0
  53. package/build/stream-utils.d.ts +0 -1
  54. package/build/stream-utils.js +29 -28
  55. package/build/stream-utils.js.map +1 -1
  56. package/build/stream-utils.mjs +30 -0
  57. package/build/stream-utils.mjs.map +1 -0
  58. package/build/string-utils.js +31 -34
  59. package/build/string-utils.js.map +1 -1
  60. package/build/string-utils.mjs +31 -0
  61. package/build/string-utils.mjs.map +1 -0
  62. package/build/tarball-utils.js +40 -39
  63. package/build/tarball-utils.js.map +1 -1
  64. package/build/tarball-utils.mjs +46 -0
  65. package/build/tarball-utils.mjs.map +1 -0
  66. package/build/validation-utils.js +78 -112
  67. package/build/validation-utils.js.map +1 -1
  68. package/build/validation-utils.mjs +91 -0
  69. package/build/validation-utils.mjs.map +1 -0
  70. package/build/warning-utils.d.ts +1 -0
  71. package/build/warning-utils.js +38 -33
  72. package/build/warning-utils.js.map +1 -1
  73. package/build/warning-utils.mjs +40 -0
  74. package/build/warning-utils.mjs.map +1 -0
  75. package/package.json +35 -22
  76. package/build/index.js.map +0 -1
  77. package/build/path-utils.js +0 -2
  78. package/build/path-utils.js.map +0 -1
@@ -1,38 +1,35 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getByQualityPriorityValue = getByQualityPriorityValue;
1
+ //#region src/string-utils.ts
2
+ var string_utils_exports = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.js").__exportAll({ getByQualityPriorityValue: () => getByQualityPriorityValue });
7
3
  /**
8
- * Quality values, or q-values and q-factors, are used to describe the order
9
- * of priority of values in a comma-separated list.
10
- * It is a special syntax allowed in some HTTP headers and in HTML.
11
- * https://developer.mozilla.org/en-US/docs/Glossary/Quality_values
12
- * @param headerValue
13
- */
4
+ * Quality values, or q-values and q-factors, are used to describe the order
5
+ * of priority of values in a comma-separated list.
6
+ * It is a special syntax allowed in some HTTP headers and in HTML.
7
+ * https://developer.mozilla.org/en-US/docs/Glossary/Quality_values
8
+ * @param headerValue
9
+ */
14
10
  function getByQualityPriorityValue(headerValue) {
15
- if (typeof headerValue !== 'string') {
16
- return '';
17
- }
18
- const split = headerValue.split(',');
19
- if (split.length <= 1) {
20
- const qList = split[0].split(';');
21
- return qList[0];
22
- }
23
- const [header] = split.reduce((acc, item) => {
24
- const qList = item.split(';');
25
- if (qList.length > 1) {
26
- const [accept, q] = qList;
27
- const [, query] = q.split('=');
28
- acc.push([accept.trim(), query ? query : 0]);
29
- } else {
30
- acc.push([qList[0], 0]);
31
- }
32
- return acc;
33
- }, []).sort(function (a, b) {
34
- return b[1] - a[1];
35
- });
36
- return header[0];
11
+ if (typeof headerValue !== "string") return "";
12
+ const split = headerValue.split(",");
13
+ if (split.length <= 1) return split[0].split(";")[0];
14
+ const [header] = split.reduce((acc, item) => {
15
+ const qList = item.split(";");
16
+ if (qList.length > 1) {
17
+ const [accept, q] = qList;
18
+ const [, query] = q.split("=");
19
+ acc.push([accept.trim(), query ? query : 0]);
20
+ } else acc.push([qList[0], 0]);
21
+ return acc;
22
+ }, []).sort(function(a, b) {
23
+ return b[1] - a[1];
24
+ });
25
+ return header[0];
37
26
  }
27
+ //#endregion
28
+ Object.defineProperty(exports, "string_utils_exports", {
29
+ enumerable: true,
30
+ get: function() {
31
+ return string_utils_exports;
32
+ }
33
+ });
34
+
38
35
  //# sourceMappingURL=string-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"string-utils.js","names":["getByQualityPriorityValue","headerValue","split","length","qList","header","reduce","acc","item","accept","q","query","push","trim","sort","a","b"],"sources":["../src/string-utils.ts"],"sourcesContent":["/**\n * Quality values, or q-values and q-factors, are used to describe the order\n * of priority of values in a comma-separated list.\n * It is a special syntax allowed in some HTTP headers and in HTML.\n * https://developer.mozilla.org/en-US/docs/Glossary/Quality_values\n * @param headerValue\n */\nexport function getByQualityPriorityValue(headerValue: string | undefined | null): string {\n if (typeof headerValue !== 'string') {\n return '';\n }\n\n const split = headerValue.split(',');\n\n if (split.length <= 1) {\n const qList = split[0].split(';');\n return qList[0];\n }\n\n const [header] = split\n .reduce((acc, item: string) => {\n const qList = item.split(';');\n if (qList.length > 1) {\n const [accept, q] = qList;\n const [, query] = q.split('=');\n acc.push([accept.trim(), query ? query : 0]);\n } else {\n acc.push([qList[0], 0]);\n }\n return acc;\n }, [] as any)\n .sort(function (a: number[], b: number[]) {\n return b[1] - a[1];\n });\n return header[0];\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,yBAAyBA,CAACC,WAAsC,EAAU;EACxF,IAAI,OAAOA,WAAW,KAAK,QAAQ,EAAE;IACnC,OAAO,EAAE;EACX;EAEA,MAAMC,KAAK,GAAGD,WAAW,CAACC,KAAK,CAAC,GAAG,CAAC;EAEpC,IAAIA,KAAK,CAACC,MAAM,IAAI,CAAC,EAAE;IACrB,MAAMC,KAAK,GAAGF,KAAK,CAAC,CAAC,CAAC,CAACA,KAAK,CAAC,GAAG,CAAC;IACjC,OAAOE,KAAK,CAAC,CAAC,CAAC;EACjB;EAEA,MAAM,CAACC,MAAM,CAAC,GAAGH,KAAK,CACnBI,MAAM,CAAC,CAACC,GAAG,EAAEC,IAAY,KAAK;IAC7B,MAAMJ,KAAK,GAAGI,IAAI,CAACN,KAAK,CAAC,GAAG,CAAC;IAC7B,IAAIE,KAAK,CAACD,MAAM,GAAG,CAAC,EAAE;MACpB,MAAM,CAACM,MAAM,EAAEC,CAAC,CAAC,GAAGN,KAAK;MACzB,MAAM,GAAGO,KAAK,CAAC,GAAGD,CAAC,CAACR,KAAK,CAAC,GAAG,CAAC;MAC9BK,GAAG,CAACK,IAAI,CAAC,CAACH,MAAM,CAACI,IAAI,CAAC,CAAC,EAAEF,KAAK,GAAGA,KAAK,GAAG,CAAC,CAAC,CAAC;IAC9C,CAAC,MAAM;MACLJ,GAAG,CAACK,IAAI,CAAC,CAACR,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACzB;IACA,OAAOG,GAAG;EACZ,CAAC,EAAE,EAAS,CAAC,CACZO,IAAI,CAAC,UAAUC,CAAW,EAAEC,CAAW,EAAE;IACxC,OAAOA,CAAC,CAAC,CAAC,CAAC,GAAGD,CAAC,CAAC,CAAC,CAAC;EACpB,CAAC,CAAC;EACJ,OAAOV,MAAM,CAAC,CAAC,CAAC;AAClB","ignoreList":[]}
1
+ {"version":3,"file":"string-utils.js","names":[],"sources":["../src/string-utils.ts"],"sourcesContent":["/**\n * Quality values, or q-values and q-factors, are used to describe the order\n * of priority of values in a comma-separated list.\n * It is a special syntax allowed in some HTTP headers and in HTML.\n * https://developer.mozilla.org/en-US/docs/Glossary/Quality_values\n * @param headerValue\n */\nexport function getByQualityPriorityValue(headerValue: string | undefined | null): string {\n if (typeof headerValue !== 'string') {\n return '';\n }\n\n const split = headerValue.split(',');\n\n if (split.length <= 1) {\n const qList = split[0].split(';');\n return qList[0];\n }\n\n const [header] = split\n .reduce((acc, item: string) => {\n const qList = item.split(';');\n if (qList.length > 1) {\n const [accept, q] = qList;\n const [, query] = q.split('=');\n acc.push([accept.trim(), query ? query : 0]);\n } else {\n acc.push([qList[0], 0]);\n }\n return acc;\n }, [] as any)\n .sort(function (a: number[], b: number[]) {\n return b[1] - a[1];\n });\n return header[0];\n}\n"],"mappings":";;;;;;;;;AAOA,SAAgB,0BAA0B,aAAgD;CACxF,IAAI,OAAO,gBAAgB,UACzB,OAAO;CAGT,MAAM,QAAQ,YAAY,MAAM,GAAG;CAEnC,IAAI,MAAM,UAAU,GAElB,OADc,MAAM,GAAG,MAAM,GACtB,EAAM;CAGf,MAAM,CAAC,UAAU,MACd,QAAQ,KAAK,SAAiB;EAC7B,MAAM,QAAQ,KAAK,MAAM,GAAG;EAC5B,IAAI,MAAM,SAAS,GAAG;GACpB,MAAM,CAAC,QAAQ,KAAK;GACpB,MAAM,GAAG,SAAS,EAAE,MAAM,GAAG;GAC7B,IAAI,KAAK,CAAC,OAAO,KAAK,GAAG,QAAQ,QAAQ,CAAC,CAAC;EAC7C,OACE,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;EAExB,OAAO;CACT,GAAG,CAAC,CAAQ,EACX,KAAK,SAAU,GAAa,GAAa;EACxC,OAAO,EAAE,KAAK,EAAE;CAClB,CAAC;CACH,OAAO,OAAO;AAChB"}
@@ -0,0 +1,31 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
+ //#region src/string-utils.ts
3
+ var string_utils_exports = /* @__PURE__ */ __exportAll({ getByQualityPriorityValue: () => getByQualityPriorityValue });
4
+ /**
5
+ * Quality values, or q-values and q-factors, are used to describe the order
6
+ * of priority of values in a comma-separated list.
7
+ * It is a special syntax allowed in some HTTP headers and in HTML.
8
+ * https://developer.mozilla.org/en-US/docs/Glossary/Quality_values
9
+ * @param headerValue
10
+ */
11
+ function getByQualityPriorityValue(headerValue) {
12
+ if (typeof headerValue !== "string") return "";
13
+ const split = headerValue.split(",");
14
+ if (split.length <= 1) return split[0].split(";")[0];
15
+ const [header] = split.reduce((acc, item) => {
16
+ const qList = item.split(";");
17
+ if (qList.length > 1) {
18
+ const [accept, q] = qList;
19
+ const [, query] = q.split("=");
20
+ acc.push([accept.trim(), query ? query : 0]);
21
+ } else acc.push([qList[0], 0]);
22
+ return acc;
23
+ }, []).sort(function(a, b) {
24
+ return b[1] - a[1];
25
+ });
26
+ return header[0];
27
+ }
28
+ //#endregion
29
+ export { string_utils_exports };
30
+
31
+ //# sourceMappingURL=string-utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-utils.mjs","names":[],"sources":["../src/string-utils.ts"],"sourcesContent":["/**\n * Quality values, or q-values and q-factors, are used to describe the order\n * of priority of values in a comma-separated list.\n * It is a special syntax allowed in some HTTP headers and in HTML.\n * https://developer.mozilla.org/en-US/docs/Glossary/Quality_values\n * @param headerValue\n */\nexport function getByQualityPriorityValue(headerValue: string | undefined | null): string {\n if (typeof headerValue !== 'string') {\n return '';\n }\n\n const split = headerValue.split(',');\n\n if (split.length <= 1) {\n const qList = split[0].split(';');\n return qList[0];\n }\n\n const [header] = split\n .reduce((acc, item: string) => {\n const qList = item.split(';');\n if (qList.length > 1) {\n const [accept, q] = qList;\n const [, query] = q.split('=');\n acc.push([accept.trim(), query ? query : 0]);\n } else {\n acc.push([qList[0], 0]);\n }\n return acc;\n }, [] as any)\n .sort(function (a: number[], b: number[]) {\n return b[1] - a[1];\n });\n return header[0];\n}\n"],"mappings":";;;;;;;;;;AAOA,SAAgB,0BAA0B,aAAgD;CACxF,IAAI,OAAO,gBAAgB,UACzB,OAAO;CAGT,MAAM,QAAQ,YAAY,MAAM,GAAG;CAEnC,IAAI,MAAM,UAAU,GAElB,OADc,MAAM,GAAG,MAAM,GACtB,EAAM;CAGf,MAAM,CAAC,UAAU,MACd,QAAQ,KAAK,SAAiB;EAC7B,MAAM,QAAQ,KAAK,MAAM,GAAG;EAC5B,IAAI,MAAM,SAAS,GAAG;GACpB,MAAM,CAAC,QAAQ,KAAK;GACpB,MAAM,GAAG,SAAS,EAAE,MAAM,GAAG;GAC7B,IAAI,KAAK,CAAC,OAAO,KAAK,GAAG,QAAQ,QAAQ,CAAC,CAAC;EAC7C,OACE,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;EAExB,OAAO;CACT,GAAG,CAAC,CAAQ,EACX,KAAK,SAAU,GAAa,GAAa;EACxC,OAAO,EAAE,KAAK,EAAE;CAClB,CAAC;CACH,OAAO,OAAO;AAChB"}
@@ -1,50 +1,51 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.js");
2
+ let node_url = require("node:url");
3
+ //#region src/tarball-utils.ts
4
+ var tarball_utils_exports = /* @__PURE__ */ require_runtime.__exportAll({
5
+ composeTarballFromPackage: () => composeTarballFromPackage,
6
+ extractTarballFromUrl: () => extractTarballFromUrl,
7
+ getVersionFromTarball: () => getVersionFromTarball
5
8
  });
6
- exports.composeTarballFromPackage = composeTarballFromPackage;
7
- exports.extractTarballFromUrl = extractTarballFromUrl;
8
- exports.getVersionFromTarball = getVersionFromTarball;
9
- var _nodeUrl = require("node:url");
10
9
  /**
11
- * Return package version from tarball name
12
- *
13
- * test-1.2.4.tgz -> 1.2.4
14
- * @param {String} fileName
15
- * @returns {String}
16
- */
10
+ * Return package version from tarball name
11
+ *
12
+ * test-1.2.4.tgz -> 1.2.4
13
+ * @param {String} fileName
14
+ * @returns {String}
15
+ */
17
16
  function getVersionFromTarball(fileName) {
18
- const groups = fileName.replace(/\.tgz$/, '').match(/^[^/]+-(\d+\.\d+\.\d+.*)/);
19
- return groups !== null ? groups[1] : undefined;
17
+ const groups = fileName.replace(/\.tgz$/, "").match(/^[^/]+-(\d+\.\d+\.\d+.*)/);
18
+ return groups !== null ? groups[1] : void 0;
20
19
  }
21
-
22
20
  /**
23
- * Extract the tarball name from a registry dist url
24
- *
25
- * https://registry.npmjs.org/test/-/test-0.0.2.tgz -> test-0.0.2.tgz
26
- * @param tarball tarball url
27
- * @returns tarball filename
28
- */
21
+ * Extract the tarball name from a registry dist url
22
+ *
23
+ * https://registry.npmjs.org/test/-/test-0.0.2.tgz -> test-0.0.2.tgz
24
+ * @param tarball tarball url
25
+ * @returns tarball filename
26
+ */
29
27
  function extractTarballFromUrl(url) {
30
- const urlObject = new _nodeUrl.URL(url);
31
- return urlObject.pathname.replace(/^.*\//, '');
28
+ return new node_url.URL(url).pathname.replace(/^.*\//, "");
32
29
  }
33
-
34
30
  /**
35
- * Build the tarball filename from paackage name and version
36
- *
37
- * test, 1.2.4 -> test-1.2.4.tgz
38
- * @scope/name, 1.2.4 -> name-1.2.4.tgz
39
- * @param name package name
40
- * @param version package version
41
- * @returns tarball filename
42
- */
31
+ * Build the tarball filename from paackage name and version
32
+ *
33
+ * test, 1.2.4 -> test-1.2.4.tgz
34
+ * @scope/name, 1.2.4 -> name-1.2.4.tgz
35
+ * @param name package name
36
+ * @param version package version
37
+ * @returns tarball filename
38
+ */
43
39
  function composeTarballFromPackage(name, version) {
44
- if (name.includes('/')) {
45
- return `${name.split('/')[1]}-${version}.tgz`;
46
- } else {
47
- return `${name}-${version}.tgz`;
48
- }
40
+ if (name.includes("/")) return `${name.split("/")[1]}-${version}.tgz`;
41
+ else return `${name}-${version}.tgz`;
49
42
  }
43
+ //#endregion
44
+ Object.defineProperty(exports, "tarball_utils_exports", {
45
+ enumerable: true,
46
+ get: function() {
47
+ return tarball_utils_exports;
48
+ }
49
+ });
50
+
50
51
  //# sourceMappingURL=tarball-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tarball-utils.js","names":["_nodeUrl","require","getVersionFromTarball","fileName","groups","replace","match","undefined","extractTarballFromUrl","url","urlObject","URL","pathname","composeTarballFromPackage","name","version","includes","split"],"sources":["../src/tarball-utils.ts"],"sourcesContent":["import { URL } from 'node:url';\n\n/**\n * Return package version from tarball name\n *\n * test-1.2.4.tgz -> 1.2.4\n * @param {String} fileName\n * @returns {String}\n */\nexport function getVersionFromTarball(fileName: string): string | void {\n const groups = fileName.replace(/\\.tgz$/, '').match(/^[^/]+-(\\d+\\.\\d+\\.\\d+.*)/);\n\n return groups !== null ? groups[1] : undefined;\n}\n\n/**\n * Extract the tarball name from a registry dist url\n *\n * https://registry.npmjs.org/test/-/test-0.0.2.tgz -> test-0.0.2.tgz\n * @param tarball tarball url\n * @returns tarball filename\n */\nexport function extractTarballFromUrl(url: string): string {\n const urlObject = new URL(url);\n return urlObject.pathname.replace(/^.*\\//, '');\n}\n\n/**\n * Build the tarball filename from paackage name and version\n *\n * test, 1.2.4 -> test-1.2.4.tgz\n * @scope/name, 1.2.4 -> name-1.2.4.tgz\n * @param name package name\n * @param version package version\n * @returns tarball filename\n */\nexport function composeTarballFromPackage(name: string, version: string): string {\n if (name.includes('/')) {\n return `${name.split('/')[1]}-${version}.tgz`;\n } else {\n return `${name}-${version}.tgz`;\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CAACC,QAAgB,EAAiB;EACrE,MAAMC,MAAM,GAAGD,QAAQ,CAACE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAACC,KAAK,CAAC,0BAA0B,CAAC;EAE/E,OAAOF,MAAM,KAAK,IAAI,GAAGA,MAAM,CAAC,CAAC,CAAC,GAAGG,SAAS;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CAACC,GAAW,EAAU;EACzD,MAAMC,SAAS,GAAG,IAAIC,YAAG,CAACF,GAAG,CAAC;EAC9B,OAAOC,SAAS,CAACE,QAAQ,CAACP,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;AAChD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,yBAAyBA,CAACC,IAAY,EAAEC,OAAe,EAAU;EAC/E,IAAID,IAAI,CAACE,QAAQ,CAAC,GAAG,CAAC,EAAE;IACtB,OAAO,GAAGF,IAAI,CAACG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAIF,OAAO,MAAM;EAC/C,CAAC,MAAM;IACL,OAAO,GAAGD,IAAI,IAAIC,OAAO,MAAM;EACjC;AACF","ignoreList":[]}
1
+ {"version":3,"file":"tarball-utils.js","names":[],"sources":["../src/tarball-utils.ts"],"sourcesContent":["import { URL } from 'node:url';\n\n/**\n * Return package version from tarball name\n *\n * test-1.2.4.tgz -> 1.2.4\n * @param {String} fileName\n * @returns {String}\n */\nexport function getVersionFromTarball(fileName: string): string | void {\n const groups = fileName.replace(/\\.tgz$/, '').match(/^[^/]+-(\\d+\\.\\d+\\.\\d+.*)/);\n\n return groups !== null ? groups[1] : undefined;\n}\n\n/**\n * Extract the tarball name from a registry dist url\n *\n * https://registry.npmjs.org/test/-/test-0.0.2.tgz -> test-0.0.2.tgz\n * @param tarball tarball url\n * @returns tarball filename\n */\nexport function extractTarballFromUrl(url: string): string {\n const urlObject = new URL(url);\n return urlObject.pathname.replace(/^.*\\//, '');\n}\n\n/**\n * Build the tarball filename from paackage name and version\n *\n * test, 1.2.4 -> test-1.2.4.tgz\n * @scope/name, 1.2.4 -> name-1.2.4.tgz\n * @param name package name\n * @param version package version\n * @returns tarball filename\n */\nexport function composeTarballFromPackage(name: string, version: string): string {\n if (name.includes('/')) {\n return `${name.split('/')[1]}-${version}.tgz`;\n } else {\n return `${name}-${version}.tgz`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AASA,SAAgB,sBAAsB,UAAiC;CACrE,MAAM,SAAS,SAAS,QAAQ,UAAU,EAAE,EAAE,MAAM,0BAA0B;CAE9E,OAAO,WAAW,OAAO,OAAO,KAAK,KAAA;AACvC;;;;;;;;AASA,SAAgB,sBAAsB,KAAqB;CAEzD,OAAO,IADe,SAAA,IAAI,GACnB,EAAU,SAAS,QAAQ,SAAS,EAAE;AAC/C;;;;;;;;;;AAWA,SAAgB,0BAA0B,MAAc,SAAyB;CAC/E,IAAI,KAAK,SAAS,GAAG,GACnB,OAAO,GAAG,KAAK,MAAM,GAAG,EAAE,GAAG,GAAG,QAAQ;MAExC,OAAO,GAAG,KAAK,GAAG,QAAQ;AAE9B"}
@@ -0,0 +1,46 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
+ import { URL } from "node:url";
3
+ //#region src/tarball-utils.ts
4
+ var tarball_utils_exports = /* @__PURE__ */ __exportAll({
5
+ composeTarballFromPackage: () => composeTarballFromPackage,
6
+ extractTarballFromUrl: () => extractTarballFromUrl,
7
+ getVersionFromTarball: () => getVersionFromTarball
8
+ });
9
+ /**
10
+ * Return package version from tarball name
11
+ *
12
+ * test-1.2.4.tgz -> 1.2.4
13
+ * @param {String} fileName
14
+ * @returns {String}
15
+ */
16
+ function getVersionFromTarball(fileName) {
17
+ const groups = fileName.replace(/\.tgz$/, "").match(/^[^/]+-(\d+\.\d+\.\d+.*)/);
18
+ return groups !== null ? groups[1] : void 0;
19
+ }
20
+ /**
21
+ * Extract the tarball name from a registry dist url
22
+ *
23
+ * https://registry.npmjs.org/test/-/test-0.0.2.tgz -> test-0.0.2.tgz
24
+ * @param tarball tarball url
25
+ * @returns tarball filename
26
+ */
27
+ function extractTarballFromUrl(url) {
28
+ return new URL(url).pathname.replace(/^.*\//, "");
29
+ }
30
+ /**
31
+ * Build the tarball filename from paackage name and version
32
+ *
33
+ * test, 1.2.4 -> test-1.2.4.tgz
34
+ * @scope/name, 1.2.4 -> name-1.2.4.tgz
35
+ * @param name package name
36
+ * @param version package version
37
+ * @returns tarball filename
38
+ */
39
+ function composeTarballFromPackage(name, version) {
40
+ if (name.includes("/")) return `${name.split("/")[1]}-${version}.tgz`;
41
+ else return `${name}-${version}.tgz`;
42
+ }
43
+ //#endregion
44
+ export { tarball_utils_exports };
45
+
46
+ //# sourceMappingURL=tarball-utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tarball-utils.mjs","names":[],"sources":["../src/tarball-utils.ts"],"sourcesContent":["import { URL } from 'node:url';\n\n/**\n * Return package version from tarball name\n *\n * test-1.2.4.tgz -> 1.2.4\n * @param {String} fileName\n * @returns {String}\n */\nexport function getVersionFromTarball(fileName: string): string | void {\n const groups = fileName.replace(/\\.tgz$/, '').match(/^[^/]+-(\\d+\\.\\d+\\.\\d+.*)/);\n\n return groups !== null ? groups[1] : undefined;\n}\n\n/**\n * Extract the tarball name from a registry dist url\n *\n * https://registry.npmjs.org/test/-/test-0.0.2.tgz -> test-0.0.2.tgz\n * @param tarball tarball url\n * @returns tarball filename\n */\nexport function extractTarballFromUrl(url: string): string {\n const urlObject = new URL(url);\n return urlObject.pathname.replace(/^.*\\//, '');\n}\n\n/**\n * Build the tarball filename from paackage name and version\n *\n * test, 1.2.4 -> test-1.2.4.tgz\n * @scope/name, 1.2.4 -> name-1.2.4.tgz\n * @param name package name\n * @param version package version\n * @returns tarball filename\n */\nexport function composeTarballFromPackage(name: string, version: string): string {\n if (name.includes('/')) {\n return `${name.split('/')[1]}-${version}.tgz`;\n } else {\n return `${name}-${version}.tgz`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AASA,SAAgB,sBAAsB,UAAiC;CACrE,MAAM,SAAS,SAAS,QAAQ,UAAU,EAAE,EAAE,MAAM,0BAA0B;CAE9E,OAAO,WAAW,OAAO,OAAO,KAAK,KAAA;AACvC;;;;;;;;AASA,SAAgB,sBAAsB,KAAqB;CAEzD,OAAO,IADe,IAAI,GACnB,EAAU,SAAS,QAAQ,SAAS,EAAE;AAC/C;;;;;;;;;;AAWA,SAAgB,0BAA0B,MAAc,SAAyB;CAC/E,IAAI,KAAK,SAAS,GAAG,GACnB,OAAO,GAAG,KAAK,MAAM,GAAG,EAAE,GAAG,GAAG,QAAQ;MAExC,OAAO,GAAG,KAAK,GAAG,QAAQ;AAE9B"}
@@ -1,131 +1,97 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isObject = isObject;
7
- exports.isPackageNameScoped = isPackageNameScoped;
8
- exports.normalizeMetadata = normalizeMetadata;
9
- exports.validateName = validateName;
10
- exports.validatePackage = validatePackage;
11
- exports.validatePassword = validatePassword;
12
- Object.defineProperty(exports, "validatePublishSingleVersion", {
13
- enumerable: true,
14
- get: function () {
15
- return _publishManifest.validatePublishSingleVersion;
16
- }
17
- });
18
- Object.defineProperty(exports, "validateUnPublishSingleVersion", {
19
- enumerable: true,
20
- get: function () {
21
- return _unpublishManifest.validateUnPublishSingleVersion;
22
- }
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.js");
2
+ const require_constants = require("./constants.js");
3
+ const require_publish_manifest = require("./schemes/publish-manifest.js");
4
+ const require_unpublish_manifest = require("./schemes/unpublish-manifest.js");
5
+ let node_assert = require("node:assert");
6
+ node_assert = require_runtime.__toESM(node_assert);
7
+ //#region src/validation-utils.ts
8
+ var validation_utils_exports = /* @__PURE__ */ require_runtime.__exportAll({
9
+ isObject: () => isObject,
10
+ isPackageNameScoped: () => isPackageNameScoped,
11
+ normalizeMetadata: () => normalizeMetadata,
12
+ validateName: () => validateName,
13
+ validatePackage: () => validatePackage,
14
+ validatePassword: () => validatePassword,
15
+ validatePublishSingleVersion: () => require_publish_manifest.validatePublishSingleVersion,
16
+ validateUnPublishSingleVersion: () => require_unpublish_manifest.validateUnPublishSingleVersion,
17
+ validateUserName: () => validateUserName
23
18
  });
24
- exports.validateUserName = validateUserName;
25
- var _nodeAssert = _interopRequireDefault(require("node:assert"));
26
- var _constants = require("./constants");
27
- var _publishManifest = require("./schemes/publish-manifest");
28
- var _unpublishManifest = require("./schemes/unpublish-manifest");
29
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
30
19
  function isPackageNameScoped(name) {
31
- return name.startsWith('@');
20
+ return name.startsWith("@");
32
21
  }
33
-
34
22
  /**
35
- * From normalize-package-data/lib/fixer.js
36
- * @param {*} name the package name
37
- * @return {Boolean} whether is valid or not
38
- */
23
+ * From normalize-package-data/lib/fixer.js
24
+ * @param {*} name the package name
25
+ * @return {Boolean} whether is valid or not
26
+ */
39
27
  function validateName(name) {
40
- if (typeof name !== 'string') {
41
- return false;
42
- }
43
- let normalizedName = name.toLowerCase();
44
- const isScoped = isPackageNameScoped(name);
45
- const scopedName = name.split('/', 2)[1];
46
- if (isScoped && typeof scopedName !== 'undefined') {
47
- normalizedName = scopedName.toLowerCase();
48
- }
49
-
50
- /**
51
- * Some context about the first regex
52
- * - npm used to have a different tarball naming system.
53
- * eg: http://registry.npmjs.com/thirty-two
54
- * https://registry.npmjs.org/thirty-two/-/thirty-two@0.0.1.tgz
55
- * The file name thirty-two@0.0.1.tgz, the version and the pkg name was separated by an at (@)
56
- * while nowadays the naming system is based in dashes
57
- * https://registry.npmjs.org/verdaccio/-/verdaccio-1.4.0.tgz
58
- *
59
- * more info here: https://github.com/rlidwka/sinopia/issues/75
60
- */
61
- return !(!normalizedName.match(/^[-a-zA-Z0-9_.!~*'()@]+$/) || normalizedName.startsWith('.') ||
62
- // ".bin", etc.
63
- ['node_modules', '__proto__', 'favicon.ico'].includes(normalizedName));
28
+ if (typeof name !== "string") return false;
29
+ let normalizedName = name.toLowerCase();
30
+ const isScoped = isPackageNameScoped(name);
31
+ const scopedName = name.split("/", 2)[1];
32
+ if (isScoped && typeof scopedName !== "undefined") normalizedName = scopedName.toLowerCase();
33
+ /**
34
+ * Some context about the first regex
35
+ * - npm used to have a different tarball naming system.
36
+ * eg: http://registry.npmjs.com/thirty-two
37
+ * https://registry.npmjs.org/thirty-two/-/thirty-two@0.0.1.tgz
38
+ * The file name thirty-two@0.0.1.tgz, the version and the pkg name was separated by an at (@)
39
+ * while nowadays the naming system is based in dashes
40
+ * https://registry.npmjs.org/verdaccio/-/verdaccio-1.4.0.tgz
41
+ *
42
+ * more info here: https://github.com/rlidwka/sinopia/issues/75
43
+ */
44
+ return !(!normalizedName.match(/^[-a-zA-Z0-9_.!~*'()@]+$/) || normalizedName.startsWith(".") || [
45
+ "node_modules",
46
+ "__proto__",
47
+ "favicon.ico"
48
+ ].includes(normalizedName));
64
49
  }
65
-
66
50
  /**
67
- * Validate a package.
68
- * @return {Boolean} whether the package is valid or not
69
- */
51
+ * Validate a package.
52
+ * @return {Boolean} whether the package is valid or not
53
+ */
70
54
  function validatePackage(name) {
71
- const nameList = name.split('/', 2);
72
- if (nameList.length === 1) {
73
- // normal package
74
- return validateName(nameList[0]);
75
- }
76
- // scoped package
77
- return nameList[0][0] === '@' && validateName(nameList[0].slice(1)) && validateName(nameList[1]);
55
+ const nameList = name.split("/", 2);
56
+ if (nameList.length === 1) return validateName(nameList[0]);
57
+ return nameList[0][0] === "@" && validateName(nameList[0].slice(1)) && validateName(nameList[1]);
78
58
  }
79
-
80
59
  /**
81
- * Validate the package metadata, add additional properties whether are missing within
82
- * the metadata properties.
83
- * @param {*} manifest
84
- * @param {*} name
85
- * @return {Object} the object with additional properties as dist-tags ad versions
86
- */
60
+ * Validate the package metadata, add additional properties whether are missing within
61
+ * the metadata properties.
62
+ * @param {*} manifest
63
+ * @param {*} name
64
+ * @return {Object} the object with additional properties as dist-tags ad versions
65
+ */
87
66
  function normalizeMetadata(manifest, name) {
88
- _nodeAssert.default.strictEqual(manifest.name, name);
89
- const _manifest = {
90
- ...manifest
91
- };
92
- if (!isObject(manifest[_constants.DIST_TAGS])) {
93
- _manifest[_constants.DIST_TAGS] = {};
94
- }
95
- if (!Array.isArray(manifest[_constants.MAINTAINERS])) {
96
- _manifest[_constants.MAINTAINERS] = [];
97
- }
98
-
99
- // This may not be needed
100
- if (!isObject(manifest['versions'])) {
101
- _manifest['versions'] = {};
102
- }
103
- if (!isObject(manifest['time'])) {
104
- _manifest['time'] = {};
105
- }
106
- return _manifest;
67
+ node_assert.default.strictEqual(manifest.name, name);
68
+ const _manifest = { ...manifest };
69
+ if (!isObject(manifest["dist-tags"])) _manifest[require_constants.DIST_TAGS] = {};
70
+ if (!Array.isArray(manifest["maintainers"])) _manifest[require_constants.MAINTAINERS] = [];
71
+ if (!isObject(manifest["versions"])) _manifest["versions"] = {};
72
+ if (!isObject(manifest["time"])) _manifest["time"] = {};
73
+ return _manifest;
107
74
  }
108
-
109
75
  /**
110
- * Check whether an element is an Object
111
- * @param {*} obj the element
112
- * @return {Boolean}
113
- */
76
+ * Check whether an element is an Object
77
+ * @param {*} obj the element
78
+ * @return {Boolean}
79
+ */
114
80
  function isObject(obj) {
115
- // if (obj === null || typeof obj === 'undefined' || typeof obj === 'string') {
116
- // return false;
117
- // }
118
-
119
- // return (
120
- // (typeof obj === 'object' || typeof obj.prototype === 'undefined') &&
121
- // Array.isArray(obj) === false
122
- // );
123
- return Object.prototype.toString.call(obj) === '[object Object]';
81
+ return Object.prototype.toString.call(obj) === "[object Object]";
124
82
  }
125
- function validatePassword(password, validation = _constants.DEFAULT_PASSWORD_VALIDATION) {
126
- return typeof password === 'string' && validation instanceof RegExp ? password.match(validation) !== null : false;
83
+ function validatePassword(password, validation = require_constants.DEFAULT_PASSWORD_VALIDATION) {
84
+ return typeof password === "string" && validation instanceof RegExp ? password.match(validation) !== null : false;
127
85
  }
128
86
  function validateUserName(userName, expectedName) {
129
- return typeof userName === 'string' && userName.split(':')[0] === 'org.couchdb.user' && userName.split(':')[1] === expectedName;
87
+ return typeof userName === "string" && userName.split(":")[0] === "org.couchdb.user" && userName.split(":")[1] === expectedName;
130
88
  }
89
+ //#endregion
90
+ Object.defineProperty(exports, "validation_utils_exports", {
91
+ enumerable: true,
92
+ get: function() {
93
+ return validation_utils_exports;
94
+ }
95
+ });
96
+
131
97
  //# sourceMappingURL=validation-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation-utils.js","names":["_nodeAssert","_interopRequireDefault","require","_constants","_publishManifest","_unpublishManifest","e","__esModule","default","isPackageNameScoped","name","startsWith","validateName","normalizedName","toLowerCase","isScoped","scopedName","split","match","includes","validatePackage","nameList","length","slice","normalizeMetadata","manifest","assert","strictEqual","_manifest","isObject","DIST_TAGS","Array","isArray","MAINTAINERS","obj","Object","prototype","toString","call","validatePassword","password","validation","DEFAULT_PASSWORD_VALIDATION","RegExp","validateUserName","userName","expectedName"],"sources":["../src/validation-utils.ts"],"sourcesContent":["import assert from 'node:assert';\n\nimport type { Manifest } from '@verdaccio/types';\n\nimport { DEFAULT_PASSWORD_VALIDATION, DIST_TAGS, MAINTAINERS } from './constants';\n\nexport { validatePublishSingleVersion } from './schemes/publish-manifest';\nexport { validateUnPublishSingleVersion } from './schemes/unpublish-manifest';\n\nexport function isPackageNameScoped(name: string): boolean {\n return name.startsWith('@');\n}\n\n/**\n * From normalize-package-data/lib/fixer.js\n * @param {*} name the package name\n * @return {Boolean} whether is valid or not\n */\nexport function validateName(name: string): boolean {\n if (typeof name !== 'string') {\n return false;\n }\n\n let normalizedName: string = name.toLowerCase();\n\n const isScoped: boolean = isPackageNameScoped(name);\n const scopedName = name.split('/', 2)[1];\n\n if (isScoped && typeof scopedName !== 'undefined') {\n normalizedName = scopedName.toLowerCase();\n }\n\n /**\n * Some context about the first regex\n * - npm used to have a different tarball naming system.\n * eg: http://registry.npmjs.com/thirty-two\n * https://registry.npmjs.org/thirty-two/-/thirty-two@0.0.1.tgz\n * The file name thirty-two@0.0.1.tgz, the version and the pkg name was separated by an at (@)\n * while nowadays the naming system is based in dashes\n * https://registry.npmjs.org/verdaccio/-/verdaccio-1.4.0.tgz\n *\n * more info here: https://github.com/rlidwka/sinopia/issues/75\n */\n return !(\n !normalizedName.match(/^[-a-zA-Z0-9_.!~*'()@]+$/) ||\n normalizedName.startsWith('.') || // \".bin\", etc.\n ['node_modules', '__proto__', 'favicon.ico'].includes(normalizedName)\n );\n}\n\n/**\n * Validate a package.\n * @return {Boolean} whether the package is valid or not\n */\nexport function validatePackage(name: string): boolean {\n const nameList = name.split('/', 2);\n if (nameList.length === 1) {\n // normal package\n return validateName(nameList[0]);\n }\n // scoped package\n return nameList[0][0] === '@' && validateName(nameList[0].slice(1)) && validateName(nameList[1]);\n}\n\n/**\n * Validate the package metadata, add additional properties whether are missing within\n * the metadata properties.\n * @param {*} manifest\n * @param {*} name\n * @return {Object} the object with additional properties as dist-tags ad versions\n */\nexport function normalizeMetadata(manifest: Manifest, name: string): Manifest {\n assert.strictEqual(manifest.name, name);\n const _manifest = { ...manifest };\n\n if (!isObject(manifest[DIST_TAGS])) {\n _manifest[DIST_TAGS] = {};\n }\n\n if (!Array.isArray(manifest[MAINTAINERS])) {\n _manifest[MAINTAINERS] = [];\n }\n\n // This may not be needed\n if (!isObject(manifest['versions'])) {\n _manifest['versions'] = {};\n }\n\n if (!isObject(manifest['time'])) {\n _manifest['time'] = {};\n }\n\n return _manifest;\n}\n\n/**\n * Check whether an element is an Object\n * @param {*} obj the element\n * @return {Boolean}\n */\nexport function isObject(obj: any): boolean {\n // if (obj === null || typeof obj === 'undefined' || typeof obj === 'string') {\n // return false;\n // }\n\n // return (\n // (typeof obj === 'object' || typeof obj.prototype === 'undefined') &&\n // Array.isArray(obj) === false\n // );\n return Object.prototype.toString.call(obj) === '[object Object]';\n}\n\nexport function validatePassword(\n password: string,\n validation: RegExp = DEFAULT_PASSWORD_VALIDATION\n): boolean {\n return typeof password === 'string' && validation instanceof RegExp\n ? password.match(validation) !== null\n : false;\n}\n\nexport function validateUserName(userName: any, expectedName: string): boolean {\n return (\n typeof userName === 'string' &&\n userName.split(':')[0] === 'org.couchdb.user' &&\n userName.split(':')[1] === expectedName\n );\n}\n"],"mappings":"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","ignoreList":[]}
1
+ {"version":3,"file":"validation-utils.js","names":[],"sources":["../src/validation-utils.ts"],"sourcesContent":["import assert from 'node:assert';\n\nimport type { Manifest } from '@verdaccio/types';\n\nimport { DEFAULT_PASSWORD_VALIDATION, DIST_TAGS, MAINTAINERS } from './constants';\n\nexport { validatePublishSingleVersion } from './schemes/publish-manifest';\nexport { validateUnPublishSingleVersion } from './schemes/unpublish-manifest';\n\nexport function isPackageNameScoped(name: string): boolean {\n return name.startsWith('@');\n}\n\n/**\n * From normalize-package-data/lib/fixer.js\n * @param {*} name the package name\n * @return {Boolean} whether is valid or not\n */\nexport function validateName(name: string): boolean {\n if (typeof name !== 'string') {\n return false;\n }\n\n let normalizedName: string = name.toLowerCase();\n\n const isScoped: boolean = isPackageNameScoped(name);\n const scopedName = name.split('/', 2)[1];\n\n if (isScoped && typeof scopedName !== 'undefined') {\n normalizedName = scopedName.toLowerCase();\n }\n\n /**\n * Some context about the first regex\n * - npm used to have a different tarball naming system.\n * eg: http://registry.npmjs.com/thirty-two\n * https://registry.npmjs.org/thirty-two/-/thirty-two@0.0.1.tgz\n * The file name thirty-two@0.0.1.tgz, the version and the pkg name was separated by an at (@)\n * while nowadays the naming system is based in dashes\n * https://registry.npmjs.org/verdaccio/-/verdaccio-1.4.0.tgz\n *\n * more info here: https://github.com/rlidwka/sinopia/issues/75\n */\n return !(\n !normalizedName.match(/^[-a-zA-Z0-9_.!~*'()@]+$/) ||\n normalizedName.startsWith('.') || // \".bin\", etc.\n ['node_modules', '__proto__', 'favicon.ico'].includes(normalizedName)\n );\n}\n\n/**\n * Validate a package.\n * @return {Boolean} whether the package is valid or not\n */\nexport function validatePackage(name: string): boolean {\n const nameList = name.split('/', 2);\n if (nameList.length === 1) {\n // normal package\n return validateName(nameList[0]);\n }\n // scoped package\n return nameList[0][0] === '@' && validateName(nameList[0].slice(1)) && validateName(nameList[1]);\n}\n\n/**\n * Validate the package metadata, add additional properties whether are missing within\n * the metadata properties.\n * @param {*} manifest\n * @param {*} name\n * @return {Object} the object with additional properties as dist-tags ad versions\n */\nexport function normalizeMetadata(manifest: Manifest, name: string): Manifest {\n assert.strictEqual(manifest.name, name);\n const _manifest = { ...manifest };\n\n if (!isObject(manifest[DIST_TAGS])) {\n _manifest[DIST_TAGS] = {};\n }\n\n if (!Array.isArray(manifest[MAINTAINERS])) {\n _manifest[MAINTAINERS] = [];\n }\n\n // This may not be needed\n if (!isObject(manifest['versions'])) {\n _manifest['versions'] = {};\n }\n\n if (!isObject(manifest['time'])) {\n _manifest['time'] = {};\n }\n\n return _manifest;\n}\n\n/**\n * Check whether an element is an Object\n * @param {*} obj the element\n * @return {Boolean}\n */\nexport function isObject(obj: any): boolean {\n // if (obj === null || typeof obj === 'undefined' || typeof obj === 'string') {\n // return false;\n // }\n\n // return (\n // (typeof obj === 'object' || typeof obj.prototype === 'undefined') &&\n // Array.isArray(obj) === false\n // );\n return Object.prototype.toString.call(obj) === '[object Object]';\n}\n\nexport function validatePassword(\n password: string,\n validation: RegExp = DEFAULT_PASSWORD_VALIDATION\n): boolean {\n return typeof password === 'string' && validation instanceof RegExp\n ? password.match(validation) !== null\n : false;\n}\n\nexport function validateUserName(userName: any, expectedName: string): boolean {\n return (\n typeof userName === 'string' &&\n userName.split(':')[0] === 'org.couchdb.user' &&\n userName.split(':')[1] === expectedName\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AASA,SAAgB,oBAAoB,MAAuB;CACzD,OAAO,KAAK,WAAW,GAAG;AAC5B;;;;;;AAOA,SAAgB,aAAa,MAAuB;CAClD,IAAI,OAAO,SAAS,UAClB,OAAO;CAGT,IAAI,iBAAyB,KAAK,YAAY;CAE9C,MAAM,WAAoB,oBAAoB,IAAI;CAClD,MAAM,aAAa,KAAK,MAAM,KAAK,CAAC,EAAE;CAEtC,IAAI,YAAY,OAAO,eAAe,aACpC,iBAAiB,WAAW,YAAY;;;;;;;;;;;;CAc1C,OAAO,EACL,CAAC,eAAe,MAAM,0BAA0B,KAChD,eAAe,WAAW,GAAG,KAC7B;EAAC;EAAgB;EAAa;CAAa,EAAE,SAAS,cAAc;AAExE;;;;;AAMA,SAAgB,gBAAgB,MAAuB;CACrD,MAAM,WAAW,KAAK,MAAM,KAAK,CAAC;CAClC,IAAI,SAAS,WAAW,GAEtB,OAAO,aAAa,SAAS,EAAE;CAGjC,OAAO,SAAS,GAAG,OAAO,OAAO,aAAa,SAAS,GAAG,MAAM,CAAC,CAAC,KAAK,aAAa,SAAS,EAAE;AACjG;;;;;;;;AASA,SAAgB,kBAAkB,UAAoB,MAAwB;CAC5E,YAAA,QAAO,YAAY,SAAS,MAAM,IAAI;CACtC,MAAM,YAAY,EAAE,GAAG,SAAS;CAEhC,IAAI,CAAC,SAAS,SAAA,YAAmB,GAC/B,UAAU,kBAAA,aAAa,CAAC;CAG1B,IAAI,CAAC,MAAM,QAAQ,SAAA,cAAqB,GACtC,UAAU,kBAAA,eAAe,CAAC;CAI5B,IAAI,CAAC,SAAS,SAAS,WAAW,GAChC,UAAU,cAAc,CAAC;CAG3B,IAAI,CAAC,SAAS,SAAS,OAAO,GAC5B,UAAU,UAAU,CAAC;CAGvB,OAAO;AACT;;;;;;AAOA,SAAgB,SAAS,KAAmB;CAS1C,OAAO,OAAO,UAAU,SAAS,KAAK,GAAG,MAAM;AACjD;AAEA,SAAgB,iBACd,UACA,aAAqB,kBAAA,6BACZ;CACT,OAAO,OAAO,aAAa,YAAY,sBAAsB,SACzD,SAAS,MAAM,UAAU,MAAM,OAC/B;AACN;AAEA,SAAgB,iBAAiB,UAAe,cAA+B;CAC7E,OACE,OAAO,aAAa,YACpB,SAAS,MAAM,GAAG,EAAE,OAAO,sBAC3B,SAAS,MAAM,GAAG,EAAE,OAAO;AAE/B"}
@@ -0,0 +1,91 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
+ import { DEFAULT_PASSWORD_VALIDATION, DIST_TAGS, MAINTAINERS } from "./constants.mjs";
3
+ import { validatePublishSingleVersion } from "./schemes/publish-manifest.mjs";
4
+ import { validateUnPublishSingleVersion } from "./schemes/unpublish-manifest.mjs";
5
+ import assert from "node:assert";
6
+ //#region src/validation-utils.ts
7
+ var validation_utils_exports = /* @__PURE__ */ __exportAll({
8
+ isObject: () => isObject,
9
+ isPackageNameScoped: () => isPackageNameScoped,
10
+ normalizeMetadata: () => normalizeMetadata,
11
+ validateName: () => validateName,
12
+ validatePackage: () => validatePackage,
13
+ validatePassword: () => validatePassword,
14
+ validatePublishSingleVersion: () => validatePublishSingleVersion,
15
+ validateUnPublishSingleVersion: () => validateUnPublishSingleVersion,
16
+ validateUserName: () => validateUserName
17
+ });
18
+ function isPackageNameScoped(name) {
19
+ return name.startsWith("@");
20
+ }
21
+ /**
22
+ * From normalize-package-data/lib/fixer.js
23
+ * @param {*} name the package name
24
+ * @return {Boolean} whether is valid or not
25
+ */
26
+ function validateName(name) {
27
+ if (typeof name !== "string") return false;
28
+ let normalizedName = name.toLowerCase();
29
+ const isScoped = isPackageNameScoped(name);
30
+ const scopedName = name.split("/", 2)[1];
31
+ if (isScoped && typeof scopedName !== "undefined") normalizedName = scopedName.toLowerCase();
32
+ /**
33
+ * Some context about the first regex
34
+ * - npm used to have a different tarball naming system.
35
+ * eg: http://registry.npmjs.com/thirty-two
36
+ * https://registry.npmjs.org/thirty-two/-/thirty-two@0.0.1.tgz
37
+ * The file name thirty-two@0.0.1.tgz, the version and the pkg name was separated by an at (@)
38
+ * while nowadays the naming system is based in dashes
39
+ * https://registry.npmjs.org/verdaccio/-/verdaccio-1.4.0.tgz
40
+ *
41
+ * more info here: https://github.com/rlidwka/sinopia/issues/75
42
+ */
43
+ return !(!normalizedName.match(/^[-a-zA-Z0-9_.!~*'()@]+$/) || normalizedName.startsWith(".") || [
44
+ "node_modules",
45
+ "__proto__",
46
+ "favicon.ico"
47
+ ].includes(normalizedName));
48
+ }
49
+ /**
50
+ * Validate a package.
51
+ * @return {Boolean} whether the package is valid or not
52
+ */
53
+ function validatePackage(name) {
54
+ const nameList = name.split("/", 2);
55
+ if (nameList.length === 1) return validateName(nameList[0]);
56
+ return nameList[0][0] === "@" && validateName(nameList[0].slice(1)) && validateName(nameList[1]);
57
+ }
58
+ /**
59
+ * Validate the package metadata, add additional properties whether are missing within
60
+ * the metadata properties.
61
+ * @param {*} manifest
62
+ * @param {*} name
63
+ * @return {Object} the object with additional properties as dist-tags ad versions
64
+ */
65
+ function normalizeMetadata(manifest, name) {
66
+ assert.strictEqual(manifest.name, name);
67
+ const _manifest = { ...manifest };
68
+ if (!isObject(manifest["dist-tags"])) _manifest[DIST_TAGS] = {};
69
+ if (!Array.isArray(manifest["maintainers"])) _manifest[MAINTAINERS] = [];
70
+ if (!isObject(manifest["versions"])) _manifest["versions"] = {};
71
+ if (!isObject(manifest["time"])) _manifest["time"] = {};
72
+ return _manifest;
73
+ }
74
+ /**
75
+ * Check whether an element is an Object
76
+ * @param {*} obj the element
77
+ * @return {Boolean}
78
+ */
79
+ function isObject(obj) {
80
+ return Object.prototype.toString.call(obj) === "[object Object]";
81
+ }
82
+ function validatePassword(password, validation = DEFAULT_PASSWORD_VALIDATION) {
83
+ return typeof password === "string" && validation instanceof RegExp ? password.match(validation) !== null : false;
84
+ }
85
+ function validateUserName(userName, expectedName) {
86
+ return typeof userName === "string" && userName.split(":")[0] === "org.couchdb.user" && userName.split(":")[1] === expectedName;
87
+ }
88
+ //#endregion
89
+ export { validation_utils_exports };
90
+
91
+ //# sourceMappingURL=validation-utils.mjs.map