@verdaccio/core 6.0.0-6-next.3 → 6.0.0-6-next.6

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 (49) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/build/constants.d.ts +15 -0
  3. package/build/constants.js +20 -2
  4. package/build/constants.js.map +1 -1
  5. package/build/error-utils.d.ts +2 -0
  6. package/build/error-utils.js +2 -0
  7. package/build/error-utils.js.map +1 -1
  8. package/build/file-utils.d.ts +13 -0
  9. package/build/file-utils.js +37 -0
  10. package/build/file-utils.js.map +1 -1
  11. package/build/index.d.ts +7 -6
  12. package/build/index.js +18 -17
  13. package/build/index.js.map +1 -1
  14. package/build/path-utils.js.map +1 -1
  15. package/build/pkg-utils.d.ts +11 -3
  16. package/build/pkg-utils.js +18 -0
  17. package/build/pkg-utils.js.map +1 -1
  18. package/build/plugin-utils.js.map +1 -1
  19. package/build/schemes/publish-manifest.d.ts +7 -0
  20. package/build/schemes/publish-manifest.js +49 -0
  21. package/build/schemes/publish-manifest.js.map +1 -0
  22. package/build/search-utils.d.ts +8 -4
  23. package/build/search-utils.js +2 -0
  24. package/build/search-utils.js.map +1 -1
  25. package/build/stream-utils.d.ts +1 -1
  26. package/build/stream-utils.js.map +1 -1
  27. package/build/validation-utils.d.ts +5 -3
  28. package/build/validation-utils.js +25 -14
  29. package/build/validation-utils.js.map +1 -1
  30. package/build/warning-utils.d.ts +0 -3
  31. package/build/warning-utils.js +2 -8
  32. package/build/warning-utils.js.map +1 -1
  33. package/package.json +61 -57
  34. package/src/constants.ts +18 -0
  35. package/src/error-utils.ts +3 -0
  36. package/src/file-utils.ts +26 -0
  37. package/src/index.ts +8 -6
  38. package/src/pkg-utils.ts +20 -3
  39. package/src/plugin-utils.ts +1 -0
  40. package/src/schemes/publish-manifest.ts +38 -0
  41. package/src/search-utils.ts +15 -4
  42. package/src/stream-utils.ts +1 -1
  43. package/src/validation-utils.ts +19 -13
  44. package/src/warning-utils.ts +2 -18
  45. package/test/errors.spec.ts +7 -7
  46. package/test/merge.dist.tags.spec.ts +1 -1
  47. package/test/mystreams.spec.ts +2 -1
  48. package/test/pkg-utils.spec.ts +42 -0
  49. package/test/validation-utilts.spec.ts +96 -2
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validatePublishSingleVersion = validatePublishSingleVersion;
7
+
8
+ var _ajv = _interopRequireDefault(require("ajv"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const ajv = new _ajv.default(); // FIXME: this could extend from @verdaccio/types but we need
13
+ // schemas from @verdaccio/types to be able to validate them
14
+
15
+ const schema = {
16
+ type: 'object',
17
+ properties: {
18
+ name: {
19
+ type: 'string'
20
+ },
21
+ versions: {
22
+ type: 'object',
23
+ maxProperties: 1
24
+ },
25
+ _attachments: {
26
+ type: 'object',
27
+ maxProperties: 1
28
+ }
29
+ },
30
+ required: ['name', 'versions', '_attachments'],
31
+ additionalProperties: true
32
+ }; // validate is a type guard for MyData - type is inferred from schema type
33
+
34
+ const validate = ajv.compile(schema);
35
+ /**
36
+ * Validate if a manifest has the correct structure when a new package
37
+ * is being created. The properties name, versions and _attachments must contain 1 element.
38
+ * @param data a manifest object
39
+ * @returns boolean
40
+ */
41
+
42
+ function validatePublishSingleVersion(manifest) {
43
+ if (!manifest) {
44
+ return false;
45
+ }
46
+
47
+ return validate(manifest);
48
+ }
49
+ //# sourceMappingURL=publish-manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish-manifest.js","names":["ajv","Ajv","schema","type","properties","name","versions","maxProperties","_attachments","required","additionalProperties","validate","compile","validatePublishSingleVersion","manifest"],"sources":["../../src/schemes/publish-manifest.ts"],"sourcesContent":["import Ajv, { JSONSchemaType } from 'ajv';\n\nconst ajv = new Ajv();\n\n// FIXME: this could extend from @verdaccio/types but we need\n// schemas from @verdaccio/types to be able to validate them\ninterface Manifest {\n name: string;\n versions: object;\n _attachments: object;\n}\n\nconst schema: JSONSchemaType<Manifest> = {\n type: 'object',\n properties: {\n name: { type: 'string' },\n versions: { type: 'object', maxProperties: 1 },\n _attachments: { type: 'object', maxProperties: 1 },\n },\n required: ['name', 'versions', '_attachments'],\n additionalProperties: true,\n};\n\n// validate is a type guard for MyData - type is inferred from schema type\nconst validate = ajv.compile(schema);\n\n/**\n * Validate if a manifest has the correct structure when a new package\n * is being created. The properties name, versions and _attachments must contain 1 element.\n * @param data a manifest object\n * @returns boolean\n */\nexport function validatePublishSingleVersion(manifest: any) {\n if (!manifest) {\n return false;\n }\n return validate(manifest);\n}\n"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,GAAG,GAAG,IAAIC,YAAJ,EAAZ,C,CAEA;AACA;;AAOA,MAAMC,MAAgC,GAAG;EACvCC,IAAI,EAAE,QADiC;EAEvCC,UAAU,EAAE;IACVC,IAAI,EAAE;MAAEF,IAAI,EAAE;IAAR,CADI;IAEVG,QAAQ,EAAE;MAAEH,IAAI,EAAE,QAAR;MAAkBI,aAAa,EAAE;IAAjC,CAFA;IAGVC,YAAY,EAAE;MAAEL,IAAI,EAAE,QAAR;MAAkBI,aAAa,EAAE;IAAjC;EAHJ,CAF2B;EAOvCE,QAAQ,EAAE,CAAC,MAAD,EAAS,UAAT,EAAqB,cAArB,CAP6B;EAQvCC,oBAAoB,EAAE;AARiB,CAAzC,C,CAWA;;AACA,MAAMC,QAAQ,GAAGX,GAAG,CAACY,OAAJ,CAAYV,MAAZ,CAAjB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASW,4BAAT,CAAsCC,QAAtC,EAAqD;EAC1D,IAAI,CAACA,QAAL,EAAe;IACb,OAAO,KAAP;EACD;;EACD,OAAOH,QAAQ,CAACG,QAAD,CAAf;AACD"}
@@ -14,10 +14,14 @@ export declare type SearchItemPkg = {
14
14
  path?: string;
15
15
  time?: number | Date;
16
16
  };
17
- export declare type SearchItem = {
17
+ declare type PrivatePackage = {
18
+ verdaccioPrivate?: boolean;
19
+ verdaccioPkgCached?: boolean;
20
+ };
21
+ export interface SearchItem extends UnStable, PrivatePackage {
18
22
  package: SearchItemPkg;
19
23
  score: Score;
20
- } & UnStable;
24
+ }
21
25
  export declare type Score = {
22
26
  final: number;
23
27
  detail: SearchMetrics;
@@ -48,11 +52,11 @@ export declare type SearchPackageBody = {
48
52
  publisher?: any;
49
53
  maintainers?: PublisherMaintainer[];
50
54
  };
51
- export declare type SearchPackageItem = {
55
+ export interface SearchPackageItem extends UnStable, PrivatePackage {
52
56
  package: SearchPackageBody;
53
57
  score: Score;
54
58
  searchScore?: number;
55
- } & UnStable;
59
+ }
56
60
  export declare const UNSCOPED = "unscoped";
57
61
  export declare type SearchQuery = {
58
62
  text: string;
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.UNSCOPED = void 0;
7
+ // @deprecated use @verdaccio/types
8
+ // @deprecated use @verdaccio/types
7
9
  const UNSCOPED = 'unscoped';
8
10
  exports.UNSCOPED = UNSCOPED;
9
11
  //# sourceMappingURL=search-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/search-utils.ts"],"names":["UNSCOPED"],"mappings":";;;;;;AA+DO,MAAMA,QAAQ,GAAG,UAAjB","sourcesContent":["export type SearchMetrics = {\n quality: number;\n popularity: number;\n maintenance: number;\n};\nexport type UnStable = {\n flags?: {\n // if is false is not be included in search results (majority are stable)\n unstable?: boolean;\n };\n};\nexport type SearchItemPkg = {\n name: string;\n scoped?: string;\n path?: string;\n time?: number | Date;\n};\n\nexport type SearchItem = {\n package: SearchItemPkg;\n score: Score;\n} & UnStable;\n\nexport type Score = {\n final: number;\n detail: SearchMetrics;\n};\n\nexport type SearchResults = {\n objects: SearchItemPkg[];\n total: number;\n time: string;\n};\n\ntype PublisherMaintainer = {\n username: string;\n email: string;\n};\n\nexport type SearchPackageBody = {\n name: string;\n scope: string;\n description: string;\n author: string | PublisherMaintainer;\n version: string;\n keywords: string | string[] | undefined;\n date: string;\n links?: {\n npm: string; // only include placeholder for URL eg: {url}/{packageName}\n homepage?: string;\n repository?: string;\n bugs?: string;\n };\n publisher?: any;\n maintainers?: PublisherMaintainer[];\n};\n\nexport type SearchPackageItem = {\n package: SearchPackageBody;\n score: Score;\n searchScore?: number;\n} & UnStable;\n\nexport const UNSCOPED = 'unscoped';\n\nexport type SearchQuery = {\n text: string;\n size?: number;\n from?: number;\n} & SearchMetrics;\n"],"file":"search-utils.js"}
1
+ {"version":3,"file":"search-utils.js","names":["UNSCOPED"],"sources":["../src/search-utils.ts"],"sourcesContent":["export type SearchMetrics = {\n quality: number;\n popularity: number;\n maintenance: number;\n};\nexport type UnStable = {\n flags?: {\n // if is false is not be included in search results (majority are stable)\n unstable?: boolean;\n };\n};\nexport type SearchItemPkg = {\n name: string;\n scoped?: string;\n path?: string;\n time?: number | Date;\n};\n\ntype PrivatePackage = {\n // note: prefixed to avoid external conflicts\n\n // the package is published as private\n verdaccioPrivate?: boolean;\n // if the package is not private but is cached\n verdaccioPkgCached?: boolean;\n};\n\nexport interface SearchItem extends UnStable, PrivatePackage {\n package: SearchItemPkg;\n score: Score;\n}\n\nexport type Score = {\n final: number;\n detail: SearchMetrics;\n};\n\nexport type SearchResults = {\n objects: SearchItemPkg[];\n total: number;\n time: string;\n};\n\n// @deprecated use @verdaccio/types\ntype PublisherMaintainer = {\n username: string;\n email: string;\n};\n\n// @deprecated use @verdaccio/types\nexport type SearchPackageBody = {\n name: string;\n scope: string;\n description: string;\n author: string | PublisherMaintainer;\n version: string;\n keywords: string | string[] | undefined;\n date: string;\n links?: {\n npm: string; // only include placeholder for URL eg: {url}/{packageName}\n homepage?: string;\n repository?: string;\n bugs?: string;\n };\n publisher?: any;\n maintainers?: PublisherMaintainer[];\n};\n\nexport interface SearchPackageItem extends UnStable, PrivatePackage {\n package: SearchPackageBody;\n score: Score;\n searchScore?: number;\n}\n\nexport const UNSCOPED = 'unscoped';\n\nexport type SearchQuery = {\n text: string;\n size?: number;\n from?: number;\n} & SearchMetrics;\n"],"mappings":";;;;;;AA2CA;AAMA;AAyBO,MAAMA,QAAQ,GAAG,UAAjB"}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { PassThrough, TransformOptions, Transform } from 'stream';
2
+ import { PassThrough, Transform, TransformOptions } from 'stream';
3
3
  export interface IReadTarball {
4
4
  abort?: () => void;
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/stream-utils.ts"],"names":["ReadTarball","PassThrough","constructor","options","addAbstractMethods","abort","UploadTarball","done","self","name","_called_methods","__defineGetter__","__defineSetter__","fn","readableToString","stream","chunks","chunk","push","Buffer","from","buffer","concat","str","toString","transformObjectToString","Transform","objectMode","transform","encoding","callback","JSON","stringify"],"mappings":";;;;;;;AAAA;;AAWA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAN,SAA0BC,mBAA1B,CAA8D;AAC5D;AACF;AACA;AACA;AACSC,EAAAA,WAAW,CAACC,OAAD,EAA4B;AAC5C,UAAMA,OAAN,EAD4C,CAE5C;;AACAC,IAAAA,kBAAkB,CAAC,IAAD,EAAO,OAAP,CAAlB;AACD;;AAEMC,EAAAA,KAAK,GAAS,CAAE;;AAXqC;AAc9D;AACA;AACA;AACA;AACA;;;;;AACA,MAAMC,aAAN,SAA4BL,mBAA5B,CAAkE;AAChE;AACF;AACA;AACA;AACSC,EAAAA,WAAW,CAACC,OAAD,EAAe;AAC/B,UAAMA,OAAN,EAD+B,CAE/B;;AACAC,IAAAA,kBAAkB,CAAC,IAAD,EAAO,OAAP,CAAlB,CAH+B,CAK/B;;AACAA,IAAAA,kBAAkB,CAAC,IAAD,EAAO,MAAP,CAAlB;AACD;;AAEMC,EAAAA,KAAK,GAAS,CAAE;;AAChBE,EAAAA,IAAI,GAAS,CAAE;;AAf0C;AAkBlE;AACA;AACA;AACA;AACA;AACA;AACA;;;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Y,QAAR,EAAkBC,QAAlB,KAA+B;AACxCA,MAAAA,QAAQ,CAAC,IAAD,EAAOC,IAAI,CAACC,SAAL,CAAef,KAAf,CAAP,CAAR;AACD;AAJkB,GAAd,CAAP;AAMD,CAPD","sourcesContent":["import { PassThrough, TransformOptions, Transform } from 'stream';\n\nexport interface IReadTarball {\n abort?: () => void;\n}\n\nexport interface IUploadTarball {\n done?: () => void;\n abort?: () => void;\n}\n\n/**\n * This stream is used to read tarballs from repository.\n * @param {*} options\n * @return {Stream}\n */\nclass ReadTarball extends PassThrough implements IReadTarball {\n /**\n *\n * @param {Object} options\n */\n public constructor(options: TransformOptions) {\n super(options);\n // called when data is not needed anymore\n addAbstractMethods(this, 'abort');\n }\n\n public abort(): void {}\n}\n\n/**\n * This stream is used to upload tarballs to a repository.\n * @param {*} options\n * @return {Stream}\n */\nclass UploadTarball extends PassThrough implements IUploadTarball {\n /**\n *\n * @param {Object} options\n */\n public constructor(options: any) {\n super(options);\n // called when user closes connection before upload finishes\n addAbstractMethods(this, 'abort');\n\n // called when upload finishes successfully\n addAbstractMethods(this, 'done');\n }\n\n public abort(): void {}\n public done(): void {}\n}\n\n/**\n * This function intercepts abstract calls and replays them allowing.\n * us to attach those functions after we are ready to do so\n * @param {*} self\n * @param {*} name\n */\n// Perhaps someone knows a better way to write this\nfunction addAbstractMethods(self: any, name: any): void {\n self._called_methods = self._called_methods || {};\n\n self.__defineGetter__(name, function () {\n return function (): void {\n self._called_methods[name] = true;\n };\n });\n\n self.__defineSetter__(name, function (fn: any) {\n delete self[name];\n\n self[name] = fn;\n\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (self._called_methods && self._called_methods[name]) {\n delete self._called_methods[name];\n\n self[name]();\n }\n });\n}\n\n/**\n * Converts a buffer stream to a string.\n */\nconst readableToString = async (stream) => {\n const chunks: Buffer[] = [];\n for await (let chunk of stream) {\n chunks.push(Buffer.from(chunk));\n }\n const buffer = Buffer.concat(chunks);\n const str = buffer.toString('utf-8');\n return str;\n};\n\n/**\n * Transform stream object mode to string\n **/\nconst transformObjectToString = () => {\n return new Transform({\n objectMode: true,\n transform: (chunk, encoding, callback) => {\n callback(null, JSON.stringify(chunk));\n },\n });\n};\n\nexport { ReadTarball, UploadTarball, readableToString, transformObjectToString };\n"],"file":"stream-utils.js"}
1
+ {"version":3,"file":"stream-utils.js","names":["ReadTarball","PassThrough","constructor","options","addAbstractMethods","abort","UploadTarball","done","self","name","_called_methods","__defineGetter__","__defineSetter__","fn","readableToString","stream","chunks","chunk","push","Buffer","from","buffer","concat","str","toString","transformObjectToString","Transform","objectMode","transform","encoding","callback","JSON","stringify"],"sources":["../src/stream-utils.ts"],"sourcesContent":["import { PassThrough, Transform, TransformOptions } from 'stream';\n\nexport interface IReadTarball {\n abort?: () => void;\n}\n\nexport interface IUploadTarball {\n done?: () => void;\n abort?: () => void;\n}\n\n/**\n * This stream is used to read tarballs from repository.\n * @param {*} options\n * @return {Stream}\n */\nclass ReadTarball extends PassThrough implements IReadTarball {\n /**\n *\n * @param {Object} options\n */\n public constructor(options: TransformOptions) {\n super(options);\n // called when data is not needed anymore\n addAbstractMethods(this, 'abort');\n }\n\n public abort(): void {}\n}\n\n/**\n * This stream is used to upload tarballs to a repository.\n * @param {*} options\n * @return {Stream}\n */\nclass UploadTarball extends PassThrough implements IUploadTarball {\n /**\n *\n * @param {Object} options\n */\n public constructor(options: any) {\n super(options);\n // called when user closes connection before upload finishes\n addAbstractMethods(this, 'abort');\n\n // called when upload finishes successfully\n addAbstractMethods(this, 'done');\n }\n\n public abort(): void {}\n public done(): void {}\n}\n\n/**\n * This function intercepts abstract calls and replays them allowing.\n * us to attach those functions after we are ready to do so\n * @param {*} self\n * @param {*} name\n */\n// Perhaps someone knows a better way to write this\nfunction addAbstractMethods(self: any, name: any): void {\n self._called_methods = self._called_methods || {};\n\n self.__defineGetter__(name, function () {\n return function (): void {\n self._called_methods[name] = true;\n };\n });\n\n self.__defineSetter__(name, function (fn: any) {\n delete self[name];\n\n self[name] = fn;\n\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (self._called_methods && self._called_methods[name]) {\n delete self._called_methods[name];\n\n self[name]();\n }\n });\n}\n\n/**\n * Converts a buffer stream to a string.\n */\nconst readableToString = async (stream) => {\n const chunks: Buffer[] = [];\n for await (let chunk of stream) {\n chunks.push(Buffer.from(chunk));\n }\n const buffer = Buffer.concat(chunks);\n const str = buffer.toString('utf-8');\n return str;\n};\n\n/**\n * Transform stream object mode to string\n **/\nconst transformObjectToString = () => {\n return new Transform({\n objectMode: true,\n transform: (chunk, encoding, callback) => {\n callback(null, JSON.stringify(chunk));\n },\n });\n};\n\nexport { ReadTarball, UploadTarball, readableToString, transformObjectToString };\n"],"mappings":";;;;;;;AAAA;;AAWA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAN,SAA0BC,mBAA1B,CAA8D;EAC5D;AACF;AACA;AACA;EACSC,WAAW,CAACC,OAAD,EAA4B;IAC5C,MAAMA,OAAN,EAD4C,CAE5C;;IACAC,kBAAkB,CAAC,IAAD,EAAO,OAAP,CAAlB;EACD;;EAEMC,KAAK,GAAS,CAAE;;AAXqC;AAc9D;AACA;AACA;AACA;AACA;;;;;AACA,MAAMC,aAAN,SAA4BL,mBAA5B,CAAkE;EAChE;AACF;AACA;AACA;EACSC,WAAW,CAACC,OAAD,EAAe;IAC/B,MAAMA,OAAN,EAD+B,CAE/B;;IACAC,kBAAkB,CAAC,IAAD,EAAO,OAAP,CAAlB,CAH+B,CAK/B;;IACAA,kBAAkB,CAAC,IAAD,EAAO,MAAP,CAAlB;EACD;;EAEMC,KAAK,GAAS,CAAE;;EAChBE,IAAI,GAAS,CAAE;;AAf0C;AAkBlE;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACA,SAASH,kBAAT,CAA4BI,IAA5B,EAAuCC,IAAvC,EAAwD;EACtDD,IAAI,CAACE,eAAL,GAAuBF,IAAI,CAACE,eAAL,IAAwB,EAA/C;;EAEAF,IAAI,CA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daccio/types';
2
+ export { validatePublishSingleVersion } from './schemes/publish-manifest';
2
3
  export declare function isPackageNameScoped(name: string): boolean;
3
4
  /**
4
5
  * From normalize-package-data/lib/fixer.js
@@ -14,11 +15,12 @@ export declare function validatePackage(name: string): boolean;
14
15
  /**
15
16
  * Validate the package metadata, add additional properties whether are missing within
16
17
  * the metadata properties.
17
- * @param {*} object
18
+ * @param {*} manifest
18
19
  * @param {*} name
19
20
  * @return {Object} the object with additional properties as dist-tags ad versions
21
+ * FUTURE: rename to normalizeMetadata
20
22
  */
21
- export declare function validateMetadata(object: Package, name: string): Package;
23
+ export declare function normalizeMetadata(manifest: Manifest, name: string): Manifest;
22
24
  /**
23
25
  * Check whether an element is an Object
24
26
  * @param {*} obj the element
@@ -5,14 +5,22 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isObject = isObject;
7
7
  exports.isPackageNameScoped = isPackageNameScoped;
8
- exports.validateMetadata = validateMetadata;
8
+ exports.normalizeMetadata = normalizeMetadata;
9
9
  exports.validateName = validateName;
10
10
  exports.validatePackage = validatePackage;
11
+ Object.defineProperty(exports, "validatePublishSingleVersion", {
12
+ enumerable: true,
13
+ get: function () {
14
+ return _publishManifest.validatePublishSingleVersion;
15
+ }
16
+ });
11
17
 
12
18
  var _assert = _interopRequireDefault(require("assert"));
13
19
 
14
20
  var _constants = require("./constants");
15
21
 
22
+ var _publishManifest = require("./schemes/publish-manifest");
23
+
16
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
25
 
18
26
  function isPackageNameScoped(name) {
@@ -73,30 +81,33 @@ function validatePackage(name) {
73
81
  /**
74
82
  * Validate the package metadata, add additional properties whether are missing within
75
83
  * the metadata properties.
76
- * @param {*} object
84
+ * @param {*} manifest
77
85
  * @param {*} name
78
86
  * @return {Object} the object with additional properties as dist-tags ad versions
87
+ * FUTURE: rename to normalizeMetadata
79
88
  */
80
89
 
81
90
 
82
- function validateMetadata(object, name) {
83
- (0, _assert.default)(isObject(object), 'not a json object');
91
+ function normalizeMetadata(manifest, name) {
92
+ _assert.default.strictEqual(manifest.name, name);
84
93
 
85
- _assert.default.strictEqual(object.name, name);
94
+ const _manifest = { ...manifest
95
+ };
96
+
97
+ if (!isObject(manifest[_constants.DIST_TAGS])) {
98
+ _manifest[_constants.DIST_TAGS] = {};
99
+ } // This may not be nee dit
86
100
 
87
- if (!isObject(object[_constants.DIST_TAGS])) {
88
- object[_constants.DIST_TAGS] = {};
89
- }
90
101
 
91
- if (!isObject(object['versions'])) {
92
- object['versions'] = {};
102
+ if (!isObject(manifest['versions'])) {
103
+ _manifest['versions'] = {};
93
104
  }
94
105
 
95
- if (!isObject(object['time'])) {
96
- object['time'] = {};
106
+ if (!isObject(manifest['time'])) {
107
+ _manifest['time'] = {};
97
108
  }
98
109
 
99
- return object;
110
+ return _manifest;
100
111
  }
101
112
  /**
102
113
  * Check whether an element is an Object
@@ -106,7 +117,7 @@ function validateMetadata(object, name) {
106
117
 
107
118
 
108
119
  function isObject(obj) {
109
- if (obj === null || typeof obj === 'undefined') {
120
+ if (obj === null || typeof obj === 'undefined' || typeof obj === 'string') {
110
121
  return false;
111
122
  }
112
123
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/validation-utils.ts"],"names":["isPackageNameScoped","name","startsWith","validateName","normalizedName","toLowerCase","isScoped","scopedName","split","match","includes","validatePackage","nameList","length","slice","validateMetadata","object","isObject","assert","strictEqual","DIST_TAGS","obj","prototype","Array","isArray"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;;;AAEO,SAASA,mBAAT,CAA6BC,IAA7B,EAAoD;AACzD,SAAOA,IAAI,CAACC,UAAL,CAAgB,GAAhB,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASC,YAAT,CAAsBF,IAAtB,EAA6C;AAClD,MAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;AAC5B,WAAO,KAAP;AACD;;AAED,MAAIG,cAAsB,GAAGH,IAAI,CA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,EAAgCA,IAAhC;;AAEA,MAAI,CAACgB,QAAQ,CAACD,MAAM,CAACI,oBAAD,CAAP,CAAb,EAAkC;AAChCJ,IAAAA,MAAM,CAACI,oBAAD,CAAN,GAAoB,EAApB;AACD;;AAED,MAAI,CAACH,QAAQ,CAACD,MAAM,CAAC,UAAD,CAAP,CAAb,EAAmC;AACjCA,IAAAA,MAAM,CAAC,UAAD,CAAN,GAAqB,EAArB;AACD;;AAED,MAAI,CAACC,QAAQ,CAACD,MAAM,CAAC,MAAD,CAAP,CAAb,EAA+B;AAC7BA,IAAAA,MAAM,CAAC,MAAD,CAAN,GAAiB,EAAjB;AACD;;AAED,SAAOA,MAAP;AACD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASC,QAAT,CAAkBI,GAAlB,EAAqC;AAC1C,MAAIA,GAAG,KAAK,IAAR,IAAgB,OAAOA,GAAP,KAAe,WAAnC,EAAgD;AAC9C,WAAO,KAAP;AACD;;AAED,SACE,CAAC,OAAOA,GAAP,KAAe,QAAf,IAA2B,OAAOA,GAAG,CAACC,SAAX,KAAyB,WAArD,KACAC,KAAK,CAACC,OAAN,CAAcH,GAAd,MAAuB,KAFzB;AAID","sourcesContent":["import assert from 'assert';\nimport { Package } from '@verdaccio/types';\nimport { DIST_TAGS } from './constants';\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 {*} object\n * @param {*} name\n * @return {Object} the object with additional properties as dist-tags ad versions\n */\nexport function validateMetadata(object: Package, name: string): Package {\n assert(isObject(object), 'not a json object');\n assert.strictEqual(object.name, name);\n\n if (!isObject(object[DIST_TAGS])) {\n object[DIST_TAGS] = {};\n }\n\n if (!isObject(object['versions'])) {\n object['versions'] = {};\n }\n\n if (!isObject(object['time'])) {\n object['time'] = {};\n }\n\n return object;\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') {\n return false;\n }\n\n return (\n (typeof obj === 'object' || typeof obj.prototype === 'undefined') &&\n Array.isArray(obj) === false\n );\n}\n"],"file":"validation-utils.js"}
1
+ {"version":3,"file":"validation-utils.js","names":["isPackageNameScoped","name","startsWith","validateName","normalizedName","toLowerCase","isScoped","scopedName","split","match","includes","validatePackage","nameList","length","slice","normalizeMetadata","manifest","assert","strictEqual","_manifest","isObject","DIST_TAGS","obj","prototype","Array","isArray"],"sources":["../src/validation-utils.ts"],"sourcesContent":["import assert from 'assert';\n\nimport { Manifest } from '@verdaccio/types';\n\nimport { DIST_TAGS } from './constants';\n\nexport { validatePublishSingleVersion } from './schemes/publish-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 * FUTURE: rename to normalizeMetadata\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 // This may not be nee dit\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}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AAIA;;AAEA;;;;AAEO,SAASA,mBAAT,CAA6BC,IAA7B,EAAoD;EACzD,OAAOA,IAAI,CAACC,UAAL,CAAgB,GAAhB,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASC,YAAT,CAAsBF,IAAtB,EAA6C;EAClD,IAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;IAC5B,OAAO,KAAP;EACD;;EAED,IAAIG,cAAsB,GAAGH,IAAI,CAACI,WAAL,EAA7B;EAEA,MAAMC,QAAiB,GAAGN,mBAAmB,CAACC,IAAD,CAA7C;EACA,MAAMM,UAAU,GAAGN,IAAI,CAACO,KAAL,CAAW,GAAX,EAAgB,CAAhB,EAAmB,CAAnB,CAAnB;;EAEA,IAAIF,QAAQ,IAAI,OAAOC,UAAP,KAAsB,WAAtC,EAAmD;IACjDH,cAAc,GAAGG,UAAU,CAACF,WAAX,EAAjB;EACD;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;EACE,OAAO,EACL,CAACD,cAAc,CAACK,KAAf,CAAqB,0BAArB,CAAD,IACAL,cAAc,CAACF,UAAf,CAA0B,GAA1B,CADA,IACkC;EAClC,CAAC,cAAD,EAAiB,WAAjB,EAA8B,aAA9B,EAA6CQ,QAA7C,CAAsDN,cAAtD,CAHK,CAAP;AAKD;AAED;AACA;AACA;AACA;;;AACO,SAASO,e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A,GAAP,KAAe,QAAjE,EAA2E;IACzE,OAAO,KAAP;EACD;;EAED,OACE,CAAC,OAAOA,GAAP,KAAe,QAAf,IAA2B,OAAOA,GAAG,CAACC,SAAX,KAAyB,WAArD,KACAC,KAAK,CAACC,OAAN,CAAcH,GAAd,MAAuB,KAFzB;AAID"}
@@ -1,10 +1,7 @@
1
1
  export declare enum Codes {
2
2
  VERWAR001 = "VERWAR001",
3
- VERWAR002 = "VERWAR002",
4
3
  VERWAR003 = "VERWAR003",
5
4
  VERWAR004 = "VERWAR004",
6
- VERDEP001 = "VERDEP001",
7
- VERDEP002 = "VERDEP002",
8
5
  VERDEP003 = "VERDEP003"
9
6
  }
10
7
  export declare function emit(code: any, a?: string, b?: string, c?: string): void;
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.Codes = void 0;
7
7
  exports.emit = emit;
8
8
 
9
- var _fastifyWarning = _interopRequireDefault(require("fastify-warning"));
9
+ var _processWarning = _interopRequireDefault(require("process-warning"));
10
10
 
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
12
 
13
- const warningInstance = (0, _fastifyWarning.default)();
13
+ const warningInstance = (0, _processWarning.default)();
14
14
  const verdaccioWarning = 'VerdaccioWarning';
15
15
  const verdaccioDeprecation = 'VerdaccioDeprecation';
16
16
  let Codes;
@@ -18,22 +18,16 @@ exports.Codes = Codes;
18
18
 
19
19
  (function (Codes) {
20
20
  Codes["VERWAR001"] = "VERWAR001";
21
- Codes["VERWAR002"] = "VERWAR002";
22
21
  Codes["VERWAR003"] = "VERWAR003";
23
22
  Codes["VERWAR004"] = "VERWAR004";
24
- Codes["VERDEP001"] = "VERDEP001";
25
- Codes["VERDEP002"] = "VERDEP002";
26
23
  Codes["VERDEP003"] = "VERDEP003";
27
24
  })(Codes || (exports.Codes = Codes = {}));
28
25
 
29
26
  warningInstance.create(verdaccioWarning, Codes.VERWAR001, `Verdaccio doesn't need superuser privileges. don't run it under root`);
30
- warningInstance.create(verdaccioWarning, Codes.VERWAR002, 'logger is not defined');
31
27
  warningInstance.create(verdaccioWarning, Codes.VERWAR003, 'rotating-file type is not longer supported, consider use [logrotate] instead');
32
28
  warningInstance.create(verdaccioWarning, Codes.VERWAR004, `invalid address - %s, we expect a port (e.g. "4873"),
33
29
  host:port (e.g. "localhost:4873") or full url '(e.g. "http://localhost:4873/")
34
30
  https://verdaccio.org/docs/en/configuration#listen-port`);
35
- warningInstance.create(verdaccioDeprecation, Codes.VERDEP001, 'config.logs is deprecated, rename configuration to "config.log" in singular');
36
- warningInstance.create(verdaccioDeprecation, Codes.VERDEP002, 'deprecate: multiple logger configuration is deprecated, please check the migration guide.');
37
31
  warningInstance.create(verdaccioDeprecation, Codes.VERDEP003, 'multiple addresses will be deprecated in the next major, only use one');
38
32
 
39
33
  function emit(code, a, b, c) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/warning-utils.ts"],"names":["warningInstance","verdaccioWarning","verdaccioDeprecation","Codes","create","VERWAR001","VERWAR002","VERWAR003","VERWAR004","VERDEP001","VERDEP002","VERDEP003","emit","code","a","b","c"],"mappings":";;;;;;;;AAAA;;;;AAEA,MAAMA,eAAe,GAAG,8BAAxB;AACA,MAAMC,gBAAgB,GAAG,kBAAzB;AACA,MAAMC,oBAAoB,GAAG,sBAA7B;IAEYC,K;;;WAAAA,K;AAAAA,EAAAA,K;AAAAA,EAAAA,K;AAAAA,EAAAA,K;AAAAA,EAAAA,K;AAAAA,EAAAA,K;AAAAA,EAAAA,K;AAAAA,EAAAA,K;GAAAA,K,qBAAAA,K;;AAUZH,eAAe,CAACI,MAAhB,CACEH,gBADF,EAEEE,KAAK,CAACE,SAFR,EAGG,sEAHH;AAMAL,eAAe,CAACI,MAAhB,CAAuBH,gBAAvB,EAAyCE,KAAK,CAACG,SAA/C,EAA0D,uBAA1D;AAEAN,eAAe,CAACI,MAAhB,CACEH,gBADF,EAEEE,KAAK,CAACI,SAFR,EAGE,8EAHF;AAMAP,eAAe,CAACI,MAAhB,CACEH,gBADF,EAEEE,KAAK,CAACK,SAFR,EAGG;AACH;AACA,wDALA;AAQAR,eAAe,CAACI,MAAhB,CACEF,oBADF,EAEEC,KAAK,CAACM,SAFR,EAGE,6EAHF;AAMAT,eAAe,CAACI,MAAhB,CACEF,oBADF,EAEEC,KAAK,CAACO,SAFR,EAGE,2FAHF;AAMAV,eAAe,CAACI,MAAhB,CACEF,oBADF,EAEEC,KAAK,CAACQ,SAFR,EAGE,uEAHF;;AAMO,SAASC,IAAT,CAAcC,IAAd,EAAoBC,CAApB,EAAgCC,CAAhC,EAA4CC,CAA5C,EAAwD;AAC7DhB,EAAAA,eAAe,CAACY,IAAhB,CAAqBC,IAArB,EAA2BC,CAA3B,EAA8BC,CAA9B,EAAiCC,CAAjC;AACD","sourcesContent":["import warning from 'fastify-warning';\n\nconst warningInstance = warning();\nconst verdaccioWarning = 'VerdaccioWarning';\nconst verdaccioDeprecation = 'VerdaccioDeprecation';\n\nexport enum Codes {\n VERWAR001 = 'VERWAR001',\n VERWAR002 = 'VERWAR002',\n VERWAR003 = 'VERWAR003',\n VERWAR004 = 'VERWAR004',\n VERDEP001 = 'VERDEP001',\n VERDEP002 = 'VERDEP002',\n VERDEP003 = 'VERDEP003',\n}\n\nwarningInstance.create(\n verdaccioWarning,\n Codes.VERWAR001,\n `Verdaccio doesn't need superuser privileges. don't run it under root`\n);\n\nwarningInstance.create(verdaccioWarning, Codes.VERWAR002, 'logger is not defined');\n\nwarningInstance.create(\n verdaccioWarning,\n Codes.VERWAR003,\n 'rotating-file type is not longer supported, consider use [logrotate] instead'\n);\n\nwarningInstance.create(\n verdaccioWarning,\n Codes.VERWAR004,\n `invalid address - %s, we expect a port (e.g. \"4873\"), \nhost:port (e.g. \"localhost:4873\") or full url '(e.g. \"http://localhost:4873/\")\nhttps://verdaccio.org/docs/en/configuration#listen-port`\n);\n\nwarningInstance.create(\n verdaccioDeprecation,\n Codes.VERDEP001,\n 'config.logs is deprecated, rename configuration to \"config.log\" in singular'\n);\n\nwarningInstance.create(\n verdaccioDeprecation,\n Codes.VERDEP002,\n 'deprecate: multiple logger configuration is deprecated, please check the migration guide.'\n);\n\nwarningInstance.create(\n verdaccioDeprecation,\n Codes.VERDEP003,\n 'multiple addresses will be deprecated in the next major, only use one'\n);\n\nexport function emit(code, a?: string, b?: string, c?: string) {\n warningInstance.emit(code, a, b, c);\n}\n"],"file":"warning-utils.js"}
1
+ {"version":3,"file":"warning-utils.js","names":["warningInstance","warning","verdaccioWarning","verdaccioDeprecation","Codes","create","VERWAR001","VERWAR003","VERWAR004","VERDEP003","emit","code","a","b","c"],"sources":["../src/warning-utils.ts"],"sourcesContent":["import warning from 'process-warning';\n\nconst warningInstance = warning();\nconst verdaccioWarning = 'VerdaccioWarning';\nconst verdaccioDeprecation = 'VerdaccioDeprecation';\n\nexport enum Codes {\n VERWAR001 = 'VERWAR001',\n VERWAR003 = 'VERWAR003',\n VERWAR004 = 'VERWAR004',\n // deprecation warnings\n VERDEP003 = 'VERDEP003',\n}\n\nwarningInstance.create(\n verdaccioWarning,\n Codes.VERWAR001,\n `Verdaccio doesn't need superuser privileges. don't run it under root`\n);\n\nwarningInstance.create(\n verdaccioWarning,\n Codes.VERWAR003,\n 'rotating-file type is not longer supported, consider use [logrotate] instead'\n);\n\nwarningInstance.create(\n verdaccioWarning,\n Codes.VERWAR004,\n `invalid address - %s, we expect a port (e.g. \"4873\"), \nhost:port (e.g. \"localhost:4873\") or full url '(e.g. \"http://localhost:4873/\")\nhttps://verdaccio.org/docs/en/configuration#listen-port`\n);\n\nwarningInstance.create(\n verdaccioDeprecation,\n Codes.VERDEP003,\n 'multiple addresses will be deprecated in the next major, only use one'\n);\n\nexport function emit(code, a?: string, b?: string, c?: string) {\n warningInstance.emit(code, a, b, c);\n}\n"],"mappings":";;;;;;;;AAAA;;;;AAEA,MAAMA,eAAe,GAAG,IAAAC,uBAAA,GAAxB;AACA,MAAMC,gBAAgB,GAAG,kBAAzB;AACA,MAAMC,oBAAoB,GAAG,sBAA7B;IAEYC,K;;;WAAAA,K;EAAAA,K;EAAAA,K;EAAAA,K;EAAAA,K;GAAAA,K,qBAAAA,K;;AAQZJ,eAAe,CAACK,MAAhB,CACEH,gBADF,EAEEE,KAAK,CAACE,SAFR,EAGG,sEAHH;AAMAN,eAAe,CAACK,MAAhB,CACEH,gBADF,EAEEE,KAAK,CAACG,SAFR,EAGE,8EAHF;AAMAP,eAAe,CAACK,MAAhB,CACEH,gBADF,EAEEE,KAAK,CAACI,SAFR,EAGG;AACH;AACA,wDALA;AAQAR,eAAe,CAACK,MAAhB,CACEF,oBADF,EAEEC,KAAK,CAACK,SAFR,EAGE,uEAHF;;AAMO,SAASC,IAAT,CAAcC,IAAd,EAAoBC,CAApB,EAAgCC,CAAhC,EAA4CC,CAA5C,EAAwD;EAC7Dd,eAAe,CAACU,IAAhB,CAAqBC,IAArB,EAA2BC,CAA3B,EAA8BC,CAA9B,EAAiCC,CAAjC;AACD"}
package/package.json CHANGED
@@ -1,58 +1,62 @@
1
1
  {
2
- "name": "@verdaccio/core",
3
- "version": "6.0.0-6-next.3",
4
- "description": "core utilities",
5
- "keywords": [
6
- "private",
7
- "package",
8
- "repository",
9
- "registry",
10
- "enterprise",
11
- "modules",
12
- "proxy",
13
- "server",
14
- "verdaccio"
15
- ],
16
- "main": "./build/index.js",
17
- "types": "./build/index.d.ts",
18
- "author": "Juan Picado <juanpicado19@gmail.com>",
19
- "license": "MIT",
20
- "homepage": "https://verdaccio.org",
21
- "engines": {
22
- "node": ">=14",
23
- "npm": ">=6"
24
- },
25
- "repository": {
26
- "type": "https",
27
- "url": "https://github.com/verdaccio/verdaccio",
28
- "directory": "packages/core/core"
29
- },
30
- "bugs": {
31
- "url": "https://github.com/verdaccio/verdaccio/issues"
32
- },
33
- "publishConfig": {
34
- "access": "public"
35
- },
36
- "dependencies": {
37
- "http-errors": "1.8.0",
38
- "http-status-codes": "2.1.4",
39
- "semver": "7.3.5",
40
- "fastify-warning": "0.2.0"
41
- },
42
- "devDependencies": {
43
- "@verdaccio/types": "11.0.0-6-next.9"
44
- },
45
- "funding": {
46
- "type": "opencollective",
47
- "url": "https://opencollective.com/verdaccio"
48
- },
49
- "scripts": {
50
- "clean": "rimraf ./build",
51
- "test": "cross-env NODE_ENV=test BABEL_ENV=test jest",
52
- "type-check": "tsc --noEmit -p tsconfig.build.json",
53
- "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
54
- "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
55
- "watch": "pnpm build:js -- --watch",
56
- "build": "pnpm run build:js && pnpm run build:types"
57
- }
58
- }
2
+ "name": "@verdaccio/core",
3
+ "version": "6.0.0-6-next.6",
4
+ "description": "core utilities",
5
+ "keywords": [
6
+ "private",
7
+ "package",
8
+ "repository",
9
+ "registry",
10
+ "enterprise",
11
+ "modules",
12
+ "proxy",
13
+ "server",
14
+ "verdaccio"
15
+ ],
16
+ "main": "./build/index.js",
17
+ "types": "./build/index.d.ts",
18
+ "author": "Juan Picado <juanpicado19@gmail.com>",
19
+ "license": "MIT",
20
+ "homepage": "https://verdaccio.org",
21
+ "engines": {
22
+ "node": ">=14",
23
+ "npm": ">=6"
24
+ },
25
+ "repository": {
26
+ "type": "https",
27
+ "url": "https://github.com/verdaccio/verdaccio",
28
+ "directory": "packages/core/core"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/verdaccio/verdaccio/issues"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "dependencies": {
37
+ "http-errors": "1.8.1",
38
+ "http-status-codes": "2.2.0",
39
+ "semver": "7.3.7",
40
+ "ajv": "8.11.0",
41
+ "process-warning": "1.0.0",
42
+ "core-js": "3.24.1"
43
+ },
44
+ "devDependencies": {
45
+ "lodash": "4.17.21",
46
+ "@verdaccio/types": "11.0.0-6-next.13"
47
+ },
48
+ "funding": {
49
+ "type": "opencollective",
50
+ "url": "https://opencollective.com/verdaccio"
51
+ },
52
+ "scripts": {
53
+ "clean": "rimraf ./build",
54
+ "test": "jest",
55
+ "type-check": "tsc --noEmit -p tsconfig.build.json",
56
+ "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
57
+ "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
58
+ "watch": "pnpm build:js -- --watch",
59
+ "build": "pnpm run build:js && pnpm run build:types"
60
+ },
61
+ "readme": "# Core\n\n[![CircleCI](https://circleci.com/gh/verdaccio/streams.svg?style=svg)](https://circleci.com/gh/ayusharma/@verdaccio/streams)\n[![codecov](https://codecov.io/gh/verdaccio/streams/branch/master/graph/badge.svg)](https://codecov.io/gh/verdaccio/streams)\n[![verdaccio (latest)](https://img.shields.io/npm/v/@verdaccio/streams/latest.svg)](https://www.npmjs.com/package/@verdaccio/streams)\n[![backers](https://opencollective.com/verdaccio/tiers/backer/badge.svg?label=Backer&color=brightgreen)](https://opencollective.com/verdaccio)\n[![discord](https://img.shields.io/discord/388674437219745793.svg)](http://chat.verdaccio.org/)\n![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)\n[![node](https://img.shields.io/node/v/@verdaccio/streams/latest.svg)](https://www.npmjs.com/package/@verdaccio/streams)\n\nThis project provides an extension of `PassThrough` stream.\n\n## Detail\n\nIt provides 2 additional methods `abort()` and `done()`. Those implementations are widely use in the verdaccio core for handle `tarballs`.\n\n## License\n\nMIT (http://www.opensource.org/licenses/mit-license.php)\n"
62
+ }
package/src/constants.ts CHANGED
@@ -19,6 +19,7 @@ export const CHARACTER_ENCODING = {
19
19
  UTF8: 'utf8',
20
20
  };
21
21
 
22
+ // @deprecated use Bearer instead
22
23
  export const TOKEN_BASIC = 'Basic';
23
24
  export const TOKEN_BEARER = 'Bearer';
24
25
 
@@ -42,6 +43,7 @@ export const HEADERS = {
42
43
  CSP: 'Content-Security-Policy',
43
44
  CTO: 'X-Content-Type-Options',
44
45
  XSS: 'X-XSS-Protection',
46
+ NONE_MATCH: 'If-None-Match',
45
47
  ETAG: 'ETag',
46
48
  JSON_CHARSET: 'application/json; charset=utf-8',
47
49
  OCTET_STREAM: 'application/octet-stream; charset=utf-8',
@@ -82,6 +84,7 @@ export const API_MESSAGE = {
82
84
  TAG_UPDATED: 'tags updated',
83
85
  TAG_REMOVED: 'tag removed',
84
86
  TAG_ADDED: 'package tagged',
87
+ OK: 'ok',
85
88
  LOGGED_OUT: 'Logged out',
86
89
  };
87
90
 
@@ -89,3 +92,18 @@ export const LOG_STATUS_MESSAGE =
89
92
  "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'";
90
93
  export const LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;
91
94
  export const LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;
95
+
96
+ export const ROLES = {
97
+ $ALL: '$all',
98
+ ALL: 'all',
99
+ $AUTH: '$authenticated',
100
+ $ANONYMOUS: '$anonymous',
101
+ DEPRECATED_ALL: '@all',
102
+ DEPRECATED_AUTH: '@authenticated',
103
+ DEPRECATED_ANONYMOUS: '@anonymous',
104
+ };
105
+
106
+ export const PACKAGE_ACCESS = {
107
+ SCOPE: '@*/*',
108
+ ALL: '**',
109
+ };
@@ -1,4 +1,5 @@
1
1
  import createError, { HttpError } from 'http-errors';
2
+
2
3
  import { DEFAULT_MIN_LIMIT_PASSWORD, HTTP_STATUS } from './constants';
3
4
 
4
5
  export const API_ERROR = {
@@ -19,10 +20,12 @@ export const API_ERROR = {
19
20
  NOT_PACKAGE_UPLINK: 'package does not exist on uplink',
20
21
  UPLINK_OFFLINE_PUBLISH: 'one of the uplinks is down, refuse to publish',
21
22
  UPLINK_OFFLINE: 'uplink is offline',
23
+ NOT_MODIFIED_NO_DATA: 'no data',
22
24
  CONTENT_MISMATCH: 'content length mismatch',
23
25
  NOT_FILE_UPLINK: "file doesn't exist on uplink",
24
26
  MAX_USERS_REACHED: 'maximum amount of users reached',
25
27
  VERSION_NOT_EXIST: "this version doesn't exist",
28
+ NO_SUCH_FILE: 'no such file available',
26
29
  UNSUPORTED_REGISTRY_CALL: 'unsupported registry call',
27
30
  FILE_NOT_FOUND: 'File not found',
28
31
  REGISTRATION_DISABLED: 'user registration disabled',
package/src/file-utils.ts CHANGED
@@ -1,3 +1,29 @@
1
+ import { mkdir, mkdtemp } from 'fs/promises';
2
+ import os from 'os';
3
+ import path from 'path';
4
+
1
5
  export const Files = {
2
6
  DatabaseName: '.verdaccio-db.json',
3
7
  };
8
+
9
+ /**
10
+ * Create a temporary folder.
11
+ * @param prefix The prefix of the folder name.
12
+ * @returns string
13
+ */
14
+ export async function createTempFolder(prefix: string): Promise<string> {
15
+ return await mkdtemp(path.join(os.tmpdir(), prefix));
16
+ }
17
+
18
+ /**
19
+ * Create temporary folder for an asset.
20
+ * @param prefix
21
+ * @param folder name
22
+ * @returns
23
+ */
24
+ export async function createTempStorageFolder(prefix: string, folder = 'storage'): Promise<string> {
25
+ const tempFolder = await createTempFolder(prefix);
26
+ const storageFolder = path.join(tempFolder, folder);
27
+ await mkdir(storageFolder);
28
+ return storageFolder;
29
+ }
package/src/index.ts CHANGED
@@ -1,11 +1,11 @@
1
- import * as searchUtils from './search-utils';
2
- import * as streamUtils from './stream-utils';
3
- import * as errorUtils from './error-utils';
4
- import * as validatioUtils from './validation-utils';
5
1
  import * as constants from './constants';
6
- import * as pluginUtils from './plugin-utils';
2
+ import * as errorUtils from './error-utils';
7
3
  import * as fileUtils from './file-utils';
8
4
  import * as pkgUtils from './pkg-utils';
5
+ import * as pluginUtils from './plugin-utils';
6
+ import * as searchUtils from './search-utils';
7
+ import * as streamUtils from './stream-utils';
8
+ import * as validatioUtils from './validation-utils';
9
9
  import * as warningUtils from './warning-utils';
10
10
 
11
11
  export { VerdaccioError, API_ERROR, SUPPORT_ERRORS, APP_ERROR } from './error-utils';
@@ -23,14 +23,16 @@ export {
23
23
  DEFAULT_USER,
24
24
  USERS,
25
25
  } from './constants';
26
-
26
+ const validationUtils = validatioUtils;
27
27
  export {
28
28
  fileUtils,
29
29
  pkgUtils,
30
30
  searchUtils,
31
31
  streamUtils,
32
32
  errorUtils,
33
+ // TODO: remove this typo
33
34
  validatioUtils,
35
+ validationUtils,
34
36
  constants,
35
37
  pluginUtils,
36
38
  warningUtils,
package/src/pkg-utils.ts CHANGED
@@ -1,7 +1,22 @@
1
- import { Package } from '@verdaccio/types';
2
1
  import semver from 'semver';
2
+ import { URL } from 'url';
3
+
4
+ import { Manifest } from '@verdaccio/types';
5
+
3
6
  import { DIST_TAGS } from './constants';
4
7
 
8
+ /**
9
+ * Extract the tarball name from a registry dist url
10
+ * 'https://registry.npmjs.org/test/-/test-0.0.2.tgz'
11
+ * @param tarball tarball url
12
+ * @returns tarball filename
13
+ */
14
+ export function extractTarballName(tarball: string) {
15
+ const urlObject: any = new URL(tarball);
16
+ const filename = urlObject.pathname.replace(/^.*\//, '');
17
+ return filename;
18
+ }
19
+
5
20
  /**
6
21
  * Function filters out bad semver versions and sorts the array.
7
22
  * @return {Array} sorted Array
@@ -22,7 +37,7 @@ export function semverSort(listVersions: string[]): string[] {
22
37
  * Get the latest publihsed version of a package.
23
38
  * @param package metadata
24
39
  **/
25
- export function getLatest(pkg: Package): string {
40
+ export function getLatest(pkg: Manifest): string {
26
41
  const listVersions: string[] = Object.keys(pkg.versions);
27
42
  if (listVersions.length < 1) {
28
43
  throw Error('cannot get lastest version of none');
@@ -40,8 +55,10 @@ export function getLatest(pkg: Package): string {
40
55
  * @param {*} local
41
56
  * @param {*} upstream
42
57
  * @param {*} config sds
58
+ * @deprecated use @verdaccio/storage mergeVersions method
43
59
  */
44
- export function mergeVersions(local: Package, upstream: Package) {
60
+ // @deprecated
61
+ export function mergeVersions(local: Manifest, upstream: Manifest) {
45
62
  // copy new versions to a cache
46
63
  // NOTE: if a certain version was updated, we can't refresh it reliably
47
64
  for (const i in upstream.versions) {