@verdaccio/core
Advanced tools
Comparing version 6.0.0-6-next.51 to 6.0.0-6-next.52
@@ -7,7 +7,4 @@ "use strict"; | ||
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; | ||
var _httpStatusCodes = _interopRequireDefault(require("http-status-codes")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const DEFAULT_PASSWORD_VALIDATION = /.{3}$/; | ||
@@ -36,4 +33,5 @@ exports.DEFAULT_PASSWORD_VALIDATION = DEFAULT_PASSWORD_VALIDATION; | ||
UTF8: 'utf8' | ||
}; // @deprecated use Bearer instead | ||
}; | ||
// @deprecated use Bearer instead | ||
exports.CHARACTER_ENCODING = CHARACTER_ENCODING; | ||
@@ -40,0 +38,0 @@ const TOKEN_BASIC = 'Basic'; |
@@ -50,3 +50,3 @@ import { HttpError } from 'http-errors'; | ||
}; | ||
export declare type VerdaccioError = HttpError & { | ||
export type VerdaccioError = HttpError & { | ||
code: number; | ||
@@ -53,0 +53,0 @@ }; |
@@ -16,9 +16,5 @@ "use strict"; | ||
exports.getUnauthorized = getUnauthorized; | ||
var _httpErrors = _interopRequireDefault(require("http-errors")); | ||
var _constants = require("./constants"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const API_ERROR = { | ||
@@ -75,3 +71,2 @@ PASSWORD_SHORT: `The provided password does not pass the validation`, | ||
exports.APP_ERROR = APP_ERROR; | ||
function getError(code, message) { | ||
@@ -82,35 +77,26 @@ const httpError = (0, _httpErrors.default)(code, message); | ||
} | ||
function getConflict(message = API_ERROR.PACKAGE_EXIST) { | ||
return getError(_constants.HTTP_STATUS.CONFLICT, message); | ||
} | ||
function getBadData(customMessage) { | ||
return getError(_constants.HTTP_STATUS.BAD_DATA, customMessage || API_ERROR.BAD_DATA); | ||
} | ||
function getBadRequest(customMessage) { | ||
return getError(_constants.HTTP_STATUS.BAD_REQUEST, customMessage); | ||
} | ||
function getInternalError(customMessage) { | ||
return customMessage ? getError(_constants.HTTP_STATUS.INTERNAL_ERROR, customMessage) : getError(_constants.HTTP_STATUS.INTERNAL_ERROR, API_ERROR.UNKNOWN_ERROR); | ||
} | ||
function getUnauthorized(message = 'no credentials provided') { | ||
return getError(_constants.HTTP_STATUS.UNAUTHORIZED, message); | ||
} | ||
function getForbidden(message = "can't use this filename") { | ||
return getError(_constants.HTTP_STATUS.FORBIDDEN, message); | ||
} | ||
function getServiceUnavailable(message = API_ERROR.RESOURCE_UNAVAILABLE) { | ||
return getError(_constants.HTTP_STATUS.SERVICE_UNAVAILABLE, message); | ||
} | ||
function getNotFound(customMessage) { | ||
return getError(_constants.HTTP_STATUS.NOT_FOUND, customMessage || API_ERROR.NO_PACKAGE); | ||
} | ||
function getCode(statusCode, customMessage) { | ||
@@ -117,0 +103,0 @@ return getError(statusCode, customMessage); |
@@ -9,14 +9,10 @@ "use strict"; | ||
exports.createTempStorageFolder = createTempStorageFolder; | ||
var _promises = require("fs/promises"); | ||
var _os = _interopRequireDefault(require("os")); | ||
var _path = _interopRequireDefault(require("path")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const Files = { | ||
DatabaseName: '.verdaccio-db.json' | ||
}; | ||
/** | ||
@@ -27,8 +23,7 @@ * Create a temporary folder. | ||
*/ | ||
exports.Files = Files; | ||
async function createTempFolder(prefix) { | ||
return await (0, _promises.mkdtemp)(_path.default.join(_os.default.tmpdir(), prefix)); | ||
} | ||
/** | ||
@@ -40,9 +35,5 @@ * Create temporary folder for an asset. | ||
*/ | ||
async function createTempStorageFolder(prefix, folder = 'storage') { | ||
const tempFolder = await createTempFolder(prefix); | ||
const storageFolder = _path.default.join(tempFolder, folder); | ||
await (0, _promises.mkdir)(storageFolder); | ||
@@ -49,0 +40,0 @@ return storageFolder; |
@@ -103,49 +103,26 @@ "use strict"; | ||
exports.warningUtils = exports.validationUtils = exports.validatioUtils = exports.stringUtils = exports.streamUtils = exports.searchUtils = exports.pluginUtils = exports.pkgUtils = exports.fileUtils = exports.errorUtils = exports.constants = void 0; | ||
var constants = _interopRequireWildcard(require("./constants")); | ||
exports.constants = constants; | ||
var errorUtils = _interopRequireWildcard(require("./error-utils")); | ||
exports.errorUtils = errorUtils; | ||
var fileUtils = _interopRequireWildcard(require("./file-utils")); | ||
exports.fileUtils = fileUtils; | ||
var pkgUtils = _interopRequireWildcard(require("./pkg-utils")); | ||
exports.pkgUtils = pkgUtils; | ||
var pluginUtils = _interopRequireWildcard(require("./plugin-utils")); | ||
exports.pluginUtils = pluginUtils; | ||
var searchUtils = _interopRequireWildcard(require("./search-utils")); | ||
exports.searchUtils = searchUtils; | ||
var streamUtils = _interopRequireWildcard(require("./stream-utils")); | ||
exports.streamUtils = streamUtils; | ||
var stringUtils = _interopRequireWildcard(require("./string-utils")); | ||
exports.stringUtils = stringUtils; | ||
var validatioUtils = _interopRequireWildcard(require("./validation-utils")); | ||
exports.validatioUtils = validatioUtils; | ||
var warningUtils = _interopRequireWildcard(require("./warning-utils")); | ||
exports.warningUtils = warningUtils; | ||
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); } | ||
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; } | ||
const validationUtils = validatioUtils; | ||
exports.validationUtils = validationUtils; | ||
//# sourceMappingURL=index.js.map |
@@ -10,11 +10,6 @@ "use strict"; | ||
exports.semverSort = semverSort; | ||
var _semver = _interopRequireDefault(require("semver")); | ||
var _url = require("url"); | ||
var _constants = require("./constants"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
@@ -31,2 +26,3 @@ * Extract the tarball name from a registry dist url | ||
} | ||
/** | ||
@@ -36,4 +32,2 @@ * Function filters out bad semver versions and sorts the array. | ||
*/ | ||
function semverSort(listVersions) { | ||
@@ -44,6 +38,6 @@ return listVersions.filter(function (x) { | ||
} | ||
return true; | ||
}).sort(_semver.default.compareLoose).map(String); | ||
} | ||
/** | ||
@@ -53,13 +47,8 @@ * Get the latest publihsed version of a package. | ||
**/ | ||
function getLatest(pkg) { | ||
var _pkg$DIST_TAGS; | ||
const listVersions = Object.keys(pkg.versions); | ||
if (listVersions.length < 1) { | ||
throw Error('cannot get lastest version of none'); | ||
} | ||
const versions = semverSort(listVersions); | ||
@@ -69,2 +58,3 @@ 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]; | ||
} | ||
/** | ||
@@ -79,4 +69,2 @@ * Function gets a local info and an info from uplinks and tries to merge it | ||
// @deprecated | ||
function mergeVersions(local, upstream) { | ||
@@ -90,3 +78,2 @@ // copy new versions to a cache | ||
} | ||
for (const i in upstream[_constants.DIST_TAGS]) { | ||
@@ -97,3 +84,2 @@ if (local[_constants.DIST_TAGS][i] !== upstream[_constants.DIST_TAGS][i]) { | ||
} | ||
if (i === 'latest' && local[_constants.DIST_TAGS][i] === upstream[_constants.DIST_TAGS][i]) { | ||
@@ -100,0 +86,0 @@ // if remote has more fresh package, we should borrow its readme |
@@ -85,7 +85,7 @@ /// <reference types="node" /> | ||
*/ | ||
export declare type AuthCallback = (error: VerdaccioError | null, groups?: string[] | false) => void; | ||
export declare type AuthAccessCallback = (error: VerdaccioError | null, access?: boolean) => void; | ||
export declare type AuthUserCallback = (error: VerdaccioError | null, access?: boolean | string) => void; | ||
export declare type AuthChangePasswordCallback = (error: VerdaccioError | null, access?: boolean) => void; | ||
export declare type AccessCallback = (error: VerdaccioError | null, ok?: boolean) => void; | ||
export type AuthCallback = (error: VerdaccioError | null, groups?: string[] | false) => void; | ||
export type AuthAccessCallback = (error: VerdaccioError | null, access?: boolean) => void; | ||
export type AuthUserCallback = (error: VerdaccioError | null, access?: boolean | string) => void; | ||
export type AuthChangePasswordCallback = (error: VerdaccioError | null, access?: boolean) => void; | ||
export type AccessCallback = (error: VerdaccioError | null, ok?: boolean) => void; | ||
export interface Auth<T> extends Plugin<T> { | ||
@@ -92,0 +92,0 @@ /** |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.Plugin = void 0; | ||
/** | ||
@@ -16,3 +15,2 @@ * The base plugin class, set of utilities for developing | ||
static version = 1; | ||
constructor(config, options) { | ||
@@ -23,10 +21,7 @@ this.version = Plugin.version; | ||
} | ||
getVersion() { | ||
return this.version; | ||
} | ||
} | ||
exports.Plugin = Plugin; | ||
//# sourceMappingURL=plugin-utils.js.map |
@@ -7,8 +7,7 @@ "use strict"; | ||
exports.validatePublishSingleVersion = validatePublishSingleVersion; | ||
var _ajv = _interopRequireDefault(require("ajv")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const ajv = new _ajv.default(); | ||
const ajv = new _ajv.default(); // FIXME: this could extend from @verdaccio/types but we need | ||
// FIXME: this could extend from @verdaccio/types but we need | ||
// schemas from @verdaccio/types to be able to validate them | ||
@@ -33,5 +32,7 @@ | ||
additionalProperties: true | ||
}; // validate is a type guard for MyData - type is inferred from schema type | ||
}; | ||
// validate is a type guard for MyData - type is inferred from schema type | ||
const validate = ajv.compile(schema); | ||
/** | ||
@@ -43,3 +44,2 @@ * Validate if a manifest has the correct structure when a new package | ||
*/ | ||
function validatePublishSingleVersion(manifest) { | ||
@@ -49,5 +49,4 @@ if (!manifest) { | ||
} | ||
return validate(manifest); | ||
} | ||
//# sourceMappingURL=publish-manifest.js.map |
@@ -1,2 +0,2 @@ | ||
export declare type SearchMetrics = { | ||
export type SearchMetrics = { | ||
quality: number; | ||
@@ -6,3 +6,3 @@ popularity: number; | ||
}; | ||
export declare type UnStable = { | ||
export type UnStable = { | ||
flags?: { | ||
@@ -12,3 +12,3 @@ unstable?: boolean; | ||
}; | ||
export declare type SearchItemPkg = { | ||
export type SearchItemPkg = { | ||
name: string; | ||
@@ -19,3 +19,3 @@ scoped?: string; | ||
}; | ||
declare type PrivatePackage = { | ||
type PrivatePackage = { | ||
verdaccioPrivate?: boolean; | ||
@@ -28,7 +28,7 @@ verdaccioPkgCached?: boolean; | ||
} | ||
export declare type Score = { | ||
export type Score = { | ||
final: number; | ||
detail: SearchMetrics; | ||
}; | ||
export declare type SearchResults = { | ||
export type SearchResults = { | ||
objects: SearchItemPkg[]; | ||
@@ -38,7 +38,7 @@ total: number; | ||
}; | ||
declare type PublisherMaintainer = { | ||
type PublisherMaintainer = { | ||
username: string; | ||
email: string; | ||
}; | ||
export declare type SearchPackageBody = { | ||
export type SearchPackageBody = { | ||
name: string; | ||
@@ -66,3 +66,3 @@ scope: string; | ||
export declare const UNSCOPED = "unscoped"; | ||
export declare type SearchQuery = { | ||
export type SearchQuery = { | ||
text: string; | ||
@@ -69,0 +69,0 @@ size?: number; |
@@ -8,5 +8,7 @@ "use strict"; | ||
// @deprecated use @verdaccio/types | ||
// @deprecated use @verdaccio/types | ||
const UNSCOPED = 'unscoped'; | ||
exports.UNSCOPED = UNSCOPED; | ||
//# sourceMappingURL=search-utils.js.map |
@@ -7,5 +7,3 @@ "use strict"; | ||
exports.transformObjectToString = exports.readableToString = void 0; | ||
var _stream = require("stream"); | ||
/** | ||
@@ -16,7 +14,5 @@ * Converts a buffer stream to a string. | ||
const chunks = []; | ||
for await (let chunk of stream) { | ||
chunks.push(Buffer.from(chunk)); | ||
} | ||
const buffer = Buffer.concat(chunks); | ||
@@ -26,9 +22,7 @@ const str = buffer.toString('utf-8'); | ||
}; | ||
/** | ||
* Transform stream object mode to string | ||
**/ | ||
exports.readableToString = readableToString; | ||
const transformObjectToString = () => { | ||
@@ -42,4 +36,3 @@ return new _stream.Transform({ | ||
}; | ||
exports.transformObjectToString = transformObjectToString; | ||
//# sourceMappingURL=stream-utils.js.map |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.getByQualityPriorityValue = getByQualityPriorityValue; | ||
/** | ||
@@ -20,5 +19,3 @@ * Quality values, or q-values and q-factors, are used to describe the order | ||
} | ||
const split = headerValue.split(','); | ||
if (split.length <= 1) { | ||
@@ -28,6 +25,4 @@ const qList = split[0].split(';'); | ||
} | ||
let [header] = split.reduce((acc, item) => { | ||
const qList = item.split(';'); | ||
if (qList.length > 1) { | ||
@@ -40,3 +35,2 @@ const [accept, q] = qList; | ||
} | ||
return acc; | ||
@@ -43,0 +37,0 @@ }, []).sort(function (a, b) { |
@@ -18,14 +18,10 @@ "use strict"; | ||
}); | ||
var _assert = _interopRequireDefault(require("assert")); | ||
var _constants = require("./constants"); | ||
var _publishManifest = require("./schemes/publish-manifest"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function isPackageNameScoped(name) { | ||
return name.startsWith('@'); | ||
} | ||
/** | ||
@@ -36,4 +32,2 @@ * From normalize-package-data/lib/fixer.js | ||
*/ | ||
function validateName(name) { | ||
@@ -43,10 +37,9 @@ if (typeof name !== 'string') { | ||
} | ||
let normalizedName = name.toLowerCase(); | ||
const isScoped = isPackageNameScoped(name); | ||
const scopedName = name.split('/', 2)[1]; | ||
if (isScoped && typeof scopedName !== 'undefined') { | ||
normalizedName = scopedName.toLowerCase(); | ||
} | ||
/** | ||
@@ -63,7 +56,7 @@ * Some context about the first regex | ||
*/ | ||
return !(!normalizedName.match(/^[-a-zA-Z0-9_.!~*'()@]+$/) || normalizedName.startsWith('.') || // ".bin", etc. | ||
return !(!normalizedName.match(/^[-a-zA-Z0-9_.!~*'()@]+$/) || normalizedName.startsWith('.') || | ||
// ".bin", etc. | ||
['node_modules', '__proto__', 'favicon.ico'].includes(normalizedName)); | ||
} | ||
/** | ||
@@ -73,15 +66,12 @@ * Validate a package. | ||
*/ | ||
function validatePackage(name) { | ||
const nameList = name.split('/', 2); | ||
if (nameList.length === 1) { | ||
// normal package | ||
return validateName(nameList[0]); | ||
} // scoped package | ||
} | ||
// scoped package | ||
return nameList[0][0] === '@' && validateName(nameList[0].slice(1)) && validateName(nameList[1]); | ||
} | ||
/** | ||
@@ -95,25 +85,21 @@ * Validate the package metadata, add additional properties whether are missing within | ||
*/ | ||
function normalizeMetadata(manifest, name) { | ||
_assert.default.strictEqual(manifest.name, name); | ||
const _manifest = { ...manifest | ||
const _manifest = { | ||
...manifest | ||
}; | ||
if (!isObject(manifest[_constants.DIST_TAGS])) { | ||
_manifest[_constants.DIST_TAGS] = {}; | ||
} // This may not be nee dit | ||
} | ||
// This may not be nee dit | ||
if (!isObject(manifest['versions'])) { | ||
_manifest['versions'] = {}; | ||
} | ||
if (!isObject(manifest['time'])) { | ||
_manifest['time'] = {}; | ||
} | ||
return _manifest; | ||
} | ||
/** | ||
@@ -124,4 +110,2 @@ * Check whether an element is an Object | ||
*/ | ||
function isObject(obj) { | ||
@@ -131,6 +115,4 @@ if (obj === null || typeof obj === 'undefined' || typeof obj === 'string') { | ||
} | ||
return (typeof obj === 'object' || typeof obj.prototype === 'undefined') && Array.isArray(obj) === false; | ||
} | ||
function validatePassword(password, validation = _constants.DEFAULT_PASSWORD_VALIDATION) { | ||
@@ -137,0 +119,0 @@ return typeof password === 'string' && validation instanceof RegExp ? password.match(validation) !== null : false; |
@@ -8,7 +8,4 @@ "use strict"; | ||
exports.emit = emit; | ||
var _processWarning = _interopRequireDefault(require("process-warning")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const warningInstance = (0, _processWarning.default)(); | ||
@@ -19,3 +16,2 @@ const verdaccioWarning = 'VerdaccioWarning'; | ||
exports.Codes = Codes; | ||
(function (Codes) { | ||
@@ -28,3 +24,2 @@ Codes["VERWAR001"] = "VERWAR001"; | ||
})(Codes || (exports.Codes = Codes = {})); | ||
warningInstance.create(verdaccioWarning, Codes.VERWAR002, `The property config "logs" property is longer supported, rename to "log" and use object instead`); | ||
@@ -37,3 +32,2 @@ warningInstance.create(verdaccioWarning, Codes.VERWAR001, `Verdaccio doesn't need superuser privileges. don't run it under root`); | ||
warningInstance.create(verdaccioDeprecation, Codes.VERDEP003, 'multiple addresses will be deprecated in the next major, only use one'); | ||
function emit(code, a, b, c) { | ||
@@ -40,0 +34,0 @@ warningInstance.emit(code, a, b, c); |
# @verdaccio/core | ||
## 6.0.0-6-next.52 | ||
## 6.0.0-6-next.51 | ||
@@ -4,0 +6,0 @@ |
{ | ||
"name": "@verdaccio/core", | ||
"version": "6.0.0-6-next.51", | ||
"version": "6.0.0-6-next.52", | ||
"description": "core utilities", | ||
@@ -40,9 +40,9 @@ "keywords": [ | ||
"semver": "7.3.8", | ||
"ajv": "8.11.0", | ||
"ajv": "8.11.2", | ||
"process-warning": "1.0.0", | ||
"core-js": "3.25.5" | ||
"core-js": "3.26.1" | ||
}, | ||
"devDependencies": { | ||
"lodash": "4.17.21", | ||
"typedoc": "0.23.16", | ||
"typedoc": "0.23.21", | ||
"typedoc-plugin-missing-exports": "latest", | ||
@@ -49,0 +49,0 @@ "@verdaccio/types": "11.0.0-6-next.17" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2464
143358
+ Addedajv@8.11.2(transitive)
+ Addedcore-js@3.26.1(transitive)
- Removedajv@8.11.0(transitive)
- Removedcore-js@3.25.5(transitive)
Updatedajv@8.11.2
Updatedcore-js@3.26.1