@verdaccio/core 6.0.0-6-next.50 → 6.0.0-6-next.52
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 +17 -0
- package/build/constants.d.ts +2 -1
- package/build/constants.js +6 -7
- package/build/constants.js.map +1 -1
- package/build/error-utils.d.ts +1 -1
- package/build/error-utils.js +0 -14
- package/build/error-utils.js.map +1 -1
- package/build/file-utils.js +2 -11
- package/build/file-utils.js.map +1 -1
- package/build/index.js +0 -23
- package/build/index.js.map +1 -1
- package/build/pkg-utils.js +3 -17
- package/build/pkg-utils.js.map +1 -1
- package/build/plugin-utils.d.ts +5 -5
- package/build/plugin-utils.js +0 -5
- package/build/plugin-utils.js.map +1 -1
- package/build/schemes/publish-manifest.js +5 -6
- package/build/schemes/publish-manifest.js.map +1 -1
- package/build/search-utils.d.ts +9 -9
- package/build/search-utils.js +2 -0
- package/build/search-utils.js.map +1 -1
- package/build/stream-utils.js +1 -8
- package/build/stream-utils.js.map +1 -1
- package/build/string-utils.js +0 -6
- package/build/string-utils.js.map +1 -1
- package/build/validation-utils.js +13 -31
- package/build/validation-utils.js.map +1 -1
- package/build/warning-utils.js +0 -6
- package/build/warning-utils.js.map +1 -1
- package/package.json +4 -4
- package/src/constants.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @verdaccio/core
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.52
|
|
4
|
+
|
|
5
|
+
## 6.0.0-6-next.51
|
|
6
|
+
|
|
7
|
+
### Minor Changes
|
|
8
|
+
|
|
9
|
+
- 4b29d715: chore: move improvements from v5 to v6
|
|
10
|
+
|
|
11
|
+
Migrate improvements form v5 to v6:
|
|
12
|
+
|
|
13
|
+
- https://github.com/verdaccio/verdaccio/pull/3158
|
|
14
|
+
- https://github.com/verdaccio/verdaccio/pull/3151
|
|
15
|
+
- https://github.com/verdaccio/verdaccio/pull/2271
|
|
16
|
+
- https://github.com/verdaccio/verdaccio/pull/2787
|
|
17
|
+
- https://github.com/verdaccio/verdaccio/pull/2791
|
|
18
|
+
- https://github.com/verdaccio/verdaccio/pull/2205
|
|
19
|
+
|
|
3
20
|
## 6.0.0-6-next.50
|
|
4
21
|
|
|
5
22
|
## 6.0.0-6-next.49
|
package/build/constants.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const DEFAULT_PASSWORD_VALIDATION: RegExp;
|
|
2
2
|
export declare const TIME_EXPIRATION_24H = "24h";
|
|
3
|
-
export declare const
|
|
3
|
+
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";
|
|
@@ -28,6 +28,7 @@ export declare const HEADERS: {
|
|
|
28
28
|
TEXT_HTML_UTF8: string;
|
|
29
29
|
TEXT_HTML: string;
|
|
30
30
|
AUTHORIZATION: string;
|
|
31
|
+
CACHE_CONTROL: string;
|
|
31
32
|
FORWARDED_PROTO: string;
|
|
32
33
|
FORWARDED_FOR: string;
|
|
33
34
|
FRAMES_OPTIONS: string;
|
package/build/constants.js
CHANGED
|
@@ -3,18 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.USERS = exports.TOKEN_BEARER = exports.TOKEN_BASIC = exports.
|
|
7
|
-
|
|
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.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;
|
|
8
7
|
var _httpStatusCodes = _interopRequireDefault(require("http-status-codes"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
const DEFAULT_PASSWORD_VALIDATION = /.{3}$/;
|
|
13
10
|
exports.DEFAULT_PASSWORD_VALIDATION = DEFAULT_PASSWORD_VALIDATION;
|
|
14
11
|
const TIME_EXPIRATION_24H = '24h';
|
|
15
12
|
exports.TIME_EXPIRATION_24H = TIME_EXPIRATION_24H;
|
|
16
|
-
const
|
|
17
|
-
exports.
|
|
13
|
+
const TIME_EXPIRATION_1H = '1h';
|
|
14
|
+
exports.TIME_EXPIRATION_1H = TIME_EXPIRATION_1H;
|
|
18
15
|
const DIST_TAGS = 'dist-tags';
|
|
19
16
|
exports.DIST_TAGS = DIST_TAGS;
|
|
20
17
|
const LATEST = 'latest';
|
|
@@ -32,8 +29,9 @@ const HEADER_TYPE = {
|
|
|
32
29
|
exports.HEADER_TYPE = HEADER_TYPE;
|
|
33
30
|
const CHARACTER_ENCODING = {
|
|
34
31
|
UTF8: 'utf8'
|
|
35
|
-
};
|
|
32
|
+
};
|
|
36
33
|
|
|
34
|
+
// @deprecated use Bearer instead
|
|
37
35
|
exports.CHARACTER_ENCODING = CHARACTER_ENCODING;
|
|
38
36
|
const TOKEN_BASIC = 'Basic';
|
|
39
37
|
exports.TOKEN_BASIC = TOKEN_BASIC;
|
|
@@ -51,6 +49,7 @@ const HEADERS = {
|
|
|
51
49
|
TEXT_HTML_UTF8: 'text/html; charset=utf-8',
|
|
52
50
|
TEXT_HTML: 'text/html',
|
|
53
51
|
AUTHORIZATION: 'authorization',
|
|
52
|
+
CACHE_CONTROL: 'Cache-Control',
|
|
54
53
|
// only set with proxy that setup HTTPS
|
|
55
54
|
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto
|
|
56
55
|
FORWARDED_PROTO: 'X-Forwarded-Proto',
|
package/build/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["DEFAULT_PASSWORD_VALIDATION","TIME_EXPIRATION_24H","
|
|
1
|
+
{"version":3,"file":"constants.js","names":["DEFAULT_PASSWORD_VALIDATION","TIME_EXPIRATION_24H","TIME_EXPIRATION_1H","DIST_TAGS","LATEST","USERS","DEFAULT_USER","HEADER_TYPE","CONTENT_ENCODING","CONTENT_TYPE","CONTENT_LENGTH","ACCEPT_ENCODING","CHARACTER_ENCODING","UTF8","TOKEN_BASIC","TOKEN_BEARER","HEADERS","ACCEPT","USER_AGENT","JSON","TEXT_PLAIN","TEXT_PLAIN_UTF8","TEXT_HTML_UTF8","TEXT_HTML","AUTHORIZATION","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","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"],"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 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};\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};\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: '$authentic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C,WAAW,EAAE,aAAa;EAC1BC,SAAS,EAAE,gBAAgB;EAC3B9B,EAAE,EAAE,IAAI;EACR+B,UAAU,EAAE;AACd,CAAC;AAAC;AAEK,MAAMC,kBAAkB,GAC7B,gFAAgF;AAAC;AAC5E,MAAMC,mBAAmB,GAAI,GAAED,kBAAmB,oBAAmB;AAAC;AACtE,MAAME,mBAAmB,GAAI,GAAEF,kBAAmB,mCAAkC;AAAC;AAErF,MAAMG,KAAK,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;AAAC;AAEK,MAAMC,cAAc,GAAG;EAC5BC,KAAK,EAAE,MAAM;EACbP,GAAG,EAAE;AACP,CAAC;AAAC"}
|
package/build/error-utils.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export declare const APP_ERROR: {
|
|
|
47
47
|
PROFILE_ERROR: string;
|
|
48
48
|
PASSWORD_VALIDATION: string;
|
|
49
49
|
};
|
|
50
|
-
export
|
|
50
|
+
export type VerdaccioError = HttpError & {
|
|
51
51
|
code: number;
|
|
52
52
|
};
|
|
53
53
|
export declare function getConflict(message?: string): VerdaccioError;
|
package/build/error-utils.js
CHANGED
|
@@ -13,13 +13,9 @@ exports.getInternalError = getInternalError;
|
|
|
13
13
|
exports.getNotFound = getNotFound;
|
|
14
14
|
exports.getServiceUnavailable = getServiceUnavailable;
|
|
15
15
|
exports.getUnauthorized = getUnauthorized;
|
|
16
|
-
|
|
17
16
|
var _httpErrors = _interopRequireDefault(require("http-errors"));
|
|
18
|
-
|
|
19
17
|
var _constants = require("./constants");
|
|
20
|
-
|
|
21
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
23
19
|
const API_ERROR = {
|
|
24
20
|
PASSWORD_SHORT: `The provided password does not pass the validation`,
|
|
25
21
|
MUST_BE_LOGGED: 'You must be logged in to publish packages.',
|
|
@@ -71,45 +67,35 @@ const APP_ERROR = {
|
|
|
71
67
|
PASSWORD_VALIDATION: 'not valid password'
|
|
72
68
|
};
|
|
73
69
|
exports.APP_ERROR = APP_ERROR;
|
|
74
|
-
|
|
75
70
|
function getError(code, message) {
|
|
76
71
|
const httpError = (0, _httpErrors.default)(code, message);
|
|
77
72
|
httpError.code = code;
|
|
78
73
|
return httpError;
|
|
79
74
|
}
|
|
80
|
-
|
|
81
75
|
function getConflict(message = API_ERROR.PACKAGE_EXIST) {
|
|
82
76
|
return getError(_constants.HTTP_STATUS.CONFLICT, message);
|
|
83
77
|
}
|
|
84
|
-
|
|
85
78
|
function getBadData(customMessage) {
|
|
86
79
|
return getError(_constants.HTTP_STATUS.BAD_DATA, customMessage || API_ERROR.BAD_DATA);
|
|
87
80
|
}
|
|
88
|
-
|
|
89
81
|
function getBadRequest(customMessage) {
|
|
90
82
|
return getError(_constants.HTTP_STATUS.BAD_REQUEST, customMessage);
|
|
91
83
|
}
|
|
92
|
-
|
|
93
84
|
function getInternalError(customMessage) {
|
|
94
85
|
return customMessage ? getError(_constants.HTTP_STATUS.INTERNAL_ERROR, customMessage) : getError(_constants.HTTP_STATUS.INTERNAL_ERROR, API_ERROR.UNKNOWN_ERROR);
|
|
95
86
|
}
|
|
96
|
-
|
|
97
87
|
function getUnauthorized(message = 'no credentials provided') {
|
|
98
88
|
return getError(_constants.HTTP_STATUS.UNAUTHORIZED, message);
|
|
99
89
|
}
|
|
100
|
-
|
|
101
90
|
function getForbidden(message = "can't use this filename") {
|
|
102
91
|
return getError(_constants.HTTP_STATUS.FORBIDDEN, message);
|
|
103
92
|
}
|
|
104
|
-
|
|
105
93
|
function getServiceUnavailable(message = API_ERROR.RESOURCE_UNAVAILABLE) {
|
|
106
94
|
return getError(_constants.HTTP_STATUS.SERVICE_UNAVAILABLE, message);
|
|
107
95
|
}
|
|
108
|
-
|
|
109
96
|
function getNotFound(customMessage) {
|
|
110
97
|
return getError(_constants.HTTP_STATUS.NOT_FOUND, customMessage || API_ERROR.NO_PACKAGE);
|
|
111
98
|
}
|
|
112
|
-
|
|
113
99
|
function getCode(statusCode, customMessage) {
|
|
114
100
|
return getError(statusCode, customMessage);
|
|
115
101
|
}
|
package/build/error-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-utils.js","names":["API_ERROR","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","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","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 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};\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":"
|
|
1
|
+
{"version":3,"file":"error-utils.js","names":["API_ERROR","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","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","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 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};\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;AAEA;AAA0C;AAEnC,MAAMA,SAAS,GAAG;E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AmB,EAAEjB,OAAO,CAAC;AAC3D;AAEO,SAASkB,WAAW,CAACX,aAAsB,EAAkB;EAClE,OAAOT,QAAQ,CAACM,sBAAW,CAACe,SAAS,EAAEZ,aAAa,IAAItD,SAAS,CAACM,UAAU,CAAC;AAC/E;AAEO,SAAS6D,OAAO,CAACC,UAAkB,EAAEd,aAAqB,EAAkB;EACjF,OAAOT,QAAQ,CAACuB,UAAU,EAAEd,aAAa,CAAC;AAC5C"}
|
package/build/file-utils.js
CHANGED
|
@@ -6,42 +6,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Files = void 0;
|
|
7
7
|
exports.createTempFolder = createTempFolder;
|
|
8
8
|
exports.createTempStorageFolder = createTempStorageFolder;
|
|
9
|
-
|
|
10
9
|
var _promises = require("fs/promises");
|
|
11
|
-
|
|
12
10
|
var _os = _interopRequireDefault(require("os"));
|
|
13
|
-
|
|
14
11
|
var _path = _interopRequireDefault(require("path"));
|
|
15
|
-
|
|
16
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
13
|
const Files = {
|
|
19
14
|
DatabaseName: '.verdaccio-db.json'
|
|
20
15
|
};
|
|
16
|
+
|
|
21
17
|
/**
|
|
22
18
|
* Create a temporary folder.
|
|
23
19
|
* @param prefix The prefix of the folder name.
|
|
24
20
|
* @returns string
|
|
25
21
|
*/
|
|
26
|
-
|
|
27
22
|
exports.Files = Files;
|
|
28
|
-
|
|
29
23
|
async function createTempFolder(prefix) {
|
|
30
24
|
return await (0, _promises.mkdtemp)(_path.default.join(_os.default.tmpdir(), prefix));
|
|
31
25
|
}
|
|
26
|
+
|
|
32
27
|
/**
|
|
33
28
|
* Create temporary folder for an asset.
|
|
34
29
|
* @param prefix
|
|
35
30
|
* @param folder name
|
|
36
31
|
* @returns
|
|
37
32
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
33
|
async function createTempStorageFolder(prefix, folder = 'storage') {
|
|
41
34
|
const tempFolder = await createTempFolder(prefix);
|
|
42
|
-
|
|
43
35
|
const storageFolder = _path.default.join(tempFolder, folder);
|
|
44
|
-
|
|
45
36
|
await (0, _promises.mkdir)(storageFolder);
|
|
46
37
|
return storageFolder;
|
|
47
38
|
}
|
package/build/file-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-utils.js","names":["Files","DatabaseName","createTempFolder","prefix","mkdtemp","path","join","os","tmpdir","createTempStorageFolder","folder","tempFolder","storageFolder","mkdir"],"sources":["../src/file-utils.ts"],"sourcesContent":["import { mkdir, mkdtemp } from 'fs/promises';\nimport os from 'os';\nimport path from 'path';\n\nexport const Files = {\n DatabaseName: '.verdaccio-db.json',\n};\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":"
|
|
1
|
+
{"version":3,"file":"file-utils.js","names":["Files","DatabaseName","createTempFolder","prefix","mkdtemp","path","join","os","tmpdir","createTempStorageFolder","folder","tempFolder","storageFolder","mkdir"],"sources":["../src/file-utils.ts"],"sourcesContent":["import { mkdir, mkdtemp } from 'fs/promises';\nimport os from 'os';\nimport path from 'path';\n\nexport const Files = {\n DatabaseName: '.verdaccio-db.json',\n};\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;AACA;AACA;AAAwB;AAEjB,MAAMA,KAAK,GAAG;EACnBC,YAAY,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJA;AAKO,eAAeC,gBAAgB,CAACC,MAAc,EAAmB;EACtE,OAAO,MAAM,IAAAC,iBAAO,EAACC,aAAI,CAACC,IAAI,CAACC,WAAE,CAACC,MAAM,EAAE,EAAEL,MAAM,CAAC,CAAC;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeM,uBAAuB,CAACN,MAAc,EAAEO,MAAM,GAAG,SAAS,EAAmB;EACjG,MAAMC,UAAU,GAAG,MAAMT,gBAAgB,CAACC,MAAM,CAAC;EACjD,MAAMS,aAAa,GAAGP,aAAI,CAACC,IAAI,CAACK,UAAU,EAAED,MAAM,CAAC;EACnD,MAAM,IAAAG,eAAK,EAACD,aAAa,CAAC;EAC1B,OAAOA,aAAa;AACtB"}
|
package/build/index.js
CHANGED
|
@@ -100,51 +100,28 @@ Object.defineProperty(exports, "VerdaccioError", {
|
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
102
|
exports.warningUtils = exports.validationUtils = exports.validatioUtils = exports.stringUtils = exports.streamUtils = exports.searchUtils = exports.pluginUtils = exports.pkgUtils = exports.fileUtils = exports.errorUtils = exports.constants = void 0;
|
|
103
|
-
|
|
104
103
|
var constants = _interopRequireWildcard(require("./constants"));
|
|
105
|
-
|
|
106
104
|
exports.constants = constants;
|
|
107
|
-
|
|
108
105
|
var errorUtils = _interopRequireWildcard(require("./error-utils"));
|
|
109
|
-
|
|
110
106
|
exports.errorUtils = errorUtils;
|
|
111
|
-
|
|
112
107
|
var fileUtils = _interopRequireWildcard(require("./file-utils"));
|
|
113
|
-
|
|
114
108
|
exports.fileUtils = fileUtils;
|
|
115
|
-
|
|
116
109
|
var pkgUtils = _interopRequireWildcard(require("./pkg-utils"));
|
|
117
|
-
|
|
118
110
|
exports.pkgUtils = pkgUtils;
|
|
119
|
-
|
|
120
111
|
var pluginUtils = _interopRequireWildcard(require("./plugin-utils"));
|
|
121
|
-
|
|
122
112
|
exports.pluginUtils = pluginUtils;
|
|
123
|
-
|
|
124
113
|
var searchUtils = _interopRequireWildcard(require("./search-utils"));
|
|
125
|
-
|
|
126
114
|
exports.searchUtils = searchUtils;
|
|
127
|
-
|
|
128
115
|
var streamUtils = _interopRequireWildcard(require("./stream-utils"));
|
|
129
|
-
|
|
130
116
|
exports.streamUtils = streamUtils;
|
|
131
|
-
|
|
132
117
|
var stringUtils = _interopRequireWildcard(require("./string-utils"));
|
|
133
|
-
|
|
134
118
|
exports.stringUtils = stringUtils;
|
|
135
|
-
|
|
136
119
|
var validatioUtils = _interopRequireWildcard(require("./validation-utils"));
|
|
137
|
-
|
|
138
120
|
exports.validatioUtils = validatioUtils;
|
|
139
|
-
|
|
140
121
|
var warningUtils = _interopRequireWildcard(require("./warning-utils"));
|
|
141
|
-
|
|
142
122
|
exports.warningUtils = warningUtils;
|
|
143
|
-
|
|
144
123
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
145
|
-
|
|
146
124
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
147
|
-
|
|
148
125
|
const validationUtils = validatioUtils;
|
|
149
126
|
exports.validationUtils = validationUtils;
|
|
150
127
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["validationUtils","validatioUtils"],"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} 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":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["validationUtils","validatioUtils"],"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} 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;AAAyC;AACzC;AAA4C;AAC5C;AAA0C;AAC1C;AAAwC;AACxC;AAA8C;AAC9C;AAA8C;AAC9C;AAA8C;AAC9C;AAA8C;AAC9C;AAAqD;AACrD;AAAgD;AAAA;AAAA;AAiBhD,MAAMA,eAAe,GAAGC,cAAc;AAAC"}
|
package/build/pkg-utils.js
CHANGED
|
@@ -7,15 +7,10 @@ exports.extractTarballName = extractTarballName;
|
|
|
7
7
|
exports.getLatest = getLatest;
|
|
8
8
|
exports.mergeVersions = mergeVersions;
|
|
9
9
|
exports.semverSort = semverSort;
|
|
10
|
-
|
|
11
10
|
var _semver = _interopRequireDefault(require("semver"));
|
|
12
|
-
|
|
13
11
|
var _url = require("url");
|
|
14
|
-
|
|
15
12
|
var _constants = require("./constants");
|
|
16
|
-
|
|
17
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
19
14
|
/**
|
|
20
15
|
* Extract the tarball name from a registry dist url
|
|
21
16
|
* 'https://registry.npmjs.org/test/-/test-0.0.2.tgz'
|
|
@@ -27,40 +22,35 @@ function extractTarballName(tarball) {
|
|
|
27
22
|
const filename = urlObject.pathname.replace(/^.*\//, '');
|
|
28
23
|
return filename;
|
|
29
24
|
}
|
|
25
|
+
|
|
30
26
|
/**
|
|
31
27
|
* Function filters out bad semver versions and sorts the array.
|
|
32
28
|
* @return {Array} sorted Array
|
|
33
29
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
30
|
function semverSort(listVersions) {
|
|
37
31
|
return listVersions.filter(function (x) {
|
|
38
32
|
if (!_semver.default.parse(x, true)) {
|
|
39
33
|
return false;
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
return true;
|
|
43
36
|
}).sort(_semver.default.compareLoose).map(String);
|
|
44
37
|
}
|
|
38
|
+
|
|
45
39
|
/**
|
|
46
40
|
* Get the latest publihsed version of a package.
|
|
47
41
|
* @param package metadata
|
|
48
42
|
**/
|
|
49
|
-
|
|
50
|
-
|
|
51
43
|
function getLatest(pkg) {
|
|
52
44
|
var _pkg$DIST_TAGS;
|
|
53
|
-
|
|
54
45
|
const listVersions = Object.keys(pkg.versions);
|
|
55
|
-
|
|
56
46
|
if (listVersions.length < 1) {
|
|
57
47
|
throw Error('cannot get lastest version of none');
|
|
58
48
|
}
|
|
59
|
-
|
|
60
49
|
const versions = semverSort(listVersions);
|
|
61
50
|
const latest = (_pkg$DIST_TAGS = pkg[_constants.DIST_TAGS]) !== null && _pkg$DIST_TAGS !== void 0 && _pkg$DIST_TAGS.latest ? pkg[_constants.DIST_TAGS].latest : versions[0];
|
|
62
51
|
return latest;
|
|
63
52
|
}
|
|
53
|
+
|
|
64
54
|
/**
|
|
65
55
|
* Function gets a local info and an info from uplinks and tries to merge it
|
|
66
56
|
exported for unit tests only.
|
|
@@ -70,8 +60,6 @@ function getLatest(pkg) {
|
|
|
70
60
|
* @deprecated use @verdaccio/storage mergeVersions method
|
|
71
61
|
*/
|
|
72
62
|
// @deprecated
|
|
73
|
-
|
|
74
|
-
|
|
75
63
|
function mergeVersions(local, upstream) {
|
|
76
64
|
// copy new versions to a cache
|
|
77
65
|
// NOTE: if a certain version was updated, we can't refresh it reliably
|
|
@@ -80,13 +68,11 @@ function mergeVersions(local, upstream) {
|
|
|
80
68
|
local.versions[i] = upstream.versions[i];
|
|
81
69
|
}
|
|
82
70
|
}
|
|
83
|
-
|
|
84
71
|
for (const i in upstream[_constants.DIST_TAGS]) {
|
|
85
72
|
if (local[_constants.DIST_TAGS][i] !== upstream[_constants.DIST_TAGS][i]) {
|
|
86
73
|
if (!local[_constants.DIST_TAGS][i] || _semver.default.lte(local[_constants.DIST_TAGS][i], upstream[_constants.DIST_TAGS][i])) {
|
|
87
74
|
local[_constants.DIST_TAGS][i] = upstream[_constants.DIST_TAGS][i];
|
|
88
75
|
}
|
|
89
|
-
|
|
90
76
|
if (i === 'latest' && local[_constants.DIST_TAGS][i] === upstream[_constants.DIST_TAGS][i]) {
|
|
91
77
|
// if remote has more fresh package, we should borrow its readme
|
|
92
78
|
local.readme = upstream.readme;
|
package/build/pkg-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkg-utils.js","names":["extractTarballName","tarball","urlObject","URL","filename","pathname","replace","semverSort","listVersions","filter","x","semver","parse","sort","compareLoose","map","String","getLatest","pkg","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":"
|
|
1
|
+
{"version":3,"file":"pkg-utils.js","names":["extractTarballName","tarball","urlObject","URL","filename","pathname","replace","semverSort","listVersions","filter","x","semver","parse","sort","compareLoose","map","String","getLatest","pkg","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;AACA;AA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,KAAK,CAACN,QAAQ,CAACQ,CAAC,CAAC,KAAK,WAAW,EAAE;MAC5CF,KAAK,CAACN,QAAQ,CAACQ,CAAC,CAAC,GAAGD,QAAQ,CAACP,QAAQ,CAACQ,CAAC,CAAC;IAC1C;EACF;EAEA,KAAK,MAAMA,CAAC,IAAID,QAAQ,CAACH,oBAAS,CAAC,EAAE;IACnC,IAAIE,KAAK,CAACF,oBAAS,CAAC,CAACI,CAAC,CAAC,KAAKD,QAAQ,CAACH,oBAAS,CAAC,CAACI,CAAC,CAAC,EAAE;MAClD,IAAI,CAACF,KAAK,CAACF,oBAAS,CAAC,CAACI,CAAC,CAAC,IAAIlB,eAAM,CAACmB,GAAG,CAACH,KAAK,CAACF,oBAAS,CAAC,CAACI,CAAC,CAAC,EAAED,QAAQ,CAACH,oBAAS,CAAC,CAACI,CAAC,CAAC,CAAC,EAAE;QACnFF,KAAK,CAACF,oBAAS,CAAC,CAACI,CAAC,CAAC,GAAGD,QAAQ,CAACH,oBAAS,CAAC,CAACI,CAAC,CAAC;MAC9C;MACA,IAAIA,CAAC,KAAK,QAAQ,IAAIF,KAAK,CAACF,oBAAS,CAAC,CAACI,CAAC,CAAC,KAAKD,QAAQ,CAACH,oBAAS,CAAC,CAACI,CAAC,CAAC,EAAE;QACpE;QACAF,KAAK,CAACI,MAAM,GAAGH,QAAQ,CAACG,MAAM;MAChC;IACF;EACF;AACF"}
|
package/build/plugin-utils.d.ts
CHANGED
|
@@ -82,11 +82,11 @@ export interface ExpressMiddleware<PluginConfig, Storage, Auth> extends Plugin<P
|
|
|
82
82
|
/**
|
|
83
83
|
* dasdsa
|
|
84
84
|
*/
|
|
85
|
-
export
|
|
86
|
-
export
|
|
87
|
-
export
|
|
88
|
-
export
|
|
89
|
-
export
|
|
85
|
+
export type AuthCallback = (error: VerdaccioError | null, groups?: string[] | false) => void;
|
|
86
|
+
export type AuthAccessCallback = (error: VerdaccioError | null, access?: boolean) => void;
|
|
87
|
+
export type AuthUserCallback = (error: VerdaccioError | null, access?: boolean | string) => void;
|
|
88
|
+
export type AuthChangePasswordCallback = (error: VerdaccioError | null, access?: boolean) => void;
|
|
89
|
+
export type AccessCallback = (error: VerdaccioError | null, ok?: boolean) => void;
|
|
90
90
|
export interface Auth<T> extends Plugin<T> {
|
|
91
91
|
/**
|
|
92
92
|
* Handles the authenticated method.
|
package/build/plugin-utils.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Plugin = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* The base plugin class, set of utilities for developing
|
|
10
9
|
* plugins.
|
|
@@ -12,18 +11,14 @@ exports.Plugin = void 0;
|
|
|
12
11
|
* */
|
|
13
12
|
class Plugin {
|
|
14
13
|
static version = 1;
|
|
15
|
-
|
|
16
14
|
constructor(config, options) {
|
|
17
15
|
this.version = Plugin.version;
|
|
18
16
|
this.config = config;
|
|
19
17
|
this.options = options;
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
getVersion() {
|
|
23
20
|
return this.version;
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
exports.Plugin = Plugin;
|
|
29
24
|
//# sourceMappingURL=plugin-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-utils.js","names":["Plugin","version","constructor","config","options","getVersion"],"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 filterMetadata(packageInfo: Manifest): Promise<Manifest>;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin-utils.js","names":["Plugin","version","constructor","config","options","getVersion"],"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 filterMetadata(packageInfo: Manifest): Promise<Manifest>;\n}\n"],"mappings":";;;;;;AA2BA;AACA;AACA;AACA;AACA;AACO,MAAMA,MAAM,CAAe;EAChC,OAAOC,OAAO,GAAG,CAAC;EAIXC,WAAW,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,UAAU,GAAG;IAClB,OAAO,IAAI,CAACJ,OAAO;EACrB;AACF;AAAC"}
|
|
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.validatePublishSingleVersion = validatePublishSingleVersion;
|
|
7
|
-
|
|
8
7
|
var _ajv = _interopRequireDefault(require("ajv"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
const ajv = new _ajv.default();
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
// FIXME: this could extend from @verdaccio/types but we need
|
|
13
12
|
// schemas from @verdaccio/types to be able to validate them
|
|
14
13
|
|
|
15
14
|
const schema = {
|
|
@@ -29,21 +28,21 @@ const schema = {
|
|
|
29
28
|
},
|
|
30
29
|
required: ['name', 'versions', '_attachments'],
|
|
31
30
|
additionalProperties: true
|
|
32
|
-
};
|
|
31
|
+
};
|
|
33
32
|
|
|
33
|
+
// validate is a type guard for MyData - type is inferred from schema type
|
|
34
34
|
const validate = ajv.compile(schema);
|
|
35
|
+
|
|
35
36
|
/**
|
|
36
37
|
* Validate if a manifest has the correct structure when a new package
|
|
37
38
|
* is being created. The properties name, versions and _attachments must contain 1 element.
|
|
38
39
|
* @param data a manifest object
|
|
39
40
|
* @returns boolean
|
|
40
41
|
*/
|
|
41
|
-
|
|
42
42
|
function validatePublishSingleVersion(manifest) {
|
|
43
43
|
if (!manifest) {
|
|
44
44
|
return false;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
46
|
return validate(manifest);
|
|
48
47
|
}
|
|
49
48
|
//# sourceMappingURL=publish-manifest.js.map
|
|
@@ -1 +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":"
|
|
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;AAA0C;AAE1C,MAAMA,GAAG,GAAG,IAAIC,YAAG,EAAE;;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,4BAA4B,CAACC,QAAa,EAAE;EAC1D,IAAI,CAACA,QAAQ,EAAE;IACb,OAAO,KAAK;EACd;EACA,OAAOH,QAAQ,CAACG,QAAQ,CAAC;AAC3B"}
|
package/build/search-utils.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type SearchMetrics = {
|
|
2
2
|
quality: number;
|
|
3
3
|
popularity: number;
|
|
4
4
|
maintenance: number;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type UnStable = {
|
|
7
7
|
flags?: {
|
|
8
8
|
unstable?: boolean;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type SearchItemPkg = {
|
|
12
12
|
name: string;
|
|
13
13
|
scoped?: string;
|
|
14
14
|
path?: string;
|
|
15
15
|
time?: number | Date;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
type PrivatePackage = {
|
|
18
18
|
verdaccioPrivate?: boolean;
|
|
19
19
|
verdaccioPkgCached?: boolean;
|
|
20
20
|
};
|
|
@@ -22,20 +22,20 @@ export interface SearchItem extends UnStable, PrivatePackage {
|
|
|
22
22
|
package: SearchItemPkg;
|
|
23
23
|
score: Score;
|
|
24
24
|
}
|
|
25
|
-
export
|
|
25
|
+
export type Score = {
|
|
26
26
|
final: number;
|
|
27
27
|
detail: SearchMetrics;
|
|
28
28
|
};
|
|
29
|
-
export
|
|
29
|
+
export type SearchResults = {
|
|
30
30
|
objects: SearchItemPkg[];
|
|
31
31
|
total: number;
|
|
32
32
|
time: string;
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
type PublisherMaintainer = {
|
|
35
35
|
username: string;
|
|
36
36
|
email: string;
|
|
37
37
|
};
|
|
38
|
-
export
|
|
38
|
+
export type SearchPackageBody = {
|
|
39
39
|
name: string;
|
|
40
40
|
scope: string;
|
|
41
41
|
description: string;
|
|
@@ -58,7 +58,7 @@ export interface SearchPackageItem extends UnStable, PrivatePackage {
|
|
|
58
58
|
searchScore?: number;
|
|
59
59
|
}
|
|
60
60
|
export declare const UNSCOPED = "unscoped";
|
|
61
|
-
export
|
|
61
|
+
export type SearchQuery = {
|
|
62
62
|
text: string;
|
|
63
63
|
size?: number;
|
|
64
64
|
from?: number;
|
package/build/search-utils.js
CHANGED
|
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.UNSCOPED = void 0;
|
|
7
7
|
// @deprecated use @verdaccio/types
|
|
8
|
+
|
|
8
9
|
// @deprecated use @verdaccio/types
|
|
10
|
+
|
|
9
11
|
const UNSCOPED = 'unscoped';
|
|
10
12
|
exports.UNSCOPED = UNSCOPED;
|
|
11
13
|
//# sourceMappingURL=search-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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,UAAU;AAAC"}
|
package/build/stream-utils.js
CHANGED
|
@@ -4,30 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.transformObjectToString = exports.readableToString = void 0;
|
|
7
|
-
|
|
8
7
|
var _stream = require("stream");
|
|
9
|
-
|
|
10
8
|
/**
|
|
11
9
|
* Converts a buffer stream to a string.
|
|
12
10
|
*/
|
|
13
11
|
const readableToString = async stream => {
|
|
14
12
|
const chunks = [];
|
|
15
|
-
|
|
16
13
|
for await (let chunk of stream) {
|
|
17
14
|
chunks.push(Buffer.from(chunk));
|
|
18
15
|
}
|
|
19
|
-
|
|
20
16
|
const buffer = Buffer.concat(chunks);
|
|
21
17
|
const str = buffer.toString('utf-8');
|
|
22
18
|
return str;
|
|
23
19
|
};
|
|
20
|
+
|
|
24
21
|
/**
|
|
25
22
|
* Transform stream object mode to string
|
|
26
23
|
**/
|
|
27
|
-
|
|
28
|
-
|
|
29
24
|
exports.readableToString = readableToString;
|
|
30
|
-
|
|
31
25
|
const transformObjectToString = () => {
|
|
32
26
|
return new _stream.Transform({
|
|
33
27
|
objectMode: true,
|
|
@@ -36,6 +30,5 @@ const transformObjectToString = () => {
|
|
|
36
30
|
}
|
|
37
31
|
});
|
|
38
32
|
};
|
|
39
|
-
|
|
40
33
|
exports.transformObjectToString = transformObjectToString;
|
|
41
34
|
//# sourceMappingURL=stream-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-utils.js","names":["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 { 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":"
|
|
1
|
+
{"version":3,"file":"stream-utils.js","names":["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 { 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;AAEA;AACA;AACA;AACA,MAAMA,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;AAFA;AAGA,MAAME,uBAAuB,GAAG,MAAM;EACpC,OAAO,IAAIC,iBAAS,CAAC;IACnBC,UAAU,EAAE,IAAI;IAChBC,SAAS,EAAE,CAACX,KAAK,EAAEY,QAAQ,EAAEC,QAAQ,KAAK;MACxCA,QAAQ,CAAC,IAAI,EAAEC,IAAI,CAACC,SAAS,CAACf,KAAK,CAAC,CAAC;IACvC;EACF,CAAC,CAAC;AACJ,CAAC;AAAC"}
|
package/build/string-utils.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getByQualityPriorityValue = getByQualityPriorityValue;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Quality values, or q-values and q-factors, are used to describe the order
|
|
10
9
|
* of priority of values in a comma-separated list.
|
|
@@ -16,17 +15,13 @@ function getByQualityPriorityValue(headerValue) {
|
|
|
16
15
|
if (typeof headerValue !== 'string') {
|
|
17
16
|
return '';
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
const split = headerValue.split(',');
|
|
21
|
-
|
|
22
19
|
if (split.length <= 1) {
|
|
23
20
|
const qList = split[0].split(';');
|
|
24
21
|
return qList[0];
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
let [header] = split.reduce((acc, item) => {
|
|
28
24
|
const qList = item.split(';');
|
|
29
|
-
|
|
30
25
|
if (qList.length > 1) {
|
|
31
26
|
const [accept, q] = qList;
|
|
32
27
|
const [, query] = q.split('=');
|
|
@@ -34,7 +29,6 @@ function getByQualityPriorityValue(headerValue) {
|
|
|
34
29
|
} else {
|
|
35
30
|
acc.push([qList[0], 0]);
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
return acc;
|
|
39
33
|
}, []).sort(function (a, b) {
|
|
40
34
|
return b[1] - a[1];
|
|
@@ -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":"
|
|
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":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,yBAAyB,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,EAAE,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,EAAE,CAAQ,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"}
|
|
@@ -15,37 +15,30 @@ Object.defineProperty(exports, "validatePublishSingleVersion", {
|
|
|
15
15
|
return _publishManifest.validatePublishSingleVersion;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
|
|
19
18
|
var _assert = _interopRequireDefault(require("assert"));
|
|
20
|
-
|
|
21
19
|
var _constants = require("./constants");
|
|
22
|
-
|
|
23
20
|
var _publishManifest = require("./schemes/publish-manifest");
|
|
24
|
-
|
|
25
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
-
|
|
27
22
|
function isPackageNameScoped(name) {
|
|
28
23
|
return name.startsWith('@');
|
|
29
24
|
}
|
|
25
|
+
|
|
30
26
|
/**
|
|
31
27
|
* From normalize-package-data/lib/fixer.js
|
|
32
28
|
* @param {*} name the package name
|
|
33
29
|
* @return {Boolean} whether is valid or not
|
|
34
30
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
31
|
function validateName(name) {
|
|
38
32
|
if (typeof name !== 'string') {
|
|
39
33
|
return false;
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
let normalizedName = name.toLowerCase();
|
|
43
36
|
const isScoped = isPackageNameScoped(name);
|
|
44
37
|
const scopedName = name.split('/', 2)[1];
|
|
45
|
-
|
|
46
38
|
if (isScoped && typeof scopedName !== 'undefined') {
|
|
47
39
|
normalizedName = scopedName.toLowerCase();
|
|
48
40
|
}
|
|
41
|
+
|
|
49
42
|
/**
|
|
50
43
|
* Some context about the first regex
|
|
51
44
|
* - npm used to have a different tarball naming system.
|
|
@@ -57,28 +50,25 @@ function validateName(name) {
|
|
|
57
50
|
*
|
|
58
51
|
* more info here: https://github.com/rlidwka/sinopia/issues/75
|
|
59
52
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return !(!normalizedName.match(/^[-a-zA-Z0-9_.!~*'()@]+$/) || normalizedName.startsWith('.') || // ".bin", etc.
|
|
53
|
+
return !(!normalizedName.match(/^[-a-zA-Z0-9_.!~*'()@]+$/) || normalizedName.startsWith('.') ||
|
|
54
|
+
// ".bin", etc.
|
|
63
55
|
['node_modules', '__proto__', 'favicon.ico'].includes(normalizedName));
|
|
64
56
|
}
|
|
57
|
+
|
|
65
58
|
/**
|
|
66
59
|
* Validate a package.
|
|
67
60
|
* @return {Boolean} whether the package is valid or not
|
|
68
61
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
62
|
function validatePackage(name) {
|
|
72
63
|
const nameList = name.split('/', 2);
|
|
73
|
-
|
|
74
64
|
if (nameList.length === 1) {
|
|
75
65
|
// normal package
|
|
76
66
|
return validateName(nameList[0]);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
67
|
+
}
|
|
68
|
+
// scoped package
|
|
80
69
|
return nameList[0][0] === '@' && validateName(nameList[0].slice(1)) && validateName(nameList[1]);
|
|
81
70
|
}
|
|
71
|
+
|
|
82
72
|
/**
|
|
83
73
|
* Validate the package metadata, add additional properties whether are missing within
|
|
84
74
|
* the metadata properties.
|
|
@@ -87,44 +77,36 @@ function validatePackage(name) {
|
|
|
87
77
|
* @return {Object} the object with additional properties as dist-tags ad versions
|
|
88
78
|
* FUTURE: rename to normalizeMetadata
|
|
89
79
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
80
|
function normalizeMetadata(manifest, name) {
|
|
93
81
|
_assert.default.strictEqual(manifest.name, name);
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
const _manifest = {
|
|
83
|
+
...manifest
|
|
96
84
|
};
|
|
97
|
-
|
|
98
85
|
if (!isObject(manifest[_constants.DIST_TAGS])) {
|
|
99
86
|
_manifest[_constants.DIST_TAGS] = {};
|
|
100
|
-
}
|
|
101
|
-
|
|
87
|
+
}
|
|
102
88
|
|
|
89
|
+
// This may not be nee dit
|
|
103
90
|
if (!isObject(manifest['versions'])) {
|
|
104
91
|
_manifest['versions'] = {};
|
|
105
92
|
}
|
|
106
|
-
|
|
107
93
|
if (!isObject(manifest['time'])) {
|
|
108
94
|
_manifest['time'] = {};
|
|
109
95
|
}
|
|
110
|
-
|
|
111
96
|
return _manifest;
|
|
112
97
|
}
|
|
98
|
+
|
|
113
99
|
/**
|
|
114
100
|
* Check whether an element is an Object
|
|
115
101
|
* @param {*} obj the element
|
|
116
102
|
* @return {Boolean}
|
|
117
103
|
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
104
|
function isObject(obj) {
|
|
121
105
|
if (obj === null || typeof obj === 'undefined' || typeof obj === 'string') {
|
|
122
106
|
return false;
|
|
123
107
|
}
|
|
124
|
-
|
|
125
108
|
return (typeof obj === 'object' || typeof obj.prototype === 'undefined') && Array.isArray(obj) === false;
|
|
126
109
|
}
|
|
127
|
-
|
|
128
110
|
function validatePassword(password, validation = _constants.DEFAULT_PASSWORD_VALIDATION) {
|
|
129
111
|
return typeof password === 'string' && validation instanceof RegExp ? password.match(validation) !== null : false;
|
|
130
112
|
}
|
|
@@ -1 +1 @@
|
|
|
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","validatePassword","password","validation","DEFAULT_PASSWORD_VALIDATION","RegExp"],"sources":["../src/validation-utils.ts"],"sourcesContent":["import assert from 'assert';\n\nimport { Manifest } from '@verdaccio/types';\n\nimport { DEFAULT_PASSWORD_VALIDATION, 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\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"],"mappings":"
|
|
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","validatePassword","password","validation","DEFAULT_PASSWORD_VALIDATION","RegExp"],"sources":["../src/validation-utils.ts"],"sourcesContent":["import assert from 'assert';\n\nimport { Manifest } from '@verdaccio/types';\n\nimport { DEFAULT_PASSWORD_VALIDATION, 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\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"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAIA;AAEA;AAA0E;AAEnE,SAASA,mBAAmB,CAACC,IAAY,EAAW;EACzD,OAAOA,IAAI,CAACC,UAAU,CAAC,GAAG,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAY,CAACF,IAAY,EAAW;EAClD,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAO,KAAK;EACd;EAEA,IAAIG,cAAsB,GAAGH,IAAI,CAACI,WAAW,EAAE;EAE/C,MAAMC,QAAiB,GAAGN,mBAAmB,CAACC,IAAI,CAAC;EACnD,MAAMM,UAAU,GAAGN,IAAI,CAACO,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;EAExC,IAAIF,QAAQ,IAAI,OAAOC,UAAU,KAAK,WAAW,EAAE;IACjDH,cAAc,GAAGG,UAAU,CAACF,WAAW,EAAE;EAC3C;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAO,EACL,CAACD,cAAc,CAACK,KAAK,CAAC,0BAA0B,CAAC,IACjDL,cAAc,CAACF,UAAU,CAAC,GAAG,CAAC;EAAI;EAClC,CAAC,cAAc,EAAE,WAAW,EAAE,aAAa,CAAC,CAACQ,QAAQ,CAACN,cAAc,CAAC,CACtE;AACH;;AAEA;AACA;AACA;AACA;AACO,SAASO,eAAe,CAACV,IAAY,EAAW;EACrD,MAAMW,QAAQ,GAAGX,IAAI,CAACO,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;EACnC,IAAII,QAAQ,CAACC,MAAM,KAAK,CAAC,EAAE;IACzB;IACA,OAAOV,YAAY,CAACS,QAAQ,CAAC,CAAC,CAAC,CAAC;EAClC;EACA;EACA,OAAOA,QA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ACT,OAAO,OAAOF,QAAQ,KAAK,QAAQ,IAAIC,UAAU,YAAYE,MAAM,GAC/DH,QAAQ,CAAClB,KAAK,CAACmB,UAAU,CAAC,KAAK,IAAI,GACnC,KAAK;AACX"}
|
package/build/warning-utils.js
CHANGED
|
@@ -5,17 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Codes = void 0;
|
|
7
7
|
exports.emit = emit;
|
|
8
|
-
|
|
9
8
|
var _processWarning = _interopRequireDefault(require("process-warning"));
|
|
10
|
-
|
|
11
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
10
|
const warningInstance = (0, _processWarning.default)();
|
|
14
11
|
const verdaccioWarning = 'VerdaccioWarning';
|
|
15
12
|
const verdaccioDeprecation = 'VerdaccioDeprecation';
|
|
16
13
|
let Codes;
|
|
17
14
|
exports.Codes = Codes;
|
|
18
|
-
|
|
19
15
|
(function (Codes) {
|
|
20
16
|
Codes["VERWAR001"] = "VERWAR001";
|
|
21
17
|
Codes["VERWAR002"] = "VERWAR002";
|
|
@@ -23,7 +19,6 @@ exports.Codes = Codes;
|
|
|
23
19
|
Codes["VERWAR004"] = "VERWAR004";
|
|
24
20
|
Codes["VERDEP003"] = "VERDEP003";
|
|
25
21
|
})(Codes || (exports.Codes = Codes = {}));
|
|
26
|
-
|
|
27
22
|
warningInstance.create(verdaccioWarning, Codes.VERWAR002, `The property config "logs" property is longer supported, rename to "log" and use object instead`);
|
|
28
23
|
warningInstance.create(verdaccioWarning, Codes.VERWAR001, `Verdaccio doesn't need superuser privileges. don't run it under root`);
|
|
29
24
|
warningInstance.create(verdaccioWarning, Codes.VERWAR003, 'rotating-file type is not longer supported, consider use [logrotate] instead');
|
|
@@ -31,7 +26,6 @@ warningInstance.create(verdaccioWarning, Codes.VERWAR004, `invalid address - %s,
|
|
|
31
26
|
host:port (e.g. "localhost:4873") or full url '(e.g. "http://localhost:4873/")
|
|
32
27
|
https://verdaccio.org/docs/en/configuration#listen-port`);
|
|
33
28
|
warningInstance.create(verdaccioDeprecation, Codes.VERDEP003, 'multiple addresses will be deprecated in the next major, only use one');
|
|
34
|
-
|
|
35
29
|
function emit(code, a, b, c) {
|
|
36
30
|
warningInstance.emit(code, a, b, c);
|
|
37
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warning-utils.js","names":["warningInstance","warning","verdaccioWarning","verdaccioDeprecation","Codes","create","VERWAR002","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 VERWAR002 = 'VERWAR002',\n VERWAR003 = 'VERWAR003',\n VERWAR004 = 'VERWAR004',\n // deprecation warnings\n VERDEP003 = 'VERDEP003',\n}\n\nwarningInstance.create(\n verdaccioWarning,\n Codes.VERWAR002,\n `The property config \"logs\" property is longer supported, rename to \"log\" and use object instead`\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: string, a?: string, b?: string, c?: string) {\n warningInstance.emit(code, a, b, c);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"warning-utils.js","names":["warningInstance","warning","verdaccioWarning","verdaccioDeprecation","Codes","create","VERWAR002","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 VERWAR002 = 'VERWAR002',\n VERWAR003 = 'VERWAR003',\n VERWAR004 = 'VERWAR004',\n // deprecation warnings\n VERDEP003 = 'VERDEP003',\n}\n\nwarningInstance.create(\n verdaccioWarning,\n Codes.VERWAR002,\n `The property config \"logs\" property is longer supported, rename to \"log\" and use object instead`\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: string, a?: string, b?: string, c?: string) {\n warningInstance.emit(code, a, b, c);\n}\n"],"mappings":";;;;;;;AAAA;AAAsC;AAEtC,MAAMA,eAAe,GAAG,IAAAC,uBAAO,GAAE;AACjC,MAAMC,gBAAgB,GAAG,kBAAkB;AAC3C,MAAMC,oBAAoB,GAAG,sBAAsB;AAAC,IAExCC,KAAK;AAAA;AAAA,WAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;AAAA,GAALA,KAAK,qBAALA,KAAK;AASjBJ,eAAe,CAACK,MAAM,CACpBH,gBAAgB,EAChBE,KAAK,CAACE,SAAS,EACd,iGAAgG,CAClG;AAEDN,eAAe,CAACK,MAAM,CACpBH,gBAAgB,EAChBE,KAAK,CAACG,SAAS,EACd,sEAAqE,CACvE;AAEDP,eAAe,CAACK,MAAM,CACpBH,gBAAgB,EAChBE,KAAK,CAACI,SAAS,EACf,8EAA8E,CAC/E;AAEDR,eAAe,CAACK,MAAM,CACpBH,gBAAgB,EAChBE,KAAK,CAACK,SAAS,EACd;AACH;AACA,wDAAwD,CACvD;AAEDT,eAAe,CAACK,MAAM,CACpBF,oBAAoB,EACpBC,KAAK,CAACM,SAAS,EACf,uEAAuE,CACxE;AAEM,SAASC,IAAI,CAACC,IAAY,EAAEC,CAAU,EAAEC,CAAU,EAAEC,CAAU,EAAE;EACrEf,eAAe,CAACW,IAAI,CAACC,IAAI,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,CAAC;AACrC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/core",
|
|
3
|
-
"version": "6.0.0-6-next.
|
|
3
|
+
"version": "6.0.0-6-next.52",
|
|
4
4
|
"description": "core utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"private",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"http-errors": "1.8.1",
|
|
38
38
|
"http-status-codes": "2.2.0",
|
|
39
39
|
"semver": "7.3.8",
|
|
40
|
-
"ajv": "8.11.
|
|
40
|
+
"ajv": "8.11.2",
|
|
41
41
|
"process-warning": "1.0.0",
|
|
42
|
-
"core-js": "3.
|
|
42
|
+
"core-js": "3.26.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"lodash": "4.17.21",
|
|
46
|
-
"typedoc": "0.23.
|
|
46
|
+
"typedoc": "0.23.21",
|
|
47
47
|
"typedoc-plugin-missing-exports": "latest",
|
|
48
48
|
"@verdaccio/types": "11.0.0-6-next.17"
|
|
49
49
|
},
|
package/src/constants.ts
CHANGED
|
@@ -2,7 +2,7 @@ import httpCodes from 'http-status-codes';
|
|
|
2
2
|
|
|
3
3
|
export const DEFAULT_PASSWORD_VALIDATION = /.{3}$/;
|
|
4
4
|
export const TIME_EXPIRATION_24H = '24h';
|
|
5
|
-
export const
|
|
5
|
+
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';
|
|
@@ -35,6 +35,7 @@ export const HEADERS = {
|
|
|
35
35
|
TEXT_HTML_UTF8: 'text/html; charset=utf-8',
|
|
36
36
|
TEXT_HTML: 'text/html',
|
|
37
37
|
AUTHORIZATION: 'authorization',
|
|
38
|
+
CACHE_CONTROL: 'Cache-Control',
|
|
38
39
|
// only set with proxy that setup HTTPS
|
|
39
40
|
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto
|
|
40
41
|
FORWARDED_PROTO: 'X-Forwarded-Proto',
|