@verdaccio/core 6.0.0-6-next.1 → 6.0.0-6-next.2

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 CHANGED
@@ -1,25 +1,38 @@
1
1
  # @verdaccio/core
2
2
 
3
+ ## 6.0.0-6-next.2
4
+
5
+ ### Major Changes
6
+
7
+ - 794af76c: Remove Node 12 support
8
+
9
+ - We need move to the new `undici` and does not support Node.js 12
10
+
11
+ ### Minor Changes
12
+
13
+ - 154b2ecd: refactor: remove @verdaccio/commons-api in favor @verdaccio/core and remove duplications
14
+
3
15
  ## 6.0.0-6-next.1
16
+
4
17
  ### Major Changes
5
18
 
6
19
  - 459b6fa7: refactor: search v1 endpoint and local-database
7
-
20
+
8
21
  - refactor search `api v1` endpoint, improve performance
9
22
  - remove usage of `async` dependency https://github.com/verdaccio/verdaccio/issues/1225
10
23
  - refactor method storage class
11
24
  - create new module `core` to reduce the ammount of modules with utilities
12
25
  - use `undici` instead `node-fetch`
13
26
  - use `fastify` instead `express` for functional test
14
-
27
+
15
28
  ### Breaking changes
16
-
29
+
17
30
  - plugin storage API changes
18
31
  - remove old search endpoint (return 404)
19
32
  - filter local private packages at plugin level
20
-
33
+
21
34
  The storage api changes for methods `get`, `add`, `remove` as promise base. The `search` methods also changes and recieves a `query` object that contains all query params from the client.
