@verdaccio/core 7.0.0-next.6 → 8.0.0-next-8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -0
- package/build/constants.d.ts +8 -0
- package/build/constants.js +10 -2
- package/build/constants.js.map +1 -1
- package/build/error-utils.d.ts +1 -0
- package/build/error-utils.js +3 -2
- package/build/error-utils.js.map +1 -1
- package/build/file-utils.js +1 -1
- package/build/file-utils.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +13 -1
- package/build/index.js.map +1 -1
- package/build/path-utils.js.map +1 -1
- package/build/pkg-utils.js +1 -1
- package/build/pkg-utils.js.map +1 -1
- package/build/plugin-utils.js.map +1 -1
- package/build/schemes/publish-manifest.js +1 -1
- package/build/schemes/publish-manifest.js.map +1 -1
- package/build/search-utils.js.map +1 -1
- package/build/stream-utils.js.map +1 -1
- package/build/string-utils.js.map +1 -1
- package/build/validation-utils.d.ts +1 -1
- package/build/validation-utils.js +9 -3
- package/build/validation-utils.js.map +1 -1
- package/build/warning-utils.d.ts +2 -2
- package/build/warning-utils.js +10 -5
- package/build/warning-utils.js.map +1 -1
- package/package.json +8 -8
- package/src/constants.ts +9 -0
- package/src/error-utils.ts +1 -0
- package/src/index.ts +2 -0
- package/src/validation-utils.ts +14 -3
- package/src/warning-utils.ts +17 -12
- package/test/errors.spec.ts +1 -0
- package/test/merge.dist.tags.spec.ts +2 -0
- package/test/mystreams.spec.ts +1 -0
- package/test/pkg-utils.spec.ts +2 -0
- package/test/string-utils.spec.ts +2 -0
- package/test/validation-utilts.spec.ts +19 -3
- package/jest.config.js +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,73 @@
|
|
|
1
1
|
# @verdaccio/core
|
|
2
2
|
|
|
3
|
+
## 8.0.0-next-8.1
|
|
4
|
+
|
|
5
|
+
## 8.0.0-next-8.0
|
|
6
|
+
|
|
7
|
+
### Major Changes
|
|
8
|
+
|
|
9
|
+
- chore: move v7 next to v8 next
|
|
10
|
+
|
|
11
|
+
## 7.0.0
|
|
12
|
+
|
|
13
|
+
### Major Changes
|
|
14
|
+
|
|
15
|
+
- 47f61c6: feat!: bump to v7
|
|
16
|
+
- e7ebccb: update major dependencies, remove old nodejs support
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- daceb6d: restore legacy support
|
|
21
|
+
- f047cc8: refactor: auth with legacy sign support
|
|
22
|
+
- bd8703e: feat: add migrateToSecureLegacySignature and remove enhancedLegacySignature property
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- 6e764e3: feat: add support for npm owner
|
|
27
|
+
- 7c9f3cf: chore: improve startup logging
|
|
28
|
+
|
|
29
|
+
## 7.0.0-next-8.21
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- 7c9f3cf: chore: improve startup logging
|
|
34
|
+
|
|
35
|
+
## 7.0.0-next-7.20
|
|
36
|
+
|
|
37
|
+
## 7.0.0-next-7.19
|
|
38
|
+
|
|
39
|
+
## 7.0.0-next-7.18
|
|
40
|
+
|
|
41
|
+
## 7.0.0-next-7.17
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- 6e764e3: feat: add support for npm owner
|
|
46
|
+
|
|
47
|
+
## 7.0.0-next-7.16
|
|
48
|
+
|
|
49
|
+
## 7.0.0-next-7.15
|
|
50
|
+
|
|
51
|
+
### Minor Changes
|
|
52
|
+
|
|
53
|
+
- bd8703e: feat: add migrateToSecureLegacySignature and remove enhancedLegacySignature property
|
|
54
|
+
|
|
55
|
+
## 7.0.0-next-7.14
|
|
56
|
+
|
|
57
|
+
## 7.0.0-next-7.13
|
|
58
|
+
|
|
59
|
+
## 7.0.0-next-7.12
|
|
60
|
+
|
|
61
|
+
## 7.0.0-next-7.11
|
|
62
|
+
|
|
63
|
+
## 7.0.0-next-7.10
|
|
64
|
+
|
|
65
|
+
## 7.0.0-next-7.9
|
|
66
|
+
|
|
67
|
+
## 7.0.0-next-7.8
|
|
68
|
+
|
|
69
|
+
## 7.0.0-next-7.7
|
|
70
|
+
|
|
3
71
|
## 7.0.0-next.6
|
|
4
72
|
|
|
5
73
|
## 7.0.0-next.5
|
package/build/constants.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const TIME_EXPIRATION_1H = "1h";
|
|
|
4
4
|
export declare const DIST_TAGS = "dist-tags";
|
|
5
5
|
export declare const LATEST = "latest";
|
|
6
6
|
export declare const USERS = "users";
|
|
7
|
+
export declare const MAINTAINERS = "maintainers";
|
|
7
8
|
export declare const DEFAULT_USER = "Anonymous";
|
|
8
9
|
export declare const HEADER_TYPE: {
|
|
9
10
|
CONTENT_ENCODING: string;
|
|
@@ -101,3 +102,10 @@ export declare enum HtpasswdHashAlgorithm {
|
|
|
101
102
|
crypt = "crypt",
|
|
102
103
|
bcrypt = "bcrypt"
|
|
103
104
|
}
|
|
105
|
+
export declare const PLUGIN_CATEGORY: {
|
|
106
|
+
AUTHENTICATION: string;
|
|
107
|
+
MIDDLEWARE: string;
|
|
108
|
+
STORAGE: string;
|
|
109
|
+
FILTER: string;
|
|
110
|
+
THEME: string;
|
|
111
|
+
};
|
package/build/constants.js
CHANGED
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.USERS = exports.TOKEN_BEARER = exports.TOKEN_BASIC = exports.TIME_EXPIRATION_24H = exports.TIME_EXPIRATION_1H = exports.ROLES = exports.PACKAGE_ACCESS = exports.LOG_VERDACCIO_ERROR = exports.LOG_VERDACCIO_BYTES = exports.LOG_STATUS_MESSAGE = exports.LATEST = exports.HtpasswdHashAlgorithm = exports.HTTP_STATUS = exports.HEADER_TYPE = exports.HEADERS = exports.ERROR_CODE = exports.DIST_TAGS = exports.DEFAULT_USER = exports.DEFAULT_PASSWORD_VALIDATION = exports.CHARACTER_ENCODING = exports.API_MESSAGE = void 0;
|
|
6
|
+
exports.USERS = exports.TOKEN_BEARER = exports.TOKEN_BASIC = exports.TIME_EXPIRATION_24H = exports.TIME_EXPIRATION_1H = exports.ROLES = exports.PLUGIN_CATEGORY = exports.PACKAGE_ACCESS = exports.MAINTAINERS = exports.LOG_VERDACCIO_ERROR = exports.LOG_VERDACCIO_BYTES = exports.LOG_STATUS_MESSAGE = exports.LATEST = exports.HtpasswdHashAlgorithm = exports.HTTP_STATUS = exports.HEADER_TYPE = exports.HEADERS = exports.ERROR_CODE = exports.DIST_TAGS = exports.DEFAULT_USER = exports.DEFAULT_PASSWORD_VALIDATION = exports.CHARACTER_ENCODING = exports.API_MESSAGE = void 0;
|
|
7
7
|
var _httpStatusCodes = _interopRequireDefault(require("http-status-codes"));
|
|
8
|
-
function _interopRequireDefault(
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
const DEFAULT_PASSWORD_VALIDATION = exports.DEFAULT_PASSWORD_VALIDATION = /.{3}$/;
|
|
10
10
|
const TIME_EXPIRATION_24H = exports.TIME_EXPIRATION_24H = '24h';
|
|
11
11
|
const TIME_EXPIRATION_1H = exports.TIME_EXPIRATION_1H = '1h';
|
|
12
12
|
const DIST_TAGS = exports.DIST_TAGS = 'dist-tags';
|
|
13
13
|
const LATEST = exports.LATEST = 'latest';
|
|
14
14
|
const USERS = exports.USERS = 'users';
|
|
15
|
+
const MAINTAINERS = exports.MAINTAINERS = 'maintainers';
|
|
15
16
|
const DEFAULT_USER = exports.DEFAULT_USER = 'Anonymous';
|
|
16
17
|
const HEADER_TYPE = exports.HEADER_TYPE = {
|
|
17
18
|
CONTENT_ENCODING: 'content-encoding',
|
|
@@ -114,4 +115,11 @@ let HtpasswdHashAlgorithm = exports.HtpasswdHashAlgorithm = /*#__PURE__*/functio
|
|
|
114
115
|
HtpasswdHashAlgorithm["bcrypt"] = "bcrypt";
|
|
115
116
|
return HtpasswdHashAlgorithm;
|
|
116
117
|
}({});
|
|
118
|
+
const PLUGIN_CATEGORY = exports.PLUGIN_CATEGORY = {
|
|
119
|
+
AUTHENTICATION: 'authentication',
|
|
120
|
+
MIDDLEWARE: 'middleware',
|
|
121
|
+
STORAGE: 'storage',
|
|
122
|
+
FILTER: 'filter',
|
|
123
|
+
THEME: 'theme'
|
|
124
|
+
};
|
|
117
125
|
//# sourceMappingURL=constants.js.map
|
package/build/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["_httpStatusCodes","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"file":"constants.js","names":["_httpStatusCodes","_interopRequireDefault","require","e","__esModule","default","DEFAULT_PASSWORD_VALIDATION","exports","TIME_EXPIRATION_24H","TIME_EXPIRATION_1H","DIST_TAGS","LATEST","USERS","MAINTAINERS","DEFAULT_USER","HEADER_TYPE","CONTENT_ENCODING","CONTENT_TYPE","CONTENT_LENGTH","ACCEPT_ENCODING","AUTHORIZATION","CHARACTER_ENCODING","UTF8","TOKEN_BASIC","TOKEN_BEARER","HEADERS","ACCEPT","USER_AGENT","JSON","TEXT_PLAIN","TEXT_PLAIN_UTF8","TEXT_HTML_UTF8","TEXT_HTML","CACHE_CONTROL","FORWARDED_PROTO","FORWARDED_FOR","FRAMES_OPTIONS","CSP","CTO","XSS","NONE_MATCH","ETAG","JSON_CHARSET","JSON_INSTALL_CHARSET","OCTET_STREAM","TEXT_CHARSET","WWW_AUTH","GZIP","HTTP_STATUS","OK","httpCodes","CREATED","MULTIPLE_CHOICES","NOT_MODIFIED","BAD_REQUEST","UNAUTHORIZED","FORBIDDEN","NOT_FOUND","CONFLICT","NOT_IMPLEMENTED","UNSUPPORTED_MEDIA","UNSUPPORTED_MEDIA_TYPE","BAD_DATA","UNPROCESSABLE_ENTITY","INTERNAL_ERROR","INTERNAL_SERVER_ERROR","SERVICE_UNAVAILABLE","LOOP_DETECTED","CANNOT_HANDLE","ERROR_CODE","token_required","API_MESSAGE","PKG_CREATED","PKG_CHANGED","PKG_REMOVED","PKG_PUBLISHED","TARBALL_UPLOADED","TARBALL_REMOVED","TAG_UPDATED","TAG_REMOVED","TAG_ADDED","LOGGED_OUT","LOG_STATUS_MESSAGE","LOG_VERDACCIO_ERROR","LOG_VERDACCIO_BYTES","ROLES","$ALL","ALL","$AUTH","$ANONYMOUS","DEPRECATED_ALL","DEPRECATED_AUTH","DEPRECATED_ANONYMOUS","PACKAGE_ACCESS","SCOPE","HtpasswdHashAlgorithm","PLUGIN_CATEGORY","AUTHENTICATION","MIDDLEWARE","STORAGE","FILTER","THEME"],"sources":["../src/constants.ts"],"sourcesContent":["import httpCodes from 'http-status-codes';\n\nexport const DEFAULT_PASSWORD_VALIDATION = /.{3}$/;\nexport const TIME_EXPIRATION_24H = '24h';\nexport const TIME_EXPIRATION_1H = '1h';\nexport const DIST_TAGS = 'dist-tags';\nexport const LATEST = 'latest';\nexport const USERS = 'users';\nexport const MAINTAINERS = 'maintainers';\nexport const DEFAULT_USER = 'Anonymous';\n\nexport const HEADER_TYPE = {\n CONTENT_ENCODING: 'content-encoding',\n CONTENT_TYPE: 'content-type',\n CONTENT_LENGTH: 'content-length',\n ACCEPT_ENCODING: 'accept-encoding',\n AUTHORIZATION: 'authorization',\n};\n\nexport const CHARACTER_ENCODING = {\n UTF8: 'utf8',\n};\n\n// @deprecated use Bearer instead\nexport const TOKEN_BASIC = 'Basic';\nexport const TOKEN_BEARER = 'Bearer';\n\nexport const HEADERS = {\n ACCEPT: 'Accept',\n ACCEPT_ENCODING: 'Accept-Encoding',\n USER_AGENT: 'User-Agent',\n JSON: 'application/json',\n CONTENT_TYPE: 'Content-type',\n CONTENT_LENGTH: 'content-length',\n TEXT_PLAIN: 'text/plain',\n TEXT_PLAIN_UTF8: 'text/plain; charset=utf-8',\n TEXT_HTML_UTF8: 'text/html; charset=utf-8',\n TEXT_HTML: 'text/html',\n AUTHORIZATION: 'authorization',\n CACHE_CONTROL: 'Cache-Control',\n // only set with proxy that setup HTTPS\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto\n FORWARDED_PROTO: 'X-Forwarded-Proto',\n FORWARDED_FOR: 'X-Forwarded-For',\n FRAMES_OPTIONS: 'X-Frame-Options',\n CSP: 'Content-Security-Policy',\n CTO: 'X-Content-Type-Options',\n XSS: 'X-XSS-Protection',\n NONE_MATCH: 'If-None-Match',\n ETAG: 'ETag',\n JSON_CHARSET: 'application/json; charset=utf-8',\n JSON_INSTALL_CHARSET: 'application/vnd.npm.install-v1+json; charset=utf-8',\n OCTET_STREAM: 'application/octet-stream; charset=utf-8',\n TEXT_CHARSET: 'text/plain; charset=utf-8',\n WWW_AUTH: 'WWW-Authenticate',\n GZIP: 'gzip',\n};\n\nexport const HTTP_STATUS = {\n OK: httpCodes.OK,\n CREATED: httpCodes.CREATED,\n MULTIPLE_CHOICES: httpCodes.MULTIPLE_CHOICES,\n NOT_MODIFIED: httpCodes.NOT_MODIFIED,\n BAD_REQUEST: httpCodes.BAD_REQUEST,\n UNAUTHORIZED: httpCodes.UNAUTHORIZED,\n FORBIDDEN: httpCodes.FORBIDDEN,\n NOT_FOUND: httpCodes.NOT_FOUND,\n CONFLICT: httpCodes.CONFLICT,\n NOT_IMPLEMENTED: httpCodes.NOT_IMPLEMENTED,\n UNSUPPORTED_MEDIA: httpCodes.UNSUPPORTED_MEDIA_TYPE,\n BAD_DATA: httpCodes.UNPROCESSABLE_ENTITY,\n INTERNAL_ERROR: httpCodes.INTERNAL_SERVER_ERROR,\n SERVICE_UNAVAILABLE: httpCodes.SERVICE_UNAVAILABLE,\n LOOP_DETECTED: 508,\n CANNOT_HANDLE: 590,\n};\n\nexport const ERROR_CODE = {\n token_required: 'token is required',\n};\n\nexport const API_MESSAGE = {\n PKG_CREATED: 'created new package',\n PKG_CHANGED: 'package changed',\n PKG_REMOVED: 'package removed',\n PKG_PUBLISHED: 'package published',\n TARBALL_UPLOADED: 'tarball uploaded successfully',\n TARBALL_REMOVED: 'tarball removed',\n TAG_UPDATED: 'tags updated',\n TAG_REMOVED: 'tag removed',\n TAG_ADDED: 'package tagged',\n OK: 'ok',\n LOGGED_OUT: 'Logged out',\n};\n\nexport const LOG_STATUS_MESSAGE =\n \"@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'\";\nexport const LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;\nexport const LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;\n\nexport const ROLES = {\n $ALL: '$all',\n ALL: 'all',\n $AUTH: '$authenticated',\n $ANONYMOUS: '$anonymous',\n DEPRECATED_ALL: '@all',\n DEPRECATED_AUTH: '@authenticated',\n DEPRECATED_ANONYMOUS: '@anonymous',\n};\n\nexport const PACKAGE_ACCESS = {\n SCOPE: '@*/*',\n ALL: '**',\n};\n\nexport enum HtpasswdHashAlgorithm {\n md5 = 'md5',\n sha1 = 'sha1',\n crypt = 'crypt',\n bcrypt = 'bcrypt',\n}\n\nexport const PLUGIN_CATEGORY = {\n AUTHENTICATION: 'authentication',\n MIDDLEWARE: 'middleware',\n STORAGE: 'storage',\n FILTER: 'filter',\n THEME: 'theme',\n};\n"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEnC,MAAMG,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,GAAG,OAAO;AAC3C,MAAME,mBAAmB,GAAAD,OAAA,CAAAC,mBAAA,GAAG,KAAK;AACjC,MAAMC,kBAAkB,GAAAF,OAAA,CAAAE,kBAAA,GAAG,IAAI;AAC/B,MAAMC,SAAS,GAAAH,OAAA,CAAAG,SAAA,GAAG,WAAW;AAC7B,MA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,WAAW,EAAE,aAAa;EAC1BC,SAAS,EAAE,gBAAgB;EAC3B/B,EAAE,EAAE,IAAI;EACRgC,UAAU,EAAE;AACd,CAAC;AAEM,MAAMC,kBAAkB,GAAA3E,OAAA,CAAA2E,kBAAA,GAC7B,gFAAgF;AAC3E,MAAMC,mBAAmB,GAAA5E,OAAA,CAAA4E,mBAAA,GAAG,GAAGD,kBAAkB,oBAAoB;AACrE,MAAME,mBAAmB,GAAA7E,OAAA,CAAA6E,mBAAA,GAAG,GAAGF,kBAAkB,mCAAmC;AAEpF,MAAMG,KAAK,GAAA9E,OAAA,CAAA8E,KAAA,GAAG;EACnBC,IAAI,EAAE,MAAM;EACZC,GAAG,EAAE,KAAK;EACVC,KAAK,EAAE,gBAAgB;EACvBC,UAAU,EAAE,YAAY;EACxBC,cAAc,EAAE,MAAM;EACtBC,eAAe,EAAE,gBAAgB;EACjCC,oBAAoB,EAAE;AACxB,CAAC;AAEM,MAAMC,cAAc,GAAAtF,OAAA,CAAAsF,cAAA,GAAG;EAC5BC,KAAK,EAAE,MAAM;EACbP,GAAG,EAAE;AACP,CAAC;AAAC,IAEUQ,qBAAqB,GAAAxF,OAAA,CAAAwF,qBAAA,0BAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAAA,OAArBA,qBAAqB;AAAA;AAO1B,MAAMC,eAAe,GAAAzF,OAAA,CAAAyF,eAAA,GAAG;EAC7BC,cAAc,EAAE,gBAAgB;EAChCC,UAAU,EAAE,YAAY;EACxBC,OAAO,EAAE,SAAS;EAClBC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE;AACT,CAAC","ignoreList":[]}
|
package/build/error-utils.d.ts
CHANGED
package/build/error-utils.js
CHANGED
|
@@ -15,7 +15,7 @@ exports.getServiceUnavailable = getServiceUnavailable;
|
|
|
15
15
|
exports.getUnauthorized = getUnauthorized;
|
|
16
16
|
var _httpErrors = _interopRequireDefault(require("http-errors"));
|
|
17
17
|
var _constants = require("./constants");
|
|
18
|
-
function _interopRequireDefault(
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
19
|
const API_ERROR = exports.API_ERROR = {
|
|
20
20
|
PASSWORD_SHORT: `The provided password does not pass the validation`,
|
|
21
21
|
MUST_BE_LOGGED: 'You must be logged in to publish packages.',
|
|
@@ -52,7 +52,8 @@ const API_ERROR = exports.API_ERROR = {
|
|
|
52
52
|
RESOURCE_UNAVAILABLE: 'resource unavailable',
|
|
53
53
|
BAD_PACKAGE_DATA: 'bad incoming package data',
|
|
54
54
|
USERNAME_PASSWORD_REQUIRED: 'username and password is required',
|
|
55
|
-
USERNAME_ALREADY_REGISTERED: 'username is already registered'
|
|
55
|
+
USERNAME_ALREADY_REGISTERED: 'username is already registered',
|
|
56
|
+
USERNAME_MISMATCH: 'username does not match logged in user'
|
|
56
57
|
};
|
|
57
58
|
const SUPPORT_ERRORS = exports.SUPPORT_ERRORS = {
|
|
58
59
|
PLUGIN_MISSING_INTERFACE: 'the plugin does not provide implementation of the requested feature',
|
package/build/error-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-utils.js","names":["_httpErrors","_interopRequireDefault","require","_constants","
|
|
1
|
+
{"version":3,"file":"error-utils.js","names":["_httpErrors","_interopRequireDefault","require","_constants","e","__esModule","default","API_ERROR","exports","PASSWORD_SHORT","MUST_BE_LOGGED","PLUGIN_ERROR","CONFIG_BAD_FORMAT","BAD_USERNAME_PASSWORD","NO_PACKAGE","PACKAGE_CANNOT_BE_ADDED","BAD_DATA","NOT_ALLOWED","NOT_ALLOWED_PUBLISH","INTERNAL_SERVER_ERROR","UNKNOWN_ERROR","NOT_PACKAGE_UPLINK","UPLINK_OFFLINE_PUBLISH","UPLINK_OFFLINE","NOT_MODIFIED_NO_DATA","CONTENT_MISMATCH","NOT_FILE_UPLINK","MAX_USERS_REACHED","VERSION_NOT_EXIST","NO_SUCH_FILE","UNSUPORTED_REGISTRY_CALL","FILE_NOT_FOUND","REGISTRATION_DISABLED","UNAUTHORIZED_ACCESS","BAD_STATUS_CODE","SERVER_TIME_OUT","PACKAGE_EXIST","BAD_AUTH_HEADER","WEB_DISABLED","DEPRECATED_BASIC_HEADER","BAD_FORMAT_USER_GROUP","RESOURCE_UNAVAILABLE","BAD_PACKAGE_DATA","USERNAME_PASSWORD_REQUIRED","USERNAME_ALREADY_REGISTERED","USERNAME_MISMATCH","SUPPORT_ERRORS","PLUGIN_MISSING_INTERFACE","TFA_DISABLED","STORAGE_NOT_IMPLEMENT","PARAMETERS_NOT_VALID","APP_ERROR","CONFIG_NOT_VALID","PROFILE_ERROR","PASSWORD_VALIDATION","getError","code","message","httpError","createError","getConflict","HTTP_STATUS","CONFLICT","getBadData","customMessage","getBadRequest","BAD_REQUEST","getInternalError","INTERNAL_ERROR","getUnauthorized","UNAUTHORIZED","getForbidden","FORBIDDEN","getServiceUnavailable","SERVICE_UNAVAILABLE","getNotFound","NOT_FOUND","getCode","statusCode"],"sources":["../src/error-utils.ts"],"sourcesContent":["import createError, { HttpError } from 'http-errors';\n\nimport { HTTP_STATUS } from './constants';\n\nexport const API_ERROR = {\n PASSWORD_SHORT: `The provided password does not pass the validation`,\n MUST_BE_LOGGED: 'You must be logged in to publish packages.',\n PLUGIN_ERROR: 'bug in the auth plugin system',\n CONFIG_BAD_FORMAT: 'config file must be an object',\n BAD_USERNAME_PASSWORD: 'bad username/password, access denied',\n NO_PACKAGE: 'no such package available',\n PACKAGE_CANNOT_BE_ADDED: 'this package cannot be added',\n BAD_DATA: 'bad data',\n NOT_ALLOWED: 'not allowed to access package',\n NOT_ALLOWED_PUBLISH: 'not allowed to publish package',\n INTERNAL_SERVER_ERROR: 'internal server error',\n UNKNOWN_ERROR: 'unknown error',\n NOT_PACKAGE_UPLINK: 'package does not exist on uplink',\n UPLINK_OFFLINE_PUBLISH: 'one of the uplinks is down, refuse to publish',\n UPLINK_OFFLINE: 'uplink is offline',\n NOT_MODIFIED_NO_DATA: 'no data',\n CONTENT_MISMATCH: 'content length mismatch',\n NOT_FILE_UPLINK: \"file doesn't exist on uplink\",\n MAX_USERS_REACHED: 'maximum amount of users reached',\n VERSION_NOT_EXIST: \"this version doesn't exist\",\n NO_SUCH_FILE: 'no such file available',\n UNSUPORTED_REGISTRY_CALL: 'unsupported registry call',\n FILE_NOT_FOUND: 'File not found',\n REGISTRATION_DISABLED: 'user registration disabled',\n UNAUTHORIZED_ACCESS: 'unauthorized access',\n BAD_STATUS_CODE: 'bad status code',\n SERVER_TIME_OUT: 'looks like the server is taking to long to respond',\n PACKAGE_EXIST: 'this package is already present',\n BAD_AUTH_HEADER: 'bad authorization header',\n WEB_DISABLED: 'Web interface is disabled in the config file',\n DEPRECATED_BASIC_HEADER: 'basic authentication is deprecated, please use JWT instead',\n BAD_FORMAT_USER_GROUP: 'user groups is different than an array',\n RESOURCE_UNAVAILABLE: 'resource unavailable',\n BAD_PACKAGE_DATA: 'bad incoming package data',\n USERNAME_PASSWORD_REQUIRED: 'username and password is required',\n USERNAME_ALREADY_REGISTERED: 'username is already registered',\n USERNAME_MISMATCH: 'username does not match logged in user',\n};\n\nexport const SUPPORT_ERRORS = {\n PLUGIN_MISSING_INTERFACE: 'the plugin does not provide implementation of the requested feature',\n TFA_DISABLED: 'the two-factor authentication is not yet supported',\n STORAGE_NOT_IMPLEMENT: 'the storage does not support token saving',\n PARAMETERS_NOT_VALID: 'the parameters are not valid',\n};\n\nexport const APP_ERROR = {\n CONFIG_NOT_VALID: 'CONFIG: it does not look like a valid config file',\n PROFILE_ERROR: 'profile unexpected error',\n PASSWORD_VALIDATION: 'not valid password',\n};\n\nexport type VerdaccioError = HttpError & { code: number };\n\nfunction getError(code: number, message: string): VerdaccioError {\n const httpError = createError(code, message);\n\n httpError.code = code;\n\n return httpError as VerdaccioError;\n}\n\nexport function getConflict(message: string = API_ERROR.PACKAGE_EXIST): VerdaccioError {\n return getError(HTTP_STATUS.CONFLICT, message);\n}\n\nexport function getBadData(customMessage?: string): VerdaccioError {\n return getError(HTTP_STATUS.BAD_DATA, customMessage || API_ERROR.BAD_DATA);\n}\n\nexport function getBadRequest(customMessage: string): VerdaccioError {\n return getError(HTTP_STATUS.BAD_REQUEST, customMessage);\n}\n\nexport function getInternalError(customMessage?: string): VerdaccioError {\n return customMessage\n ? getError(HTTP_STATUS.INTERNAL_ERROR, customMessage)\n : getError(HTTP_STATUS.INTERNAL_ERROR, API_ERROR.UNKNOWN_ERROR);\n}\n\nexport function getUnauthorized(message = 'no credentials provided'): VerdaccioError {\n return getError(HTTP_STATUS.UNAUTHORIZED, message);\n}\n\nexport function getForbidden(message = \"can't use this filename\"): VerdaccioError {\n return getError(HTTP_STATUS.FORBIDDEN, message);\n}\n\nexport function getServiceUnavailable(\n message: string = API_ERROR.RESOURCE_UNAVAILABLE\n): VerdaccioError {\n return getError(HTTP_STATUS.SERVICE_UNAVAILABLE, message);\n}\n\nexport function getNotFound(customMessage?: string): VerdaccioError {\n return getError(HTTP_STATUS.NOT_FOUND, customMessage || API_ERROR.NO_PACKAGE);\n}\n\nexport function getCode(statusCode: number, customMessage: string): VerdaccioError {\n return getError(statusCode, customMessage);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAA0C,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEnC,MAAMG,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACvBE,cAAc,EAAE,oDAAoD;EACpEC,cAAc,EAAE,4CAA4C;EAC5DC,YAAY,EAAE,+BAA+B;EAC7CC,iBAAiB,EAAE,+BAA+B;EAClDC,qBAAqB,EAAE,sCAAsC;EAC7DC,UAAU,EAAE,2BAA2B;EACvCC,uBAAuB,EAAE,8BAA8B;EACv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W,CAACe,SAAS,EAAEZ,aAAa,IAAIzD,SAAS,CAACO,UAAU,CAAC;AAC/E;AAEO,SAAS+D,OAAOA,CAACC,UAAkB,EAAEd,aAAqB,EAAkB;EACjF,OAAOT,QAAQ,CAACuB,UAAU,EAAEd,aAAa,CAAC;AAC5C","ignoreList":[]}
|
package/build/file-utils.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.createTempStorageFolder = createTempStorageFolder;
|
|
|
9
9
|
var _fs = _interopRequireDefault(require("fs"));
|
|
10
10
|
var _os = _interopRequireDefault(require("os"));
|
|
11
11
|
var _path = _interopRequireDefault(require("path"));
|
|
12
|
-
function _interopRequireDefault(
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
const Files = exports.Files = {
|
|
14
14
|
DatabaseName: '.verdaccio-db.json'
|
|
15
15
|
};
|
package/build/file-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-utils.js","names":["_fs","_interopRequireDefault","require","_os","_path","
|
|
1
|
+
{"version":3,"file":"file-utils.js","names":["_fs","_interopRequireDefault","require","_os","_path","e","__esModule","default","Files","exports","DatabaseName","mkdir","mkdtemp","fs","promises","createTempFolder","prefix","path","join","os","tmpdir","createTempStorageFolder","folder","tempFolder","storageFolder"],"sources":["../src/file-utils.ts"],"sourcesContent":["import fs from 'fs';\nimport os from 'os';\nimport path from 'path';\n\nexport const Files = {\n DatabaseName: '.verdaccio-db.json',\n};\n\nconst { mkdir, mkdtemp } = fs.promises ? fs.promises : require('fs/promises');\n\n/**\n * Create a temporary folder.\n * @param prefix The prefix of the folder name.\n * @returns string\n */\nexport async function createTempFolder(prefix: string): Promise<string> {\n return await mkdtemp(path.join(os.tmpdir(), prefix));\n}\n\n/**\n * Create temporary folder for an asset.\n * @param prefix\n * @param folder name\n * @returns\n */\nexport async function createTempStorageFolder(prefix: string, folder = 'storage'): Promise<string> {\n const tempFolder = await createTempFolder(prefix);\n const storageFolder = path.join(tempFolder, folder);\n await mkdir(storageFolder);\n return storageFolder;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,GAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAwB,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEjB,MAAMG,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAG;EACnBE,YAAY,EAAE;AAChB,CAAC;AAED,MAAM;EAAEC,KAAK;EAAEC;AAAQ,CAAC,GAAGC,WAAE,CAACC,QAAQ,GAAGD,WAAE,CAACC,QAAQ,GAAGZ,OAAO,CAAC,aAAa,CAAC;;AAE7E;AACA;AACA;AACA;AACA;AACO,eAAea,gBAAgBA,CAACC,MAAc,EAAmB;EACtE,OAAO,MAAMJ,OAAO,CAACK,aAAI,CAACC,IAAI,CAACC,WAAE,CAACC,MAAM,CAAC,CAAC,EAAEJ,MAAM,CAAC,CAAC;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeK,uBAAuBA,CAACL,MAAc,EAAEM,MAAM,GAAG,SAAS,EAAmB;EACjG,MAAMC,UAAU,GAAG,MAAMR,gBAAgB,CAACC,MAAM,CAAC;EACjD,MAAMQ,aAAa,GAAGP,aAAI,CAACC,IAAI,CAACK,UAAU,EAAED,MAAM,CAAC;EACnD,MAAMX,KAAK,CAACa,aAAa,CAAC;EAC1B,OAAOA,aAAa;AACtB","ignoreList":[]}
|
package/build/index.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ import * as stringUtils from './string-utils';
|
|
|
9
9
|
import * as validatioUtils from './validation-utils';
|
|
10
10
|
import * as warningUtils from './warning-utils';
|
|
11
11
|
export { VerdaccioError, API_ERROR, SUPPORT_ERRORS, APP_ERROR } from './error-utils';
|
|
12
|
-
export { TOKEN_BASIC, TOKEN_BEARER, HTTP_STATUS, API_MESSAGE, HEADERS, DIST_TAGS, CHARACTER_ENCODING, HEADER_TYPE, LATEST, DEFAULT_PASSWORD_VALIDATION, DEFAULT_USER, USERS, HtpasswdHashAlgorithm, } from './constants';
|
|
12
|
+
export { TOKEN_BASIC, TOKEN_BEARER, HTTP_STATUS, API_MESSAGE, HEADERS, DIST_TAGS, CHARACTER_ENCODING, HEADER_TYPE, LATEST, DEFAULT_PASSWORD_VALIDATION, DEFAULT_USER, USERS, MAINTAINERS, PLUGIN_CATEGORY, HtpasswdHashAlgorithm, } from './constants';
|
|
13
13
|
declare const validationUtils: typeof validatioUtils;
|
|
14
14
|
export { fileUtils, pkgUtils, searchUtils, streamUtils, errorUtils, validatioUtils, validationUtils, stringUtils, constants, pluginUtils, warningUtils, };
|
package/build/index.js
CHANGED
|
@@ -75,6 +75,18 @@ Object.defineProperty(exports, "LATEST", {
|
|
|
75
75
|
return constants.LATEST;
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
|
+
Object.defineProperty(exports, "MAINTAINERS", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () {
|
|
81
|
+
return constants.MAINTAINERS;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "PLUGIN_CATEGORY", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () {
|
|
87
|
+
return constants.PLUGIN_CATEGORY;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
78
90
|
Object.defineProperty(exports, "SUPPORT_ERRORS", {
|
|
79
91
|
enumerable: true,
|
|
80
92
|
get: function () {
|
|
@@ -127,6 +139,6 @@ exports.validatioUtils = validatioUtils;
|
|
|
127
139
|
var warningUtils = _interopRequireWildcard(require("./warning-utils"));
|
|
128
140
|
exports.warningUtils = warningUtils;
|
|
129
141
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
130
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
|
142
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
131
143
|
const validationUtils = exports.validationUtils = validatioUtils;
|
|
132
144
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["constants","_interopRequireWildcard","require","exports","errorUtils","fileUtils","pkgUtils","pluginUtils","searchUtils","streamUtils","stringUtils","validatioUtils","warningUtils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","
|
|
1
|
+
{"version":3,"file":"index.js","names":["constants","_interopRequireWildcard","require","exports","errorUtils","fileUtils","pkgUtils","pluginUtils","searchUtils","streamUtils","stringUtils","validatioUtils","warningUtils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","validationUtils"],"sources":["../src/index.ts"],"sourcesContent":["import * as constants from './constants';\nimport * as errorUtils from './error-utils';\nimport * as fileUtils from './file-utils';\nimport * as pkgUtils from './pkg-utils';\nimport * as pluginUtils from './plugin-utils';\nimport * as searchUtils from './search-utils';\nimport * as streamUtils from './stream-utils';\nimport * as stringUtils from './string-utils';\nimport * as validatioUtils from './validation-utils';\nimport * as warningUtils from './warning-utils';\n\nexport { VerdaccioError, API_ERROR, SUPPORT_ERRORS, APP_ERROR } from './error-utils';\nexport {\n TOKEN_BASIC,\n TOKEN_BEARER,\n HTTP_STATUS,\n API_MESSAGE,\n HEADERS,\n DIST_TAGS,\n CHARACTER_ENCODING,\n HEADER_TYPE,\n LATEST,\n DEFAULT_PASSWORD_VALIDATION,\n DEFAULT_USER,\n USERS,\n MAINTAINERS,\n PLUGIN_CATEGORY,\n HtpasswdHashAlgorithm,\n} from './constants';\nconst validationUtils = validatioUtils;\nexport {\n fileUtils,\n pkgUtils,\n searchUtils,\n streamUtils,\n errorUtils,\n // TODO: remove this typo\n validatioUtils,\n validationUtils,\n stringUtils,\n constants,\n pluginUtils,\n warningUtils,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAyCC,OAAA,CAAAH,SAAA,GAAAA,SAAA;AACzC,IAAAI,UAAA,GAAAH,uBAAA,CAAAC,OAAA;AAA4CC,OAAA,CAAAC,UAAA,GAAAA,UAAA;AAC5C,IAAAC,SAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAA0CC,OAAA,CAAAE,SAAA,GAAAA,SAAA;AAC1C,IAAAC,QAAA,GAAAL,uBAAA,CAAAC,OAAA;AAAwCC,OAAA,CAAAG,QAAA,GAAAA,QAAA;AACxC,IAAAC,WAAA,GAAAN,uBAAA,CAAAC,OAAA;AAA8CC,OAAA,CAAAI,WAAA,GAAAA,WAAA;AAC9C,IAAAC,WAAA,GAAAP,uBAAA,CAAAC,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AA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAoBhD,MAAMW,eAAe,GAAA9B,OAAA,CAAA8B,eAAA,GAAGtB,cAAc","ignoreList":[]}
|
package/build/path-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-utils.js","names":[],"sources":["../src/path-utils.ts"],"sourcesContent":[""],"mappings":""}
|
|
1
|
+
{"version":3,"file":"path-utils.js","names":[],"sources":["../src/path-utils.ts"],"sourcesContent":[""],"mappings":"","ignoreList":[]}
|
package/build/pkg-utils.js
CHANGED
|
@@ -10,7 +10,7 @@ exports.semverSort = semverSort;
|
|
|
10
10
|
var _semver = _interopRequireDefault(require("semver"));
|
|
11
11
|
var _url = require("url");
|
|
12
12
|
var _constants = require("./constants");
|
|
13
|
-
function _interopRequireDefault(
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
/**
|
|
15
15
|
* Extract the tarball name from a registry dist url
|
|
16
16
|
* 'https://registry.npmjs.org/test/-/test-0.0.2.tgz'
|
package/build/pkg-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkg-utils.js","names":["_semver","_interopRequireDefault","require","_url","_constants","
|
|
1
|
+
{"version":3,"file":"pkg-utils.js","names":["_semver","_interopRequireDefault","require","_url","_constants","e","__esModule","default","extractTarballName","tarball","urlObject","URL","filename","pathname","replace","semverSort","listVersions","filter","x","semver","parse","sort","compareLoose","map","String","getLatest","pkg","_pkg$DIST_TAGS","Object","keys","versions","length","Error","latest","DIST_TAGS","mergeVersions","local","upstream","i","lte","readme"],"sources":["../src/pkg-utils.ts"],"sourcesContent":["import semver from 'semver';\nimport { URL } from 'url';\n\nimport { Manifest } from '@verdaccio/types';\n\nimport { DIST_TAGS } from './constants';\n\n/**\n * Extract the tarball name from a registry dist url\n * 'https://registry.npmjs.org/test/-/test-0.0.2.tgz'\n * @param tarball tarball url\n * @returns tarball filename\n */\nexport function extractTarballName(tarball: string) {\n const urlObject: any = new URL(tarball);\n const filename = urlObject.pathname.replace(/^.*\\//, '');\n return filename;\n}\n\n/**\n * Function filters out bad semver versions and sorts the array.\n * @return {Array} sorted Array\n */\nexport function semverSort(listVersions: string[]): string[] {\n return listVersions\n .filter(function (x): boolean {\n if (!semver.parse(x, true)) {\n return false;\n }\n return true;\n })\n .sort(semver.compareLoose)\n .map(String);\n}\n\n/**\n * Get the latest publihsed version of a package.\n * @param package metadata\n **/\nexport function getLatest(pkg: Manifest): string {\n const listVersions: string[] = Object.keys(pkg.versions);\n if (listVersions.length < 1) {\n throw Error('cannot get lastest version of none');\n }\n\n const versions: string[] = semverSort(listVersions);\n const latest: string | undefined = pkg[DIST_TAGS]?.latest ? pkg[DIST_TAGS].latest : versions[0];\n\n return latest;\n}\n\n/**\n * Function gets a local info and an info from uplinks and tries to merge it\n exported for unit tests only.\n * @param {*} local\n * @param {*} upstream\n * @param {*} config sds\n * @deprecated use @verdaccio/storage mergeVersions method\n */\n// @deprecated\nexport function mergeVersions(local: Manifest, upstream: Manifest) {\n // copy new versions to a cache\n // NOTE: if a certain version was updated, we can't refresh it reliably\n for (const i in upstream.versions) {\n if (typeof local.versions[i] === 'undefined') {\n local.versions[i] = upstream.versions[i];\n }\n }\n\n for (const i in upstream[DIST_TAGS]) {\n if (local[DIST_TAGS][i] !== upstream[DIST_TAGS][i]) {\n if (!local[DIST_TAGS][i] || semver.lte(local[DIST_TAGS][i], upstream[DIST_TAGS][i])) {\n local[DIST_TAGS][i] = upstream[DIST_TAGS][i];\n }\n if (i === 'latest' && local[DIST_TAGS][i] === upstream[DIST_TAGS][i]) {\n // if remote has more fresh package, we should borrow its readme\n local.readme = upstream.readme;\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAIA,IAAAE,UAAA,GAAAF,OAAA;AAAwC,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExC;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,kBAAkBA,CAACC,OAAe,EAAE;EAClD,MAAMC,SAAc,GAAG,IAAIC,QAAG,CAACF,OAAO,CAAC;EACvC,MAAMG,QAAQ,GAAGF,SAAS,CAACG,QAAQ,CAACC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;EACxD,OAAOF,QAAQ;AACjB;;AAEA;AACA;AACA;AACA;AACO,SAASG,UAAUA,CAACC,YAAsB,EAAY;EAC3D,OAAOA,YAAY,CAChBC,MAAM,CAAC,UAAUC,CAAC,EAAW;IAC5B,IAAI,CAACC,eAAM,CAACC,KAAK,CAACF,CAAC,EAAE,IAAI,CAAC,EAAE;MAC1B,OAAO,KAAK;IACd;IACA,OAAO,IAAI;EACb,CAAC,CAAC,CACDG,IAAI,CAACF,eAAM,CAACG,YAAY,CAAC,CACzBC,GAAG,CAACC,MAAM,CAAC;AAChB;;AAEA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAACC,GAAa,EAAU;EAAA,IAAAC,cAAA;EAC/C,MAAMX,YAAsB,GAAGY,MAAM,CAACC,IAAI,CAACH,GAAG,CAACI,QAAQ,CAAC;EACxD,IAAId,YAAY,CAACe,MAAM,GAAG,CAAC,EAAE;IAC3B,MAAMC,KAAK,CAAC,oCAAoC,CAAC;EACnD;EAEA,MAAMF,QAAkB,GAAGf,UAAU,CAACC,YAAY,CAAC;EACnD,MAAMiB,MAA0B,GAAG,CAAAN,cAAA,GAAAD,GAAG,CAACQ,oB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@@
|
|
|
1
|
-
{"version":3,"file":"plugin-utils.js","names":["Plugin","version","constructor","config","options","getVersion","exports"],"sources":["../src/plugin-utils.ts"],"sourcesContent":["import { Express, RequestHandler } from 'express';\nimport { Readable, Writable } from 'stream';\n\nimport {\n AllowAccess,\n Callback,\n Config,\n Logger,\n Manifest,\n PackageAccess,\n RemoteUser,\n Token,\n TokenFilter,\n} from '@verdaccio/types';\n\nimport { VerdaccioError, searchUtils } from '.';\n\nexport interface AuthPluginPackage {\n packageName: string;\n packageVersion?: string;\n tag?: string;\n}\nexport interface PluginOptions {\n config: Config;\n logger: Logger;\n}\n\n/**\n * The base plugin class, set of utilities for developing\n * plugins.\n * @alpha\n * */\nexport class Plugin<PluginConfig> {\n static version = 1;\n public readonly version: number;\n public readonly config: PluginConfig | unknown;\n public readonly options: PluginOptions;\n public constructor(config: PluginConfig, options: PluginOptions) {\n this.version = Plugin.version;\n this.config = config;\n this.options = options;\n }\n\n public getVersion() {\n return this.version;\n }\n}\nexport interface StorageHandler {\n logger: Logger;\n deletePackage(fileName: string): Promise<void>;\n removePackage(): Promise<void>;\n // next packages migration (this list is meant to replace the callback parent functions)\n updatePackage(\n packageName: string,\n handleUpdate: (manifest: Manifest) => Promise<Manifest>\n ): Promise<Manifest>;\n readPackage(name: string): Promise<Manifest>;\n savePackage(pkgName: string, value: Manifest): Promise<void>;\n readTarball(pkgName: string, { signal }: { signal: AbortSignal }): Promise<Readable>;\n createPackage(name: string, manifest: Manifest): Promise<void>;\n writeTarball(tarballName: string, { signal }: { signal: AbortSignal }): Promise<Writable>;\n // verify if tarball exist in the storage\n hasTarball(fileName: string): Promise<boolean>;\n // verify if package exist in the storage\n hasPackage(): Promise<boolean>;\n}\n\nexport interface Storage<PluginConfig> extends Plugin<PluginConfig> {\n add(name: string): Promise<void>;\n remove(name: string): Promise<void>;\n get(): Promise<any>;\n init(): Promise<void>;\n getSecret(): Promise<string>;\n setSecret(secret: string): Promise<any>;\n getPackageStorage(packageInfo: string): StorageHandler;\n search(query: searchUtils.SearchQuery): Promise<searchUtils.SearchItem[]>;\n saveToken(token: Token): Promise<any>;\n deleteToken(user: string, tokenKey: string): Promise<any>;\n readTokens(filter: TokenFilter): Promise<Token[]>;\n}\n\n/**\n * This function allow add additional middleware to the application.\n *\n * ```ts\n * import express, { Request, Response } from 'express';\n * \n * class Middleware extends Plugin {\n * // instances of auth and storage are injected\n * register_middlewares(app, auth, storage) {\n * const router = express.Router();\n * router.post('/my-endpoint', (req: Request, res: Response): void => {\n res.status(200).end();\n });\n * }\n * }\n * \n * \n * const [plugin] = await asyncLoadPlugin(...);\n * plugin.register_middlewares(app, auth, storage);\n * ```\n */\nexport interface ExpressMiddleware<PluginConfig, Storage, Auth> extends Plugin<PluginConfig> {\n register_middlewares(app: Express, auth: Auth, storage: Storage): void;\n}\n\n/**\n * dasdsa\n */\nexport type AuthCallback = (error: VerdaccioError | null, groups?: string[] | false) => void;\n\nexport type AuthAccessCallback = (error: VerdaccioError | null, access?: boolean) => void;\nexport type AuthUserCallback = (error: VerdaccioError | null, access?: boolean | string) => void;\nexport type AuthChangePasswordCallback = (error: VerdaccioError | null, access?: boolean) => void;\nexport type AccessCallback = (error: VerdaccioError | null, ok?: boolean) => void;\nexport interface Auth<T> extends Plugin<T> {\n /**\n * Handles the authenticated method.\n * ```ts\n * class Auth {\n public authenticate(user: string, password: string, done: AuthCallback): void {\n if (!password) {\n return done(errorUtils.getUnauthorized(API_ERROR.BAD_USERNAME_PASSWORD));\n }\n // always return an array of users\n return done(null, [user]); \n * }\n * ```\n */\n authenticate(user: string, password: string, cb: AuthCallback): void;\n /**\n * Handles the authenticated method.\n * ```ts\n * class Auth {\n public adduser(user: string, password: string, done: AuthCallback): void {\n if (!password) {\n return done(errorUtils.getUnauthorized(API_ERROR.BAD_USERNAME_PASSWORD));\n }\n // return boolean\n return done(null, true); \n * }\n * ```\n */\n adduser?(user: string, password: string, cb: AuthUserCallback): void;\n changePassword?(\n user: string,\n password: string,\n newPassword: string,\n cb: AuthChangePasswordCallback\n ): void;\n allow_publish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;\n allow_publish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;\n allow_access?(user: RemoteUser, pkg: T & PackageAccess, cb: AccessCallback): void;\n allow_access?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AccessCallback): void;\n allow_unpublish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;\n allow_unpublish?(\n user: RemoteUser,\n pkg: AllowAccess & PackageAccess,\n cb: AuthAccessCallback\n ): void;\n apiJWTmiddleware?(helpers: any): RequestHandler;\n}\n\nexport interface IBasicAuth {\n authenticate(user: string, password: string, cb: Callback): void;\n invalidateToken?(token: string): Promise<void>;\n changePassword(user: string, password: string, newPassword: string, cb: Callback): void;\n allow_access(pkg: AuthPluginPackage, user: RemoteUser, callback: Callback): void;\n add_user(user: string, password: string, cb: Callback): any;\n}\n\nexport interface ManifestFilter<T> extends Plugin<T> {\n filter_metadata(packageInfo: Manifest): Promise<Manifest>;\n}\n"],"mappings":";;;;;;AA2BA;AACA;AACA;AACA;AACA;AACO,MAAMA,MAAM,CAAe;EAChC,OAAOC,OAAO,GAAG,CAAC;EAIXC,WAAWA,CAACC,MAAoB,EAAEC,OAAsB,EAAE;IAC/D,IAAI,CAACH,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACE,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;EAEOC,UAAUA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACJ,OAAO;EACrB;AACF;;AAmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AAFAK,OAAA,CAAAN,MAAA,GAAAA,MAAA"}
|
|
1
|
+
{"version":3,"file":"plugin-utils.js","names":["Plugin","version","constructor","config","options","getVersion","exports"],"sources":["../src/plugin-utils.ts"],"sourcesContent":["import { Express, RequestHandler } from 'express';\nimport { Readable, Writable } from 'stream';\n\nimport {\n AllowAccess,\n Callback,\n Config,\n Logger,\n Manifest,\n PackageAccess,\n RemoteUser,\n Token,\n TokenFilter,\n} from '@verdaccio/types';\n\nimport { VerdaccioError, searchUtils } from '.';\n\nexport interface AuthPluginPackage {\n packageName: string;\n packageVersion?: string;\n tag?: string;\n}\nexport interface PluginOptions {\n config: Config;\n logger: Logger;\n}\n\n/**\n * The base plugin class, set of utilities for developing\n * plugins.\n * @alpha\n * */\nexport class Plugin<PluginConfig> {\n static version = 1;\n public readonly version: number;\n public readonly config: PluginConfig | unknown;\n public readonly options: PluginOptions;\n public constructor(config: PluginConfig, options: PluginOptions) {\n this.version = Plugin.version;\n this.config = config;\n this.options = options;\n }\n\n public getVersion() {\n return this.version;\n }\n}\nexport interface StorageHandler {\n logger: Logger;\n deletePackage(fileName: string): Promise<void>;\n removePackage(): Promise<void>;\n // next packages migration (this list is meant to replace the callback parent functions)\n updatePackage(\n packageName: string,\n handleUpdate: (manifest: Manifest) => Promise<Manifest>\n ): Promise<Manifest>;\n readPackage(name: string): Promise<Manifest>;\n savePackage(pkgName: string, value: Manifest): Promise<void>;\n readTarball(pkgName: string, { signal }: { signal: AbortSignal }): Promise<Readable>;\n createPackage(name: string, manifest: Manifest): Promise<void>;\n writeTarball(tarballName: string, { signal }: { signal: AbortSignal }): Promise<Writable>;\n // verify if tarball exist in the storage\n hasTarball(fileName: string): Promise<boolean>;\n // verify if package exist in the storage\n hasPackage(): Promise<boolean>;\n}\n\nexport interface Storage<PluginConfig> extends Plugin<PluginConfig> {\n add(name: string): Promise<void>;\n remove(name: string): Promise<void>;\n get(): Promise<any>;\n init(): Promise<void>;\n getSecret(): Promise<string>;\n setSecret(secret: string): Promise<any>;\n getPackageStorage(packageInfo: string): StorageHandler;\n search(query: searchUtils.SearchQuery): Promise<searchUtils.SearchItem[]>;\n saveToken(token: Token): Promise<any>;\n deleteToken(user: string, tokenKey: string): Promise<any>;\n readTokens(filter: TokenFilter): Promise<Token[]>;\n}\n\n/**\n * This function allow add additional middleware to the application.\n *\n * ```ts\n * import express, { Request, Response } from 'express';\n * \n * class Middleware extends Plugin {\n * // instances of auth and storage are injected\n * register_middlewares(app, auth, storage) {\n * const router = express.Router();\n * router.post('/my-endpoint', (req: Request, res: Response): void => {\n res.status(200).end();\n });\n * }\n * }\n * \n * \n * const [plugin] = await asyncLoadPlugin(...);\n * plugin.register_middlewares(app, auth, storage);\n * ```\n */\nexport interface ExpressMiddleware<PluginConfig, Storage, Auth> extends Plugin<PluginConfig> {\n register_middlewares(app: Express, auth: Auth, storage: Storage): void;\n}\n\n/**\n * dasdsa\n */\nexport type AuthCallback = (error: VerdaccioError | null, groups?: string[] | false) => void;\n\nexport type AuthAccessCallback = (error: VerdaccioError | null, access?: boolean) => void;\nexport type AuthUserCallback = (error: VerdaccioError | null, access?: boolean | string) => void;\nexport type AuthChangePasswordCallback = (error: VerdaccioError | null, access?: boolean) => void;\nexport type AccessCallback = (error: VerdaccioError | null, ok?: boolean) => void;\nexport interface Auth<T> extends Plugin<T> {\n /**\n * Handles the authenticated method.\n * ```ts\n * class Auth {\n public authenticate(user: string, password: string, done: AuthCallback): void {\n if (!password) {\n return done(errorUtils.getUnauthorized(API_ERROR.BAD_USERNAME_PASSWORD));\n }\n // always return an array of users\n return done(null, [user]); \n * }\n * ```\n */\n authenticate(user: string, password: string, cb: AuthCallback): void;\n /**\n * Handles the authenticated method.\n * ```ts\n * class Auth {\n public adduser(user: string, password: string, done: AuthCallback): void {\n if (!password) {\n return done(errorUtils.getUnauthorized(API_ERROR.BAD_USERNAME_PASSWORD));\n }\n // return boolean\n return done(null, true); \n * }\n * ```\n */\n adduser?(user: string, password: string, cb: AuthUserCallback): void;\n changePassword?(\n user: string,\n password: string,\n newPassword: string,\n cb: AuthChangePasswordCallback\n ): void;\n allow_publish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;\n allow_publish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;\n allow_access?(user: RemoteUser, pkg: T & PackageAccess, cb: AccessCallback): void;\n allow_access?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AccessCallback): void;\n allow_unpublish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;\n allow_unpublish?(\n user: RemoteUser,\n pkg: AllowAccess & PackageAccess,\n cb: AuthAccessCallback\n ): void;\n apiJWTmiddleware?(helpers: any): RequestHandler;\n}\n\nexport interface IBasicAuth {\n authenticate(user: string, password: string, cb: Callback): void;\n invalidateToken?(token: string): Promise<void>;\n changePassword(user: string, password: string, newPassword: string, cb: Callback): void;\n allow_access(pkg: AuthPluginPackage, user: RemoteUser, callback: Callback): void;\n add_user(user: string, password: string, cb: Callback): any;\n}\n\nexport interface ManifestFilter<T> extends Plugin<T> {\n filter_metadata(packageInfo: Manifest): Promise<Manifest>;\n}\n"],"mappings":";;;;;;AA2BA;AACA;AACA;AACA;AACA;AACO,MAAMA,MAAM,CAAe;EAChC,OAAOC,OAAO,GAAG,CAAC;EAIXC,WAAWA,CAACC,MAAoB,EAAEC,OAAsB,EAAE;IAC/D,IAAI,CAACH,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACE,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;EAEOC,UAAUA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACJ,OAAO;EACrB;AACF;;AAmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AAFAK,OAAA,CAAAN,MAAA,GAAAA,MAAA","ignoreList":[]}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.validatePublishSingleVersion = validatePublishSingleVersion;
|
|
7
7
|
var _ajv = _interopRequireDefault(require("ajv"));
|
|
8
|
-
function _interopRequireDefault(
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
const ajv = new _ajv.default();
|
|
10
10
|
|
|
11
11
|
// FIXME: this could extend from @verdaccio/types but we need
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-manifest.js","names":["_ajv","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"file":"publish-manifest.js","names":["_ajv","_interopRequireDefault","require","e","__esModule","default","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,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1C,MAAMG,GAAG,GAAG,IAAIC,YAAG,CAAC,CAAC;;AAErB;AACA;;AAOA,MAAMC,MAAgC,GAAG;EACvCC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE;IACVC,IAAI,EAAE;MAAEF,IAAI,EAAE;IAAS,CAAC;IACxBG,QAAQ,EAAE;MAAEH,IAAI,EAAE,QAAQ;MAAEI,aAAa,EAAE;IAAE,CAAC;IAC9CC,YAAY,EAAE;MAAEL,IAAI,EAAE,QAAQ;MAAEI,aAAa,EAAE;IAAE;EACnD,CAAC;EACDE,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,cAAc,CAAC;EAC9CC,oBAAoB,EAAE;AACxB,CAAC;;AAED;AACA,MAAMC,QAAQ,GAAGX,GAAG,CAACY,OAAO,CAACV,MAAM,CAAC;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACO,SAASW,4BAA4BA,CAACC,QAAa,EAAE;EAC1D,IAAI,CAACA,QAAQ,EAAE;IACb,OAAO,KAAK;EACd;EACA,OAAOH,QAAQ,CAACG,QAAQ,CAAC;AAC3B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-utils.js","names":["UNSCOPED","exports"],"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,GAAAC,OAAA,CAAAD,QAAA,GAAG,UAAU"}
|
|
1
|
+
{"version":3,"file":"search-utils.js","names":["UNSCOPED","exports"],"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,GAAAC,OAAA,CAAAD,QAAA,GAAG,UAAU","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-utils.js","names":["_stream","require","readableToString","stream","chunks","chunk","push","Buffer","from","buffer","concat","str","toString","exports","transformObjectToString","Transform","objectMode","transform","encoding","callback","JSON","stringify"],"sources":["../src/stream-utils.ts"],"sourcesContent":["import { Readable, Transform } from 'stream';\n\n/**\n * Converts a buffer stream to a string.\n */\nconst readableToString = async (stream: Readable) => {\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 { readableToString, transformObjectToString };\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG,MAAOC,MAAgB,IAAK;EACnD,MAAMC,MAAgB,GAAG,EAAE;EAC3B,WAAW,IAAIC,KAAK,IAAIF,MAAM,EAAE;IAC9BC,MAAM,CAACE,IAAI,CAACC,MAAM,CAACC,IAAI,CAACH,KAAK,CAAC,CAAC;EACjC;EACA,MAAMI,MAAM,GAAGF,MAAM,CAACG,MAAM,CAACN,MAAM,CAAC;EACpC,MAAMO,GAAG,GAAGF,MAAM,CAACG,QAAQ,CAAC,OAAO,CAAC;EACpC,OAAOD,GAAG;AACZ,CAAC;;AAED;AACA;AACA;AAFAE,OAAA,CAAAX,gBAAA,GAAAA,gBAAA;AAGA,MAAMY,uBAAuB,GAAGA,CAAA,KAAM;EACpC,OAAO,IAAIC,iBAAS,CAAC;IACnBC,UAAU,EAAE,IAAI;IAChBC,SAAS,EAAEA,CAACZ,KAAK,EAAEa,QAAQ,EAAEC,QAAQ,KAAK;MACxCA,QAAQ,CAAC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAChB,KAAK,CAAC,CAAC;IACvC;EACF,CAAC,CAAC;AACJ,CAAC;AAACQ,OAAA,CAAAC,uBAAA,GAAAA,uBAAA"}
|
|
1
|
+
{"version":3,"file":"stream-utils.js","names":["_stream","require","readableToString","stream","chunks","chunk","push","Buffer","from","buffer","concat","str","toString","exports","transformObjectToString","Transform","objectMode","transform","encoding","callback","JSON","stringify"],"sources":["../src/stream-utils.ts"],"sourcesContent":["import { Readable, Transform } from 'stream';\n\n/**\n * Converts a buffer stream to a string.\n */\nconst readableToString = async (stream: Readable) => {\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 { readableToString, transformObjectToString };\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG,MAAOC,MAAgB,IAAK;EACnD,MAAMC,MAAgB,GAAG,EAAE;EAC3B,WAAW,IAAIC,KAAK,IAAIF,MAAM,EAAE;IAC9BC,MAAM,CAACE,IAAI,CAACC,MAAM,CAACC,IAAI,CAACH,KAAK,CAAC,CAAC;EACjC;EACA,MAAMI,MAAM,GAAGF,MAAM,CAACG,MAAM,CAACN,MAAM,CAAC;EACpC,MAAMO,GAAG,GAAGF,MAAM,CAACG,QAAQ,CAAC,OAAO,CAAC;EACpC,OAAOD,GAAG;AACZ,CAAC;;AAED;AACA;AACA;AAFAE,OAAA,CAAAX,gBAAA,GAAAA,gBAAA;AAGA,MAAMY,uBAAuB,GAAGA,CAAA,KAAM;EACpC,OAAO,IAAIC,iBAAS,CAAC;IACnBC,UAAU,EAAE,IAAI;IAChBC,SAAS,EAAEA,CAACZ,KAAK,EAAEa,QAAQ,EAAEC,QAAQ,KAAK;MACxCA,QAAQ,CAAC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAChB,KAAK,CAAC,CAAC;IACvC;EACF,CAAC,CAAC;AACJ,CAAC;AAACQ,OAAA,CAAAC,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -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 let [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":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orityValue","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 let [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,IAAI,CAACC,MAAM,CAAC,GAAGH,KAAK,CACjBI,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":[]}
|
|
@@ -18,7 +18,6 @@ export declare function validatePackage(name: string): boolean;
|
|
|
18
18
|
* @param {*} manifest
|
|
19
19
|
* @param {*} name
|
|
20
20
|
* @return {Object} the object with additional properties as dist-tags ad versions
|
|
21
|
-
* FUTURE: rename to normalizeMetadata
|
|
22
21
|
*/
|
|
23
22
|
export declare function normalizeMetadata(manifest: Manifest, name: string): Manifest;
|
|
24
23
|
/**
|
|
@@ -28,3 +27,4 @@ export declare function normalizeMetadata(manifest: Manifest, name: string): Man
|
|
|
28
27
|
*/
|
|
29
28
|
export declare function isObject(obj: any): boolean;
|
|
30
29
|
export declare function validatePassword(password: string, validation?: RegExp): boolean;
|
|
30
|
+
export declare function validateUserName(userName: any, expectedName: string): boolean;
|
|
@@ -15,10 +15,11 @@ Object.defineProperty(exports, "validatePublishSingleVersion", {
|
|
|
15
15
|
return _publishManifest.validatePublishSingleVersion;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
exports.validateUserName = validateUserName;
|
|
18
19
|
var _assert = _interopRequireDefault(require("assert"));
|
|
19
20
|
var _constants = require("./constants");
|
|
20
21
|
var _publishManifest = require("./schemes/publish-manifest");
|
|
21
|
-
function _interopRequireDefault(
|
|
22
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
23
|
function isPackageNameScoped(name) {
|
|
23
24
|
return name.startsWith('@');
|
|
24
25
|
}
|
|
@@ -75,7 +76,6 @@ function validatePackage(name) {
|
|
|
75
76
|
* @param {*} manifest
|
|
76
77
|
* @param {*} name
|
|
77
78
|
* @return {Object} the object with additional properties as dist-tags ad versions
|
|
78
|
-
* FUTURE: rename to normalizeMetadata
|
|
79
79
|
*/
|
|
80
80
|
function normalizeMetadata(manifest, name) {
|
|
81
81
|
_assert.default.strictEqual(manifest.name, name);
|
|
@@ -85,8 +85,11 @@ function normalizeMetadata(manifest, name) {
|
|
|
85
85
|
if (!isObject(manifest[_constants.DIST_TAGS])) {
|
|
86
86
|
_manifest[_constants.DIST_TAGS] = {};
|
|
87
87
|
}
|
|
88
|
+
if (!Array.isArray(manifest[_constants.MAINTAINERS])) {
|
|
89
|
+
_manifest[_constants.MAINTAINERS] = [];
|
|
90
|
+
}
|
|
88
91
|
|
|
89
|
-
// This may not be
|
|
92
|
+
// This may not be needed
|
|
90
93
|
if (!isObject(manifest['versions'])) {
|
|
91
94
|
_manifest['versions'] = {};
|
|
92
95
|
}
|
|
@@ -115,4 +118,7 @@ function isObject(obj) {
|
|
|
115
118
|
function validatePassword(password, validation = _constants.DEFAULT_PASSWORD_VALIDATION) {
|
|
116
119
|
return typeof password === 'string' && validation instanceof RegExp ? password.match(validation) !== null : false;
|
|
117
120
|
}
|
|
121
|
+
function validateUserName(userName, expectedName) {
|
|
122
|
+
return typeof userName === 'string' && userName.split(':')[0] === 'org.couchdb.user' && userName.split(':')[1] === expectedName;
|
|
123
|
+
}
|
|
118
124
|
//# sourceMappingURL=validation-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation-utils.js","names":["_assert","_interopRequireDefault","require","_constants","_publishManifest","
|
|
1
|
+
{"version":3,"file":"validation-utils.js","names":["_assert","_interopRequireDefault","require","_constants","_publishManifest","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 'assert';\n\nimport { Manifest } from '@verdaccio/types';\n\nimport { DEFAULT_PASSWORD_VALIDATION, DIST_TAGS, MAINTAINERS } 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 */\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":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAF,OAAA;AAA0E,SAAAD,uBAAAI,CAAA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B,KAAK,CAACuB,UAAU,CAAC,KAAK,IAAI,GACnC,KAAK;AACX;AAEO,SAASG,gBAAgBA,CAACC,QAAa,EAAEC,YAAoB,EAAW;EAC7E,OACE,OAAOD,QAAQ,KAAK,QAAQ,IAC5BA,QAAQ,CAAC5B,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,kBAAkB,IAC7C4B,QAAQ,CAAC5B,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK6B,YAAY;AAE3C","ignoreList":[]}
|
package/build/warning-utils.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export declare enum Codes {
|
|
|
3
3
|
VERWAR002 = "VERWAR002",
|
|
4
4
|
VERWAR003 = "VERWAR003",
|
|
5
5
|
VERWAR004 = "VERWAR004",
|
|
6
|
-
VERWAR005 = "VERWAR005",
|
|
7
6
|
VERDEP003 = "VERDEP003",
|
|
8
|
-
VERWAR006 = "VERWAR006"
|
|
7
|
+
VERWAR006 = "VERWAR006",
|
|
8
|
+
VERWAR007 = "VERWAR007"
|
|
9
9
|
}
|
|
10
10
|
export declare function emit(code: string, a?: string, b?: string, c?: string): void;
|
package/build/warning-utils.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Codes = void 0;
|
|
7
7
|
exports.emit = emit;
|
|
8
8
|
var _processWarning = _interopRequireDefault(require("process-warning"));
|
|
9
|
-
function _interopRequireDefault(
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
const warningInstance = (0, _processWarning.default)();
|
|
11
11
|
const verdaccioWarning = 'VerdaccioWarning';
|
|
12
12
|
const verdaccioDeprecation = 'VerdaccioDeprecation';
|
|
@@ -15,20 +15,25 @@ let Codes = exports.Codes = /*#__PURE__*/function (Codes) {
|
|
|
15
15
|
Codes["VERWAR002"] = "VERWAR002";
|
|
16
16
|
Codes["VERWAR003"] = "VERWAR003";
|
|
17
17
|
Codes["VERWAR004"] = "VERWAR004";
|
|
18
|
-
Codes["VERWAR005"] = "VERWAR005";
|
|
19
18
|
Codes["VERDEP003"] = "VERDEP003";
|
|
20
19
|
Codes["VERWAR006"] = "VERWAR006";
|
|
20
|
+
Codes["VERWAR007"] = "VERWAR007";
|
|
21
21
|
return Codes;
|
|
22
22
|
}({});
|
|
23
|
-
|
|
23
|
+
/* general warnings */
|
|
24
24
|
warningInstance.create(verdaccioWarning, Codes.VERWAR001, `Verdaccio doesn't need superuser privileges. don't run it under root`);
|
|
25
|
+
warningInstance.create(verdaccioWarning, Codes.VERWAR002, `The configuration property "logs" has been deprecated, please rename to "log" for future compatibility`);
|
|
25
26
|
warningInstance.create(verdaccioWarning, Codes.VERWAR003, 'rotating-file type is not longer supported, consider use [logrotate] instead');
|
|
26
27
|
warningInstance.create(verdaccioWarning, Codes.VERWAR004, `invalid address - %s, we expect a port (e.g. "4873"),
|
|
27
28
|
host:port (e.g. "localhost:4873") or full url '(e.g. "http://localhost:4873/")
|
|
28
29
|
https://verdaccio.org/docs/en/configuration#listen-port`);
|
|
29
|
-
warningInstance.create(verdaccioWarning, Codes.VERWAR005, 'disable enhanced legacy signature is considered a security risk, please reconsider enable it');
|
|
30
|
-
warningInstance.create(verdaccioDeprecation, Codes.VERDEP003, 'multiple addresses will be deprecated in the next major, only use one');
|
|
31
30
|
warningInstance.create(verdaccioDeprecation, Codes.VERWAR006, 'the auth plugin method "add_user" in the auth plugin is deprecated and will be removed in next major release, rename to "adduser"');
|
|
31
|
+
warningInstance.create(verdaccioDeprecation, Codes.VERWAR007, `the secret length is too long, it must be 32 characters long, please consider generate a new one
|
|
32
|
+
Learn more at https://verdaccio.org/docs/configuration/#.verdaccio-db`);
|
|
33
|
+
|
|
34
|
+
/* deprecation warnings */
|
|
35
|
+
|
|
36
|
+
warningInstance.create(verdaccioDeprecation, Codes.VERDEP003, 'multiple addresses will be deprecated in the next major, only use one');
|
|
32
37
|
function emit(code, a, b, c) {
|
|
33
38
|
warningInstance.emit(code, a, b, c);
|
|
34
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warning-utils.js","names":["_processWarning","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"file":"warning-utils.js","names":["_processWarning","_interopRequireDefault","require","e","__esModule","default","warningInstance","warning","verdaccioWarning","verdaccioDeprecation","Codes","exports","create","VERWAR001","VERWAR002","VERWAR003","VERWAR004","VERWAR006","VERWAR007","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 VERWAR002 = 'VERWAR002',\n VERWAR003 = 'VERWAR003',\n VERWAR004 = 'VERWAR004',\n // deprecation warnings\n VERDEP003 = 'VERDEP003',\n VERWAR006 = 'VERWAR006',\n VERWAR007 = 'VERWAR007',\n}\n\n/* general warnings */\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.VERWAR002,\n `The configuration property \"logs\" has been deprecated, please rename to \"log\" for future compatibility`\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.VERWAR006,\n 'the auth plugin method \"add_user\" in the auth plugin is deprecated and will be removed in next major release, rename to \"adduser\"'\n);\n\nwarningInstance.create(\n verdaccioDeprecation,\n Codes.VERWAR007,\n `the secret length is too long, it must be 32 characters long, please consider generate a new one \n Learn more at https://verdaccio.org/docs/configuration/#.verdaccio-db`\n);\n\n/* deprecation warnings */\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: string, a?: string, b?: string, c?: string) {\n warningInstance.emit(code, a, b, c);\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAsC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEtC,MAAMG,eAAe,GAAG,IAAAC,uBAAO,EAAC,CAAC;AACjC,MAAMC,gBAAgB,GAAG,kBAAkB;AAC3C,MAAMC,oBAAoB,GAAG,sBAAsB;AAAC,IAExCC,KAAK,GAAAC,OAAA,CAAAD,KAAA,0BAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAAA,OAALA,KAAK;AAAA;AAWjB;AAEAJ,eAAe,CAACM,MAAM,CACpBJ,gBAAgB,EAChBE,KAAK,CAACG,SAAS,EACf,sEACF,CAAC;AAEDP,eAAe,CAACM,MAAM,CACpBJ,gBAAgB,EAChBE,KAAK,CAACI,SAAS,EACf,wGACF,CAAC;AAEDR,eAAe,CAACM,MAAM,CACpBJ,gBAAgB,EAChBE,KAAK,CAACK,SAAS,EACf,8EACF,CAAC;AAEDT,eAAe,CAACM,MAAM,CACpBJ,gBAAgB,EAChBE,KAAK,CAACM,SAAS,EACf;AACF;AACA,wDACA,CAAC;AAEDV,eAAe,CAACM,MAAM,CACpBH,oBAAoB,EACpBC,KAAK,CAACO,SAAS,EACf,mIACF,CAAC;AAEDX,eAAe,CAACM,MAAM,CACpBH,oBAAoB,EACpBC,KAAK,CAACQ,SAAS,EACf;AACF,wEACA,CAAC;;AAED;;AAEAZ,eAAe,CAACM,MAAM,CACpBH,oBAAoB,EACpBC,KAAK,CAACS,SAAS,EACf,uEACF,CAAC;AAEM,SAASC,IAAIA,CAACC,IAAY,EAAEC,CAAU,EAAEC,CAAU,EAAEC,CAAU,EAAE;EACrElB,eAAe,CAACc,IAAI,CAACC,IAAI,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,CAAC;AACrC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-next-8.1",
|
|
4
4
|
"description": "core utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"private",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"homepage": "https://verdaccio.org",
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
22
|
+
"node": ">=14"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "https",
|
|
@@ -33,18 +33,18 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"ajv": "8.17.1",
|
|
37
|
+
"core-js": "3.37.1",
|
|
36
38
|
"http-errors": "2.0.0",
|
|
37
39
|
"http-status-codes": "2.3.0",
|
|
38
|
-
"semver": "7.5.4",
|
|
39
|
-
"ajv": "8.12.0",
|
|
40
40
|
"process-warning": "1.0.0",
|
|
41
|
-
"
|
|
41
|
+
"semver": "7.6.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
+
"@verdaccio/types": "13.0.0-next-8.0",
|
|
44
45
|
"lodash": "4.17.21",
|
|
45
46
|
"typedoc": "0.23.25",
|
|
46
|
-
"typedoc-plugin-missing-exports": "latest"
|
|
47
|
-
"@verdaccio/types": "12.0.0-next.2"
|
|
47
|
+
"typedoc-plugin-missing-exports": "latest"
|
|
48
48
|
},
|
|
49
49
|
"funding": {
|
|
50
50
|
"type": "opencollective",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"clean": "rimraf ./build",
|
|
55
|
-
"test": "
|
|
55
|
+
"test": "vitest run",
|
|
56
56
|
"type-check": "tsc --noEmit -p tsconfig.build.json",
|
|
57
57
|
"build:docs": "typedoc --options ./typedoc.json --tsconfig tsconfig.build.json",
|
|
58
58
|
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
|
package/src/constants.ts
CHANGED
|
@@ -6,6 +6,7 @@ export const TIME_EXPIRATION_1H = '1h';
|
|
|
6
6
|
export const DIST_TAGS = 'dist-tags';
|
|
7
7
|
export const LATEST = 'latest';
|
|
8
8
|
export const USERS = 'users';
|
|
9
|
+
export const MAINTAINERS = 'maintainers';
|
|
9
10
|
export const DEFAULT_USER = 'Anonymous';
|
|
10
11
|
|
|
11
12
|
export const HEADER_TYPE = {
|
|
@@ -118,3 +119,11 @@ export enum HtpasswdHashAlgorithm {
|
|
|
118
119
|
crypt = 'crypt',
|
|
119
120
|
bcrypt = 'bcrypt',
|
|
120
121
|
}
|
|
122
|
+
|
|
123
|
+
export const PLUGIN_CATEGORY = {
|
|
124
|
+
AUTHENTICATION: 'authentication',
|
|
125
|
+
MIDDLEWARE: 'middleware',
|
|
126
|
+
STORAGE: 'storage',
|
|
127
|
+
FILTER: 'filter',
|
|
128
|
+
THEME: 'theme',
|
|
129
|
+
};
|
package/src/error-utils.ts
CHANGED
|
@@ -39,6 +39,7 @@ export const API_ERROR = {
|
|
|
39
39
|
BAD_PACKAGE_DATA: 'bad incoming package data',
|
|
40
40
|
USERNAME_PASSWORD_REQUIRED: 'username and password is required',
|
|
41
41
|
USERNAME_ALREADY_REGISTERED: 'username is already registered',
|
|
42
|
+
USERNAME_MISMATCH: 'username does not match logged in user',
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
export const SUPPORT_ERRORS = {
|
package/src/index.ts
CHANGED
package/src/validation-utils.ts
CHANGED
|
@@ -2,7 +2,7 @@ import assert from 'assert';
|
|
|
2
2
|
|
|
3
3
|
import { Manifest } from '@verdaccio/types';
|
|
4
4
|
|
|
5
|
-
import { DEFAULT_PASSWORD_VALIDATION, DIST_TAGS } from './constants';
|
|
5
|
+
import { DEFAULT_PASSWORD_VALIDATION, DIST_TAGS, MAINTAINERS } from './constants';
|
|
6
6
|
|
|
7
7
|
export { validatePublishSingleVersion } from './schemes/publish-manifest';
|
|
8
8
|
|
|
@@ -67,7 +67,6 @@ export function validatePackage(name: string): boolean {
|
|
|
67
67
|
* @param {*} manifest
|
|
68
68
|
* @param {*} name
|
|
69
69
|
* @return {Object} the object with additional properties as dist-tags ad versions
|
|
70
|
-
* FUTURE: rename to normalizeMetadata
|
|
71
70
|
*/
|
|
72
71
|
export function normalizeMetadata(manifest: Manifest, name: string): Manifest {
|
|
73
72
|
assert.strictEqual(manifest.name, name);
|
|
@@ -77,7 +76,11 @@ export function normalizeMetadata(manifest: Manifest, name: string): Manifest {
|
|
|
77
76
|
_manifest[DIST_TAGS] = {};
|
|
78
77
|
}
|
|
79
78
|
|
|
80
|
-
|
|
79
|
+
if (!Array.isArray(manifest[MAINTAINERS])) {
|
|
80
|
+
_manifest[MAINTAINERS] = [];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// This may not be needed
|
|
81
84
|
if (!isObject(manifest['versions'])) {
|
|
82
85
|
_manifest['versions'] = {};
|
|
83
86
|
}
|
|
@@ -114,3 +117,11 @@ export function validatePassword(
|
|
|
114
117
|
? password.match(validation) !== null
|
|
115
118
|
: false;
|
|
116
119
|
}
|
|
120
|
+
|
|
121
|
+
export function validateUserName(userName: any, expectedName: string): boolean {
|
|
122
|
+
return (
|
|
123
|
+
typeof userName === 'string' &&
|
|
124
|
+
userName.split(':')[0] === 'org.couchdb.user' &&
|
|
125
|
+
userName.split(':')[1] === expectedName
|
|
126
|
+
);
|
|
127
|
+
}
|
package/src/warning-utils.ts
CHANGED
|
@@ -9,22 +9,24 @@ export enum Codes {
|
|
|
9
9
|
VERWAR002 = 'VERWAR002',
|
|
10
10
|
VERWAR003 = 'VERWAR003',
|
|
11
11
|
VERWAR004 = 'VERWAR004',
|
|
12
|
-
VERWAR005 = 'VERWAR005',
|
|
13
12
|
// deprecation warnings
|
|
14
13
|
VERDEP003 = 'VERDEP003',
|
|
15
14
|
VERWAR006 = 'VERWAR006',
|
|
15
|
+
VERWAR007 = 'VERWAR007',
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/* general warnings */
|
|
19
|
+
|
|
18
20
|
warningInstance.create(
|
|
19
21
|
verdaccioWarning,
|
|
20
|
-
Codes.
|
|
21
|
-
`
|
|
22
|
+
Codes.VERWAR001,
|
|
23
|
+
`Verdaccio doesn't need superuser privileges. don't run it under root`
|
|
22
24
|
);
|
|
23
25
|
|
|
24
26
|
warningInstance.create(
|
|
25
27
|
verdaccioWarning,
|
|
26
|
-
Codes.
|
|
27
|
-
`
|
|
28
|
+
Codes.VERWAR002,
|
|
29
|
+
`The configuration property "logs" has been deprecated, please rename to "log" for future compatibility`
|
|
28
30
|
);
|
|
29
31
|
|
|
30
32
|
warningInstance.create(
|
|
@@ -42,21 +44,24 @@ https://verdaccio.org/docs/en/configuration#listen-port`
|
|
|
42
44
|
);
|
|
43
45
|
|
|
44
46
|
warningInstance.create(
|
|
45
|
-
|
|
46
|
-
Codes.
|
|
47
|
-
'
|
|
47
|
+
verdaccioDeprecation,
|
|
48
|
+
Codes.VERWAR006,
|
|
49
|
+
'the auth plugin method "add_user" in the auth plugin is deprecated and will be removed in next major release, rename to "adduser"'
|
|
48
50
|
);
|
|
49
51
|
|
|
50
52
|
warningInstance.create(
|
|
51
53
|
verdaccioDeprecation,
|
|
52
|
-
Codes.
|
|
53
|
-
|
|
54
|
+
Codes.VERWAR007,
|
|
55
|
+
`the secret length is too long, it must be 32 characters long, please consider generate a new one
|
|
56
|
+
Learn more at https://verdaccio.org/docs/configuration/#.verdaccio-db`
|
|
54
57
|
);
|
|
55
58
|
|
|
59
|
+
/* deprecation warnings */
|
|
60
|
+
|
|
56
61
|
warningInstance.create(
|
|
57
62
|
verdaccioDeprecation,
|
|
58
|
-
Codes.
|
|
59
|
-
'
|
|
63
|
+
Codes.VERDEP003,
|
|
64
|
+
'multiple addresses will be deprecated in the next major, only use one'
|
|
60
65
|
);
|
|
61
66
|
|
|
62
67
|
export function emit(code: string, a?: string, b?: string, c?: string) {
|
package/test/errors.spec.ts
CHANGED
package/test/mystreams.spec.ts
CHANGED
package/test/pkg-utils.spec.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
|
|
1
3
|
import { DEFAULT_PASSWORD_VALIDATION, DIST_TAGS } from '../src/constants';
|
|
2
4
|
import { validatePublishSingleVersion } from '../src/schemes/publish-manifest';
|
|
3
5
|
import {
|
|
@@ -6,6 +8,7 @@ import {
|
|
|
6
8
|
validateName,
|
|
7
9
|
validatePackage,
|
|
8
10
|
validatePassword,
|
|
11
|
+
validateUserName,
|
|
9
12
|
} from '../src/validation-utils';
|
|
10
13
|
|
|
11
14
|
describe('validatePackage', () => {
|
|
@@ -61,10 +64,9 @@ describe('normalizeMetadata', () => {
|
|
|
61
64
|
|
|
62
65
|
test('should fails the assertions is name does not match', () => {
|
|
63
66
|
expect(function () {
|
|
64
|
-
// @ts-
|
|
67
|
+
// @ts-expect-error
|
|
65
68
|
normalizeMetadata({}, 'no-name');
|
|
66
|
-
|
|
67
|
-
}).toThrow(expect.hasAssertions());
|
|
69
|
+
}).toThrowError();
|
|
68
70
|
});
|
|
69
71
|
});
|
|
70
72
|
|
|
@@ -224,3 +226,17 @@ describe('validatePassword', () => {
|
|
|
224
226
|
expect(validatePassword('1235678910')).toBeTruthy();
|
|
225
227
|
});
|
|
226
228
|
});
|
|
229
|
+
|
|
230
|
+
describe('validateUserName', () => {
|
|
231
|
+
test('should validate username according to expected name', () => {
|
|
232
|
+
expect(validateUserName('org.couchdb.user:test', 'test')).toBeTruthy();
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
test('should fail to validate username if different from expected name', () => {
|
|
236
|
+
expect(validateUserName('org.couchdb.user:foouser', 'test')).toBeFalsy();
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
test('should fail to validate username if not given', () => {
|
|
240
|
+
expect(validateUserName(undefined, 'test')).toBeFalsy();
|
|
241
|
+
});
|
|
242
|
+
});
|
package/jest.config.js
DELETED