22
-
35
+
23
36
  ```ts
24
37
  export interface IPluginStorage<T> extends IPlugin {
25
38
  add(name: string): Promise<void>;
@@ -41,3 +41,38 @@ export declare const HEADERS: {
41
41
  WWW_AUTH: string;
42
42
  GZIP: string;
43
43
  };
44
+ export declare const HTTP_STATUS: {
45
+ OK: number;
46
+ CREATED: number;
47
+ MULTIPLE_CHOICES: number;
48
+ NOT_MODIFIED: number;
49
+ BAD_REQUEST: number;
50
+ UNAUTHORIZED: number;
51
+ FORBIDDEN: number;
52
+ NOT_FOUND: number;
53
+ CONFLICT: number;
54
+ NOT_IMPLEMENTED: number;
55
+ UNSUPPORTED_MEDIA: number;
56
+ BAD_DATA: number;
57
+ INTERNAL_ERROR: number;
58
+ SERVICE_UNAVAILABLE: number;
59
+ LOOP_DETECTED: number;
60
+ };
61
+ export declare const ERROR_CODE: {
62
+ token_required: string;
63
+ };
64
+ export declare const API_MESSAGE: {
65
+ PKG_CREATED: string;
66
+ PKG_CHANGED: string;
67
+ PKG_REMOVED: string;
68
+ PKG_PUBLISHED: string;
69
+ TARBALL_UPLOADED: string;
70
+ TARBALL_REMOVED: string;
71
+ TAG_UPDATED: string;
72
+ TAG_REMOVED: string;
73
+ TAG_ADDED: string;
74
+ LOGGED_OUT: string;
75
+ };
76
+ export declare const LOG_STATUS_MESSAGE = "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'";
77
+ export declare const LOG_VERDACCIO_ERROR: string;
78
+ export declare const LOG_VERDACCIO_BYTES: string;
@@ -3,7 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.HEADERS = exports.TOKEN_BEARER = exports.TOKEN_BASIC = exports.CHARACTER_ENCODING = exports.HEADER_TYPE = exports.DEFAULT_USER = exports.USERS = exports.LATEST = exports.DIST_TAGS = exports.TIME_EXPIRATION_7D = exports.TIME_EXPIRATION_24H = exports.DEFAULT_MIN_LIMIT_PASSWORD = void 0;
6
+ exports.LOG_VERDACCIO_BYTES = exports.LOG_VERDACCIO_ERROR = exports.LOG_STATUS_MESSAGE = exports.API_MESSAGE = exports.ERROR_CODE = exports.HTTP_STATUS = exports.HEADERS = exports.TOKEN_BEARER = exports.TOKEN_BASIC = exports.CHARACTER_ENCODING = exports.HEADER_TYPE = exports.DEFAULT_USER = exports.USERS = exports.LATEST = exports.DIST_TAGS = exports.TIME_EXPIRATION_7D = exports.TIME_EXPIRATION_24H = exports.DEFAULT_MIN_LIMIT_PASSWORD = void 0;
7
+
8
+ var _httpStatusCodes = _interopRequireDefault(require("http-status-codes"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
7
12
  const DEFAULT_MIN_LIMIT_PASSWORD = 3;
8
13
  exports.DEFAULT_MIN_LIMIT_PASSWORD = DEFAULT_MIN_LIMIT_PASSWORD;
9
14
  const TIME_EXPIRATION_24H = '24h';
@@ -61,4 +66,45 @@ const HEADERS = {
61
66
  GZIP: 'gzip'
62
67
  };
63
68
  exports.HEADERS = HEADERS;
69
+ const HTTP_STATUS = {
70
+ OK: _httpStatusCodes.default.OK,
71
+ CREATED: _httpStatusCodes.default.CREATED,
72
+ MULTIPLE_CHOICES: _httpStatusCodes.default.MULTIPLE_CHOICES,
73
+ NOT_MODIFIED: _httpStatusCodes.default.NOT_MODIFIED,
74
+ BAD_REQUEST: _httpStatusCodes.default.BAD_REQUEST,
75
+ UNAUTHORIZED: _httpStatusCodes.default.UNAUTHORIZED,
76
+ FORBIDDEN: _httpStatusCodes.default.FORBIDDEN,
77
+ NOT_FOUND: _httpStatusCodes.default.NOT_FOUND,
78
+ CONFLICT: _httpStatusCodes.default.CONFLICT,
79
+ NOT_IMPLEMENTED: _httpStatusCodes.default.NOT_IMPLEMENTED,
80
+ UNSUPPORTED_MEDIA: _httpStatusCodes.default.UNSUPPORTED_MEDIA_TYPE,
81
+ BAD_DATA: _httpStatusCodes.default.UNPROCESSABLE_ENTITY,
82
+ INTERNAL_ERROR: _httpStatusCodes.default.INTERNAL_SERVER_ERROR,
83
+ SERVICE_UNAVAILABLE: _httpStatusCodes.default.SERVICE_UNAVAILABLE,
84
+ LOOP_DETECTED: 508
85
+ };
86
+ exports.HTTP_STATUS = HTTP_STATUS;
87
+ const ERROR_CODE = {
88
+ token_required: 'token is required'
89
+ };
90
+ exports.ERROR_CODE = ERROR_CODE;
91
+ const API_MESSAGE = {
92
+ PKG_CREATED: 'created new package',
93
+ PKG_CHANGED: 'package changed',
94
+ PKG_REMOVED: 'package removed',
95
+ PKG_PUBLISHED: 'package published',
96
+ TARBALL_UPLOADED: 'tarball uploaded successfully',
97
+ TARBALL_REMOVED: 'tarball removed',
98
+ TAG_UPDATED: 'tags updated',
99
+ TAG_REMOVED: 'tag removed',
100
+ TAG_ADDED: 'package tagged',
101
+ LOGGED_OUT: 'Logged out'
102
+ };
103
+ exports.API_MESSAGE = API_MESSAGE;
104
+ const LOG_STATUS_MESSAGE = "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'";
105
+ exports.LOG_STATUS_MESSAGE = LOG_STATUS_MESSAGE;
106
+ const LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;
107
+ exports.LOG_VERDACCIO_ERROR = LOG_VERDACCIO_ERROR;
108
+ const LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;
109
+ exports.LOG_VERDACCIO_BYTES = LOG_VERDACCIO_BYTES;
64
110
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/constants.ts"],"names":["DEFAULT_MIN_LIMIT_PASSWORD","TIME_EXPIRATION_24H","TIME_EXPIRATION_7D","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","FORWARDED_PROTO","FORWARDED_FOR","FRAMES_OPTIONS","CSP","CTO","XSS","ETAG","JSON_CHARSET","OCTET_STREAM","TEXT_CHARSET","WWW_AUTH","GZIP"],"mappings":";;;;;;AAAO,MAAMA,0BAA0B,GAAG,CAAnC;;AACA,MAAMC,mBAAmB,GAAG,KAA5B;;AACA,MAAMC,kBAAkB,GAAG,IAA3B;;AACA,MAAMC,SAAS,GAAG,WAAlB;;AACA,MAAMC,MAAM,GAAG,QAAf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DEFAULT_MIN_LIMIT_PASSWORD = 3;\nexport const TIME_EXPIRATION_24H = '24h';\nexport const TIME_EXPIRATION_7D = '7d';\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\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 // 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 ETAG: 'ETag',\n JSON_CHARSET: 'application/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"],"file":"constants.js"}
1
+ {"version":3,"sources":["../src/constants.ts"],"names":["DEFAULT_MIN_LIMIT_PASSWORD","TIME_EXPIRATION_24H","TIME_EXPIRATION_7D","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","FORWARDED_PROTO","FORWARDED_FOR","FRAMES_OPTIONS","CSP","CTO","XSS","ETAG","JSON_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"],"mappings":";;;;;;;AAAA;;;;AAEO,MAAMA,0BAA0B,GAAG,CAAnC;;AACA,MAAMC,mBAAmB,GAAG,KAA5B;;AACA,MAAMC,kBAAkB,GAAG,IAA3B;;AACA,MAAMC,SAAS,GAAG,WAAlB;;AACA,MAAMC,MAAM,GAAG,QAAf;;AACA,MAAMC,KAAK,GAAG,OAAd;;AACA,MAAMC,YAAY,GAAG,WAArB;;AAEA,MAAMC,WAAW,GAAG;AACzBC,EAAAA,gBAAgB,EAAE,kBADO;AAEzBC,EAAAA,YAAY,EAAE,cAFW;AAGzBC,EAAAA,cAAc,EAAE,gBAHS;AAI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EAAAA,WAAW,EAAEJ,yBAAUI,WALE;AAMzBC,EAAAA,YAAY,EAAEL,yBAAUK,YANC;AAOzBC,EAAAA,SAAS,EAAEN,yBAAUM,SAPI;AAQzBC,EAAAA,SAAS,EAAEP,yBAAUO,SARI;AASzBC,EAAAA,QAAQ,EAAER,yBAAUQ,QATK;AAUzBC,EAAAA,eAAe,EAAET,yBAAUS,eAVF;AAWzBC,EAAAA,iBAAiB,EAAEV,yBAAUW,sBAXJ;AAYzBC,EAAAA,QAAQ,EAAEZ,yBAAUa,oBAZK;AAazBC,EAAAA,cAAc,EAAEd,yBAAUe,qBAbD;AAczBC,EAAAA,mBAAmB,EAAEhB,yBAAUgB,mBAdN;AAezBC,EAAAA,aAAa,EAAE;AAfU,CAApB;;AAkBA,MAAMC,UAAU,GAAG;AACxBC,EAAAA,cAAc,EAAE;AADQ,CAAnB;;AAIA,MAAMC,WAAW,GAAG;AACzBC,EAAAA,WAAW,EAAE,qBADY;AAEzBC,EAAAA,WAAW,EAAE,iBAFY;AAGzBC,EAAAA,WAAW,EAAE,iBAHY;AAIzBC,EAAAA,aAAa,EAAE,mBAJU;AAKzBC,EAAAA,gBAAgB,EAAE,+BALO;AAMzBC,EAAAA,eAAe,EAAE,iBANQ;AAOzBC,EAAAA,WAAW,EAAE,cAPY;AAQzBC,EAAAA,WAAW,EAAE,aARY;AASzBC,EAAAA,SAAS,EAAE,gBATc;AAUzBC,EAAAA,UAAU,EAAE;AAVa,CAApB;;AAaA,MAAMC,kBAAkB,GAC7B,gFADK;;AAEA,MAAMC,mBAAmB,GAAI,GAAED,kBAAmB,oBAAlD;;AACA,MAAME,mBAAmB,GAAI,GAAEF,kBAAmB,mCAAlD","sourcesContent":["import httpCodes from 'http-status-codes';\n\nexport const DEFAULT_MIN_LIMIT_PASSWORD = 3;\nexport const TIME_EXPIRATION_24H = '24h';\nexport const TIME_EXPIRATION_7D = '7d';\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\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 // 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 ETAG: 'ETag',\n JSON_CHARSET: 'application/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 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"],"file":"constants.js"}
@@ -1,42 +1,4 @@
1
1
  import { HttpError } from 'http-errors';
2
- export declare const HTTP_STATUS: {
3
- OK: number;
4
- CREATED: number;
5
- MULTIPLE_CHOICES: number;
6
- NOT_MODIFIED: number;
7
- BAD_REQUEST: number;
8
- UNAUTHORIZED: number;
9
- FORBIDDEN: number;
10
- NOT_FOUND: number;
11
- CONFLICT: number;
12
- NOT_IMPLEMENTED: number;
13
- UNSUPPORTED_MEDIA: number;
14
- BAD_DATA: number;
15
- INTERNAL_ERROR: number;
16
- SERVICE_UNAVAILABLE: number;
17
- LOOP_DETECTED: number;
18
- };
19
- export declare const ERROR_CODE: {
20
- token_required: string;
21
- };
22
- export declare const API_MESSAGE: {
23
- PKG_CREATED: string;
24
- PKG_CHANGED: string;
25
- PKG_REMOVED: string;
26
- PKG_PUBLISHED: string;
27
- TARBALL_UPLOADED: string;
28
- TARBALL_REMOVED: string;
29
- TAG_UPDATED: string;
30
- TAG_REMOVED: string;
31
- TAG_ADDED: string;
32
- LOGGED_OUT: string;
33
- };
34
- export declare const SUPPORT_ERRORS: {
35
- PLUGIN_MISSING_INTERFACE: string;
36
- TFA_DISABLED: string;
37
- STORAGE_NOT_IMPLEMENT: string;
38
- PARAMETERS_NOT_VALID: string;
39
- };
40
2
  export declare const API_ERROR: {
41
3
  PASSWORD_SHORT: (passLength?: number) => string;
42
4
  MUST_BE_LOGGED: string;
@@ -72,6 +34,12 @@ export declare const API_ERROR: {
72
34
  USERNAME_PASSWORD_REQUIRED: string;
73
35
  USERNAME_ALREADY_REGISTERED: string;
74
36
  };
37
+ export declare const SUPPORT_ERRORS: {
38
+ PLUGIN_MISSING_INTERFACE: string;
39
+ TFA_DISABLED: string;
40
+ STORAGE_NOT_IMPLEMENT: string;
41
+ PARAMETERS_NOT_VALID: string;
42
+ };
75
43
  export declare const APP_ERROR: {
76
44
  CONFIG_NOT_VALID: string;
77
45
  PROFILE_ERROR: string;
@@ -89,6 +57,3 @@ export declare function getForbidden(message?: string): VerdaccioError;
89
57
  export declare function getServiceUnavailable(message?: string): VerdaccioError;
90
58
  export declare function getNotFound(customMessage?: string): VerdaccioError;
91
59
  export declare function getCode(statusCode: number, customMessage: string): VerdaccioError;
92
- export declare const LOG_STATUS_MESSAGE = "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'";
93
- export declare const LOG_VERDACCIO_ERROR: string;
94
- export declare const LOG_VERDACCIO_BYTES: string;
@@ -12,58 +12,14 @@ exports.getForbidden = getForbidden;
12
12
  exports.getServiceUnavailable = getServiceUnavailable;
13
13
  exports.getNotFound = getNotFound;
14
14
  exports.getCode = getCode;
15
- exports.LOG_VERDACCIO_BYTES = exports.LOG_VERDACCIO_ERROR = exports.LOG_STATUS_MESSAGE = exports.APP_ERROR = exports.API_ERROR = exports.SUPPORT_ERRORS = exports.API_MESSAGE = exports.ERROR_CODE = exports.HTTP_STATUS = void 0;
15
+ exports.APP_ERROR = exports.SUPPORT_ERRORS = exports.API_ERROR = void 0;
16
16
 
17
17
  var _httpErrors = _interopRequireDefault(require("http-errors"));
18
18
 
19
- var _httpStatusCodes = _interopRequireDefault(require("http-status-codes"));
20
-
21
19
  var _constants = require("./constants");
22
20
 
23
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
22
 
25
- const HTTP_STATUS = {
26
- OK: _httpStatusCodes.default.OK,
27
- CREATED: _httpStatusCodes.default.CREATED,
28
- MULTIPLE_CHOICES: _httpStatusCodes.default.MULTIPLE_CHOICES,
29
- NOT_MODIFIED: _httpStatusCodes.default.NOT_MODIFIED,
30
- BAD_REQUEST: _httpStatusCodes.default.BAD_REQUEST,
31
- UNAUTHORIZED: _httpStatusCodes.default.UNAUTHORIZED,
32
- FORBIDDEN: _httpStatusCodes.default.FORBIDDEN,
33
- NOT_FOUND: _httpStatusCodes.default.NOT_FOUND,
34
- CONFLICT: _httpStatusCodes.default.CONFLICT,
35
- NOT_IMPLEMENTED: _httpStatusCodes.default.NOT_IMPLEMENTED,
36
- UNSUPPORTED_MEDIA: _httpStatusCodes.default.UNSUPPORTED_MEDIA_TYPE,
37
- BAD_DATA: _httpStatusCodes.default.UNPROCESSABLE_ENTITY,
38
- INTERNAL_ERROR: _httpStatusCodes.default.INTERNAL_SERVER_ERROR,
39
- SERVICE_UNAVAILABLE: _httpStatusCodes.default.SERVICE_UNAVAILABLE,
40
- LOOP_DETECTED: 508
41
- };
42
- exports.HTTP_STATUS = HTTP_STATUS;
43
- const ERROR_CODE = {
44
- token_required: 'token is required'
45
- };
46
- exports.ERROR_CODE = ERROR_CODE;
47
- const API_MESSAGE = {
48
- PKG_CREATED: 'created new package',
49
- PKG_CHANGED: 'package changed',
50
- PKG_REMOVED: 'package removed',
51
- PKG_PUBLISHED: 'package published',
52
- TARBALL_UPLOADED: 'tarball uploaded successfully',
53
- TARBALL_REMOVED: 'tarball removed',
54
- TAG_UPDATED: 'tags updated',
55
- TAG_REMOVED: 'tag removed',
56
- TAG_ADDED: 'package tagged',
57
- LOGGED_OUT: 'Logged out'
58
- };
59
- exports.API_MESSAGE = API_MESSAGE;
60
- const SUPPORT_ERRORS = {
61
- PLUGIN_MISSING_INTERFACE: 'the plugin does not provide implementation of the requested feature',
62
- TFA_DISABLED: 'the two-factor authentication is not yet supported',
63
- STORAGE_NOT_IMPLEMENT: 'the storage does not support token saving',
64
- PARAMETERS_NOT_VALID: 'the parameters are not valid'
65
- };
66
- exports.SUPPORT_ERRORS = SUPPORT_ERRORS;
67
23
  const API_ERROR = {
68
24
  PASSWORD_SHORT: (passLength = _constants.DEFAULT_MIN_LIMIT_PASSWORD) => `The provided password is too short. Please pick a password longer than ` + `${passLength} characters.`,
69
25
  MUST_BE_LOGGED: 'You must be logged in to publish packages.',
@@ -100,6 +56,13 @@ const API_ERROR = {
100
56
  USERNAME_ALREADY_REGISTERED: 'username is already registered'
101
57
  };
102
58
  exports.API_ERROR = API_ERROR;
59
+ const SUPPORT_ERRORS = {
60
+ PLUGIN_MISSING_INTERFACE: 'the plugin does not provide implementation of the requested feature',
61
+ TFA_DISABLED: 'the two-factor authentication is not yet supported',
62
+ STORAGE_NOT_IMPLEMENT: 'the storage does not support token saving',
63
+ PARAMETERS_NOT_VALID: 'the parameters are not valid'
64
+ };
65
+ exports.SUPPORT_ERRORS = SUPPORT_ERRORS;
103
66
  const APP_ERROR = {
104
67
  CONFIG_NOT_VALID: 'CONFIG: it does not look like a valid config file',
105
68
  PROFILE_ERROR: 'profile unexpected error',
@@ -114,45 +77,38 @@ function getError(code, message) {
114
77
  }
115
78
 
116
79
  function getConflict(message = API_ERROR.PACKAGE_EXIST) {
117
- return getError(HTTP_STATUS.CONFLICT, message);
80
+ return getError(_constants.HTTP_STATUS.CONFLICT, message);
118
81
  }
119
82
 
120
83
  function getBadData(customMessage) {
121
- return getError(HTTP_STATUS.BAD_DATA, customMessage || API_ERROR.BAD_DATA);
84
+ return getError(_constants.HTTP_STATUS.BAD_DATA, customMessage || API_ERROR.BAD_DATA);
122
85
  }
123
86
 
124
87
  function getBadRequest(customMessage) {
125
- return getError(HTTP_STATUS.BAD_REQUEST, customMessage);
88
+ return getError(_constants.HTTP_STATUS.BAD_REQUEST, customMessage);
126
89
  }
127
90
 
128
91
  function getInternalError(customMessage) {
129
- return customMessage ? getError(HTTP_STATUS.INTERNAL_ERROR, customMessage) : getError(HTTP_STATUS.INTERNAL_ERROR, API_ERROR.UNKNOWN_ERROR);
92
+ return customMessage ? getError(_constants.HTTP_STATUS.INTERNAL_ERROR, customMessage) : getError(_constants.HTTP_STATUS.INTERNAL_ERROR, API_ERROR.UNKNOWN_ERROR);
130
93
  }
131
94
 
132
95
  function getUnauthorized(message = 'no credentials provided') {
133
- return getError(HTTP_STATUS.UNAUTHORIZED, message);
96
+ return getError(_constants.HTTP_STATUS.UNAUTHORIZED, message);
134
97
  }
135
98
 
136
99
  function getForbidden(message = "can't use this filename") {
137
- return getError(HTTP_STATUS.FORBIDDEN, message);
100
+ return getError(_constants.HTTP_STATUS.FORBIDDEN, message);
138
101
  }
139
102
 
140
103
  function getServiceUnavailable(message = API_ERROR.RESOURCE_UNAVAILABLE) {
141
- return getError(HTTP_STATUS.SERVICE_UNAVAILABLE, message);
104
+ return getError(_constants.HTTP_STATUS.SERVICE_UNAVAILABLE, message);
142
105
  }
143
106
 
144
107
  function getNotFound(customMessage) {
145
- return getError(HTTP_STATUS.NOT_FOUND, customMessage || API_ERROR.NO_PACKAGE);
108
+ return getError(_constants.HTTP_STATUS.NOT_FOUND, customMessage || API_ERROR.NO_PACKAGE);
146
109
  }
147
110
 
148
111
  function getCode(statusCode, customMessage) {
149
112
  return getError(statusCode, customMessage);
150
113
  }
151
-
152
- const LOG_STATUS_MESSAGE = "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'";
153
- exports.LOG_STATUS_MESSAGE = LOG_STATUS_MESSAGE;
154
- const LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;
155
- exports.LOG_VERDACCIO_ERROR = LOG_VERDACCIO_ERROR;
156
- const LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;
157
- exports.LOG_VERDACCIO_BYTES = LOG_VERDACCIO_BYTES;
158
114
  //# sourceMappingURL=error-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/error-utils.ts"],"names":["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","SUPPORT_ERRORS","PLUGIN_MISSING_INTERFACE","TFA_DISABLED","STORAGE_NOT_IMPLEMENT","PARAMETERS_NOT_VALID","API_ERROR","PASSWORD_SHORT","passLength","DEFAULT_MIN_LIMIT_PASSWORD","MUST_BE_LOGGED","PLUGIN_ERROR","CONFIG_BAD_FORMAT","BAD_USERNAME_PASSWORD","NO_PACKAGE","PACKAGE_CANNOT_BE_ADDED","NOT_ALLOWED","NOT_ALLOWED_PUBLISH","UNKNOWN_ERROR","NOT_PACKAGE_UPLINK","UPLINK_OFFLINE_PUBLISH","UPLINK_OFFLINE","CONTENT_MISMATCH","NOT_FILE_UPLINK","MAX_USERS_REACHED","VERSION_NOT_EXIST","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","APP_ERROR","CONFIG_NOT_VALID","PROFILE_ERROR","PASSWORD_VALIDATION","getError","code","message","httpError","getConflict","getBadData","customMessage","getBadRequest","getInternalError","getUnauthorized","getForbidden","getServiceUnavailable","getNotFound","getCode","statusCode","LOG_STATUS_MESSAGE","LOG_VERDACCIO_ERROR","LOG_VERDACCIO_BYTES"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;;;AAEO,MAAMA,WAAW,GAAG;AACzBC,EAAAA,EAAE,EAAEC,yBAAUD,EADW;AAEzBE,EAAAA,OAAO,EAAED,yBAAUC,OAFM;AAGzBC,EAAAA,gBAAgB,EAAEF,yBAAUE,gBAHH;AAIzBC,EAAAA,YAAY,EAAEH,yBAAUG,YAJC;AAKzBC,EAAAA,WAAW,EAAEJ,yBAAUI,WALE;AAMzBC,EAAAA,YAAY,EAAEL,yBAAUK,YANC;AAOzBC,EAAAA,SAAS,EAAEN,yBAAUM,SAPI;AAQzBC,EAAAA,SAAS,EAAEP,yBAAUO,SARI;AASzBC,EAAAA,QAAQ,EAAER,yBAAUQ,QATK;AAUzBC,EAAAA,eAAe,EAAET,yBAAUS,eAVF;AAWzBC,EAAAA,iBAAiB,EAAEV,yBAAUW,sBAXJ;AAYzBC,EAAAA,QAAQ,EAAEZ,yBAAUa,oBAZK;AAazBC,EAAAA,cAAc,EAAEd,yBAAUe,qBAbD;AAczBC,EAAAA,mBAAmB,EAAEhB,yBAAUgB,mBAdN;AAezBC,EAAAA,aAAa,EAAE;AAfU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AmB,mCAAlD","sourcesContent":["import createError, { HttpError } from 'http-errors';\nimport httpCodes from 'http-status-codes';\nimport { DEFAULT_MIN_LIMIT_PASSWORD } from './constants';\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 LOGGED_OUT: 'Logged out',\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 API_ERROR = {\n PASSWORD_SHORT: (passLength = DEFAULT_MIN_LIMIT_PASSWORD): string =>\n `The provided password is too short. Please pick a password longer than ` +\n `${passLength} characters.`,\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 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 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 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\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"],"file":"error-utils.js"}
1
+ {"version":3,"sources":["../src/error-utils.ts"],"names":["API_ERROR","PASSWORD_SHORT","passLength","DEFAULT_MIN_LIMIT_PASSWORD","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","CONTENT_MISMATCH","NOT_FILE_UPLINK","MAX_USERS_REACHED","VERSION_NOT_EXIST","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","getConflict","HTTP_STATUS","CONFLICT","getBadData","customMessage","getBadRequest","BAD_REQUEST","getInternalError","INTERNAL_ERROR","getUnauthorized","UNAUTHORIZED","getForbidden","FORBIDDEN","getServiceUnavailable","SERVICE_UNAVAILABLE","getNotFound","NOT_FOUND","getCode","statusCode"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AACA;;;;AAEO,MAAMA,SAAS,GAAG;AACvBC,EAAAA,cAAc,EAAE,CAACC,UAAU,GAAGC,qCAAd,KACb,yEAAD,GACC,GAAED,UAAW,cAHO;AAIvBE,EAAAA,cAAc,EAAE,4CAJO;AAKvBC,EAAAA,YAAY,EAAE,+BALS;AAMvBC,EAAAA,iBAAiB,EAAE,+BANI;AAOvBC,EAAAA,qBAAqB,EAAE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/C,SAAS,CAACgC,oBADvB,EAEW;AAChB,SAAOa,QAAQ,CAACK,uBAAYa,mBAAb,EAAkChB,OAAlC,CAAf;AACD;;AAEM,SAASiB,WAAT,CAAqBX,aAArB,EAA6D;AAClE,SAAOR,QAAQ,CAACK,uBAAYe,SAAb,EAAwBZ,aAAa,IAAIrD,SAAS,CAACQ,UAAnD,CAAf;AACD;;AAEM,SAAS0D,OAAT,CAAiBC,UAAjB,EAAqCd,aAArC,EAA4E;AACjF,SAAOR,QAAQ,CAACsB,UAAD,EAAad,aAAb,CAAf;AACD","sourcesContent":["import createError, { HttpError } from 'http-errors';\nimport { DEFAULT_MIN_LIMIT_PASSWORD, HTTP_STATUS } from './constants';\n\nexport const API_ERROR = {\n PASSWORD_SHORT: (passLength = DEFAULT_MIN_LIMIT_PASSWORD): string =>\n `The provided password is too short. Please pick a password longer than ` +\n `${passLength} characters.`,\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 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 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"],"file":"error-utils.js"}
package/build/index.d.ts CHANGED
@@ -6,4 +6,6 @@ import * as constants from './constants';
6
6
  import * as pluginUtils from './plugin-utils';
7
7
  import * as fileUtils from './file-utils';
8
8
  import * as pkgUtils from './pkg-utils';
9
+ export { VerdaccioError, API_ERROR, SUPPORT_ERRORS, APP_ERROR } from './error-utils';
10
+ export { TOKEN_BASIC, TOKEN_BEARER, HTTP_STATUS, API_MESSAGE, HEADERS, DIST_TAGS, CHARACTER_ENCODING, HEADER_TYPE, LATEST, DEFAULT_MIN_LIMIT_PASSWORD, DEFAULT_USER, USERS, } from './constants';
9
11
  export { fileUtils, pkgUtils, searchUtils, streamUtils, errorUtils, validatioUtils, constants, pluginUtils, };
package/build/index.js CHANGED
@@ -5,6 +5,102 @@ require("core-js/modules/esnext.weak-map.delete-all.js");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ Object.defineProperty(exports, "VerdaccioError", {
9
+ enumerable: true,
10
+ get: function () {
11
+ return errorUtils.VerdaccioError;
12
+ }
13
+ });
14
+ Object.defineProperty(exports, "API_ERROR", {
15
+ enumerable: true,
16
+ get: function () {
17
+ return errorUtils.API_ERROR;
18
+ }
19
+ });
20
+ Object.defineProperty(exports, "SUPPORT_ERRORS", {
21
+ enumerable: true,
22
+ get: function () {
23
+ return errorUtils.SUPPORT_ERRORS;
24
+ }
25
+ });
26
+ Object.defineProperty(exports, "APP_ERROR", {
27
+ enumerable: true,
28
+ get: function () {
29
+ return errorUtils.APP_ERROR;
30
+ }
31
+ });
32
+ Object.defineProperty(exports, "TOKEN_BASIC", {
33
+ enumerable: true,
34
+ get: function () {
35
+ return constants.TOKEN_BASIC;
36
+ }
37
+ });
38
+ Object.defineProperty(exports, "TOKEN_BEARER", {
39
+ enumerable: true,
40
+ get: function () {
41
+ return constants.TOKEN_BEARER;
42
+ }
43
+ });
44
+ Object.defineProperty(exports, "HTTP_STATUS", {
45
+ enumerable: true,
46
+ get: function () {
47
+ return constants.HTTP_STATUS;
48
+ }
49
+ });
50
+ Object.defineProperty(exports, "API_MESSAGE", {
51
+ enumerable: true,
52
+ get: function () {
53
+ return constants.API_MESSAGE;
54
+ }
55
+ });
56
+ Object.defineProperty(exports, "HEADERS", {
57
+ enumerable: true,
58
+ get: function () {
59
+ return constants.HEADERS;
60
+ }
61
+ });
62
+ Object.defineProperty(exports, "DIST_TAGS", {
63
+ enumerable: true,
64
+ get: function () {
65
+ return constants.DIST_TAGS;
66
+ }
67
+ });
68
+ Object.defineProperty(exports, "CHARACTER_ENCODING", {
69
+ enumerable: true,
70
+ get: function () {
71
+ return constants.CHARACTER_ENCODING;
72
+ }
73
+ });
74
+ Object.defineProperty(exports, "HEADER_TYPE", {
75
+ enumerable: true,
76
+ get: function () {
77
+ return constants.HEADER_TYPE;
78
+ }
79
+ });
80
+ Object.defineProperty(exports, "LATEST", {
81
+ enumerable: true,
82
+ get: function () {
83
+ return constants.LATEST;
84
+ }
85
+ });
86
+ Object.defineProperty(exports, "DEFAULT_MIN_LIMIT_PASSWORD", {
87
+ enumerable: true,
88
+ get: function () {
89
+ return constants.DEFAULT_MIN_LIMIT_PASSWORD;
90
+ }
91
+ });
92
+ Object.defineProperty(exports, "DEFAULT_USER", {
93
+ enumerable: true,
94
+ get: function () {
95
+ return constants.DEFAULT_USER;
96
+ }
97
+ });
98
+ Object.defineProperty(exports, "USERS", {
99
+ enumerable: true,
100
+ get: function () {
101
+ return constants.USERS;
102
+ }
103
+ });
8
104
  exports.pkgUtils = exports.fileUtils = exports.pluginUtils = exports.constants = exports.validatioUtils = exports.errorUtils = exports.streamUtils = exports.searchUtils = void 0;
9
105
 
10
106
  var searchUtils = _interopRequireWildcard(require("./search-utils"));
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA","sourcesContent":["import * as searchUtils from './search-utils';\nimport * as streamUtils from './stream-utils';\nimport * as errorUtils from './error-utils';\nimport * as validatioUtils from './validation-utils';\nimport * as constants from './constants';\nimport * as pluginUtils from './plugin-utils';\nimport * as fileUtils from './file-utils';\nimport * as pkgUtils from './pkg-utils';\n\nexport {\n fileUtils,\n pkgUtils,\n searchUtils,\n streamUtils,\n errorUtils,\n validatioUtils,\n constants,\n pluginUtils,\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA","sourcesContent":["import * as searchUtils from './search-utils';\nimport * as streamUtils from './stream-utils';\nimport * as errorUtils from './error-utils';\nimport * as validatioUtils from './validation-utils';\nimport * as constants from './constants';\nimport * as pluginUtils from './plugin-utils';\nimport * as fileUtils from './file-utils';\nimport * as pkgUtils from './pkg-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_MIN_LIMIT_PASSWORD,\n DEFAULT_USER,\n USERS,\n} from './constants';\n\nexport {\n fileUtils,\n pkgUtils,\n searchUtils,\n streamUtils,\n errorUtils,\n validatioUtils,\n constants,\n pluginUtils,\n};\n"],"file":"index.js"}
@@ -22,6 +22,11 @@ export declare type Score = {
22
22
  final: number;
23
23
  detail: SearchMetrics;
24
24
  };
25
+ export declare type SearchResults = {
26
+ objects: SearchItemPkg[];
27
+ total: number;
28
+ time: string;
29
+ };
25
30
  declare type PublisherMaintainer = {
26
31
  username: string;
27
32
  email: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/search-utils.ts"],"names":["UNSCOPED"],"mappings":";;;;;;AAyDO,MAAMA,QAAQ,GAAG,UAAjB","sourcesContent":["export type SearchMetrics = {\n quality: number;\n popularity: number;\n maintenance: number;\n};\nexport type UnStable = {\n flags?: {\n // if is false is not be included in search results (majority are stable)\n unstable?: boolean;\n };\n};\nexport type SearchItemPkg = {\n name: string;\n scoped?: string;\n path?: string;\n time?: number | Date;\n};\n\nexport type SearchItem = {\n package: SearchItemPkg;\n score: Score;\n} & UnStable;\n\nexport type Score = {\n final: number;\n detail: SearchMetrics;\n};\n\ntype PublisherMaintainer = {\n username: string;\n email: string;\n};\n\nexport type SearchPackageBody = {\n name: string;\n scope: string;\n description: string;\n author: string | PublisherMaintainer;\n version: string;\n keywords: string | string[] | undefined;\n date: string;\n links?: {\n npm: string; // only include placeholder for URL eg: {url}/{packageName}\n homepage?: string;\n repository?: string;\n bugs?: string;\n };\n publisher?: any;\n maintainers?: PublisherMaintainer[];\n};\n\nexport type SearchPackageItem = {\n package: SearchPackageBody;\n score: Score;\n searchScore?: number;\n} & UnStable;\n\nexport const UNSCOPED = 'unscoped';\n\nexport type SearchQuery = {\n text: string;\n size?: number;\n from?: number;\n} & SearchMetrics;\n"],"file":"search-utils.js"}
1
+ {"version":3,"sources":["../src/search-utils.ts"],"names":["UNSCOPED"],"mappings":";;;;;;AA+DO,MAAMA,QAAQ,GAAG,UAAjB","sourcesContent":["export type SearchMetrics = {\n quality: number;\n popularity: number;\n maintenance: number;\n};\nexport type UnStable = {\n flags?: {\n // if is false is not be included in search results (majority are stable)\n unstable?: boolean;\n };\n};\nexport type SearchItemPkg = {\n name: string;\n scoped?: string;\n path?: string;\n time?: number | Date;\n};\n\nexport type SearchItem = {\n package: SearchItemPkg;\n score: Score;\n} & UnStable;\n\nexport type Score = {\n final: number;\n detail: SearchMetrics;\n};\n\nexport type SearchResults = {\n objects: SearchItemPkg[];\n total: number;\n time: string;\n};\n\ntype PublisherMaintainer = {\n username: string;\n email: string;\n};\n\nexport type SearchPackageBody = {\n name: string;\n scope: string;\n description: string;\n author: string | PublisherMaintainer;\n version: string;\n keywords: string | string[] | undefined;\n date: string;\n links?: {\n npm: string; // only include placeholder for URL eg: {url}/{packageName}\n homepage?: string;\n repository?: string;\n bugs?: string;\n };\n publisher?: any;\n maintainers?: PublisherMaintainer[];\n};\n\nexport type SearchPackageItem = {\n package: SearchPackageBody;\n score: Score;\n searchScore?: number;\n} & UnStable;\n\nexport const UNSCOPED = 'unscoped';\n\nexport type SearchQuery = {\n text: string;\n size?: number;\n from?: number;\n} & SearchMetrics;\n"],"file":"search-utils.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/core",
3
- "version": "6.0.0-6-next.1",
3
+ "version": "6.0.0-6-next.2",
4
4
  "description": "core utilities",
5
5
  "keywords": [
6
6
  "private",
@@ -19,7 +19,7 @@
19
19
  "license": "MIT",
20
20
  "homepage": "https://verdaccio.org",
21
21
  "engines": {
22
- "node": ">=12",
22
+ "node": ">=14",
23
23
  "npm": ">=6"
24
24
  },
25
25
  "repository": {
@@ -39,8 +39,7 @@
39
39
  "semver": "7.3.5"
40
40
  },
41
41
  "devDependencies": {
42
- "@verdaccio/types": "11.0.0-6-next.8",
43
- "typedoc": "next"
42
+ "@verdaccio/types": "11.0.0-6-next.9"
44
43
  },
45
44
  "funding": {
46
45
  "type": "opencollective",
@@ -53,7 +52,6 @@
53
52
  "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
54
53
  "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
55
54
  "watch": "pnpm build:js -- --watch",
56
- "build": "pnpm run build:js && pnpm run build:types",
57
- "doc": "typedoc src/index.ts --tsconfig tsconfig.build.json"
55
+ "build": "pnpm run build:js && pnpm run build:types"
58
56
  }
59
57
  }
package/src/constants.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import httpCodes from 'http-status-codes';
2
+
1
3
  export const DEFAULT_MIN_LIMIT_PASSWORD = 3;
2
4
  export const TIME_EXPIRATION_24H = '24h';
3
5
  export const TIME_EXPIRATION_7D = '7d';
@@ -47,3 +49,43 @@ export const HEADERS = {
47
49
  WWW_AUTH: 'WWW-Authenticate',
48
50
  GZIP: 'gzip',
49
51
  };
52
+
53
+ export const HTTP_STATUS = {
54
+ OK: httpCodes.OK,
55
+ CREATED: httpCodes.CREATED,
56
+ MULTIPLE_CHOICES: httpCodes.MULTIPLE_CHOICES,
57
+ NOT_MODIFIED: httpCodes.NOT_MODIFIED,
58
+ BAD_REQUEST: httpCodes.BAD_REQUEST,
59
+ UNAUTHORIZED: httpCodes.UNAUTHORIZED,
60
+ FORBIDDEN: httpCodes.FORBIDDEN,
61
+ NOT_FOUND: httpCodes.NOT_FOUND,
62
+ CONFLICT: httpCodes.CONFLICT,
63
+ NOT_IMPLEMENTED: httpCodes.NOT_IMPLEMENTED,
64
+ UNSUPPORTED_MEDIA: httpCodes.UNSUPPORTED_MEDIA_TYPE,
65
+ BAD_DATA: httpCodes.UNPROCESSABLE_ENTITY,
66
+ INTERNAL_ERROR: httpCodes.INTERNAL_SERVER_ERROR,
67
+ SERVICE_UNAVAILABLE: httpCodes.SERVICE_UNAVAILABLE,
68
+ LOOP_DETECTED: 508,
69
+ };
70
+
71
+ export const ERROR_CODE = {
72
+ token_required: 'token is required',
73
+ };
74
+
75
+ export const API_MESSAGE = {
76
+ PKG_CREATED: 'created new package',
77
+ PKG_CHANGED: 'package changed',
78
+ PKG_REMOVED: 'package removed',
79
+ PKG_PUBLISHED: 'package published',
80
+ TARBALL_UPLOADED: 'tarball uploaded successfully',
81
+ TARBALL_REMOVED: 'tarball removed',
82
+ TAG_UPDATED: 'tags updated',
83
+ TAG_REMOVED: 'tag removed',
84
+ TAG_ADDED: 'package tagged',
85
+ LOGGED_OUT: 'Logged out',
86
+ };
87
+
88
+ export const LOG_STATUS_MESSAGE =
89
+ "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'";
90
+ export const LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;
91
+ export const LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;
@@ -1,48 +1,5 @@
1
1
  import createError, { HttpError } from 'http-errors';
2
- import httpCodes from 'http-status-codes';
3
- import { DEFAULT_MIN_LIMIT_PASSWORD } from './constants';
4
-
5
- export const HTTP_STATUS = {
6
- OK: httpCodes.OK,
7
- CREATED: httpCodes.CREATED,
8
- MULTIPLE_CHOICES: httpCodes.MULTIPLE_CHOICES,
9
- NOT_MODIFIED: httpCodes.NOT_MODIFIED,
10
- BAD_REQUEST: httpCodes.BAD_REQUEST,
11
- UNAUTHORIZED: httpCodes.UNAUTHORIZED,
12
- FORBIDDEN: httpCodes.FORBIDDEN,
13
- NOT_FOUND: httpCodes.NOT_FOUND,
14
- CONFLICT: httpCodes.CONFLICT,
15
- NOT_IMPLEMENTED: httpCodes.NOT_IMPLEMENTED,
16
- UNSUPPORTED_MEDIA: httpCodes.UNSUPPORTED_MEDIA_TYPE,
17
- BAD_DATA: httpCodes.UNPROCESSABLE_ENTITY,
18
- INTERNAL_ERROR: httpCodes.INTERNAL_SERVER_ERROR,
19
- SERVICE_UNAVAILABLE: httpCodes.SERVICE_UNAVAILABLE,
20
- LOOP_DETECTED: 508,
21
- };
22
-
23
- export const ERROR_CODE = {
24
- token_required: 'token is required',
25
- };
26
-
27
- export const API_MESSAGE = {
28
- PKG_CREATED: 'created new package',
29
- PKG_CHANGED: 'package changed',
30
- PKG_REMOVED: 'package removed',
31
- PKG_PUBLISHED: 'package published',
32
- TARBALL_UPLOADED: 'tarball uploaded successfully',
33
- TARBALL_REMOVED: 'tarball removed',
34
- TAG_UPDATED: 'tags updated',
35
- TAG_REMOVED: 'tag removed',
36
- TAG_ADDED: 'package tagged',
37
- LOGGED_OUT: 'Logged out',
38
- };
39
-
40
- export const SUPPORT_ERRORS = {
41
- PLUGIN_MISSING_INTERFACE: 'the plugin does not provide implementation of the requested feature',
42
- TFA_DISABLED: 'the two-factor authentication is not yet supported',
43
- STORAGE_NOT_IMPLEMENT: 'the storage does not support token saving',
44
- PARAMETERS_NOT_VALID: 'the parameters are not valid',
45
- };
2
+ import { DEFAULT_MIN_LIMIT_PASSWORD, HTTP_STATUS } from './constants';
46
3
 
47
4
  export const API_ERROR = {
48
5
  PASSWORD_SHORT: (passLength = DEFAULT_MIN_LIMIT_PASSWORD): string =>
@@ -82,6 +39,13 @@ export const API_ERROR = {
82
39
  USERNAME_ALREADY_REGISTERED: 'username is already registered',
83
40
  };
84
41
 
42
+ export const SUPPORT_ERRORS = {
43
+ PLUGIN_MISSING_INTERFACE: 'the plugin does not provide implementation of the requested feature',
44
+ TFA_DISABLED: 'the two-factor authentication is not yet supported',
45
+ STORAGE_NOT_IMPLEMENT: 'the storage does not support token saving',
46
+ PARAMETERS_NOT_VALID: 'the parameters are not valid',
47
+ };
48
+
85
49
  export const APP_ERROR = {
86
50
  CONFIG_NOT_VALID: 'CONFIG: it does not look like a valid config file',
87
51
  PROFILE_ERROR: 'profile unexpected error',
@@ -137,8 +101,3 @@ export function getNotFound(customMessage?: string): VerdaccioError {
137
101
  export function getCode(statusCode: number, customMessage: string): VerdaccioError {
138
102
  return getError(statusCode, customMessage);
139
103
  }
140
-
141
- export const LOG_STATUS_MESSAGE =
142
- "@{status}, user: @{user}(@{remoteIP}), req: '@{request.method} @{request.url}'";
143
- export const LOG_VERDACCIO_ERROR = `${LOG_STATUS_MESSAGE}, error: @{!error}`;
144
- export const LOG_VERDACCIO_BYTES = `${LOG_STATUS_MESSAGE}, bytes: @{bytes.in}/@{bytes.out}`;
package/src/index.ts CHANGED
@@ -7,6 +7,22 @@ import * as pluginUtils from './plugin-utils';
7
7
  import * as fileUtils from './file-utils';
8
8
  import * as pkgUtils from './pkg-utils';
9
9
 
10
+ export { VerdaccioError, API_ERROR, SUPPORT_ERRORS, APP_ERROR } from './error-utils';
11
+ export {
12
+ TOKEN_BASIC,
13
+ TOKEN_BEARER,
14
+ HTTP_STATUS,
15
+ API_MESSAGE,
16
+ HEADERS,
17
+ DIST_TAGS,
18
+ CHARACTER_ENCODING,
19
+ HEADER_TYPE,
20
+ LATEST,
21
+ DEFAULT_MIN_LIMIT_PASSWORD,
22
+ DEFAULT_USER,
23
+ USERS,
24
+ } from './constants';
25
+
10
26
  export {
11
27
  fileUtils,
12
28
  pkgUtils,
@@ -26,6 +26,12 @@ export type Score = {
26
26
  detail: SearchMetrics;
27
27
  };
28
28
 
29
+ export type SearchResults = {
30
+ objects: SearchItemPkg[];
31
+ total: number;
32
+ time: string;
33
+ };
34
+
29
35
  type PublisherMaintainer = {
30
36
  username: string;
31
37
  email: string;
@@ -1,9 +1,9 @@
1
1
  import _ from 'lodash';
2
+ import { HTTP_STATUS } from '../src/constants';
2
3
 
3
4
  import {
4
5
  getNotFound,
5
6
  VerdaccioError,
6
- HTTP_STATUS,
7
7
  getConflict,
8
8
  getBadData,
9
9
  getInternalError,