@verdaccio/utils
Advanced tools
Comparing version 6.0.0-6-next.19 to 6.0.0-6-next.20
@@ -10,3 +10,2 @@ "use strict"; | ||
exports.getAuthenticatedMessage = getAuthenticatedMessage; | ||
function createSessionToken() { | ||
@@ -19,11 +18,8 @@ const tenHoursTime = 10 * 60 * 60 * 1000; | ||
} | ||
function getAuthenticatedMessage(user) { | ||
return `you are authenticated as '${user}'`; | ||
} | ||
function buildUserBuffer(name, password) { | ||
return Buffer.from(`${name}:${password}`, 'utf8'); | ||
} | ||
const ROLES = { | ||
@@ -30,0 +26,0 @@ $ALL: '$all', |
@@ -10,11 +10,9 @@ "use strict"; | ||
exports.stringToMD5 = stringToMD5; | ||
var _crypto = require("crypto"); | ||
const defaultTarballHashAlgorithm = 'sha1'; | ||
exports.defaultTarballHashAlgorithm = defaultTarballHashAlgorithm; | ||
function createTarballHash() { | ||
return (0, _crypto.createHash)(defaultTarballHashAlgorithm); | ||
} | ||
/** | ||
@@ -27,8 +25,5 @@ * Express doesn't do ETAGS with requests <= 1024b | ||
*/ | ||
function stringToMD5(data) { | ||
return (0, _crypto.createHash)('md5').update(data).digest('hex'); | ||
} | ||
function generateRandomHexString(length = 8) { | ||
@@ -35,0 +30,0 @@ return (0, _crypto.pseudoRandomBytes)(length).toString('hex'); |
@@ -6,5 +6,3 @@ "use strict"; | ||
}); | ||
var _authUtils = require("./auth-utils"); | ||
Object.keys(_authUtils).forEach(function (key) { | ||
@@ -20,5 +18,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _utils = require("./utils"); | ||
Object.keys(_utils).forEach(function (key) { | ||
@@ -34,5 +30,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _cryptoUtils = require("./crypto-utils"); | ||
Object.keys(_cryptoUtils).forEach(function (key) { | ||
@@ -48,5 +42,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _replaceLodash = require("./replace-lodash"); | ||
Object.keys(_replaceLodash).forEach(function (key) { | ||
@@ -62,5 +54,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _matcher = require("./matcher"); | ||
Object.keys(_matcher).forEach(function (key) { | ||
@@ -67,0 +57,0 @@ if (key === "default" || key === "__esModule") return; |
@@ -7,7 +7,4 @@ "use strict"; | ||
exports.getMatchedPackagesSpec = getMatchedPackagesSpec; | ||
var _minimatch = _interopRequireDefault(require("minimatch")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function getMatchedPackagesSpec(pkgName, packages) { | ||
@@ -19,5 +16,4 @@ for (const i in packages) { | ||
} | ||
return; | ||
} | ||
//# sourceMappingURL=matcher.js.map |
@@ -8,7 +8,5 @@ "use strict"; | ||
exports.isNil = isNil; | ||
function isNil(value) { | ||
return value === null || typeof value === 'undefined'; | ||
} | ||
function isFunction(value) { | ||
@@ -15,0 +13,0 @@ return typeof value === 'function'; |
@@ -1,3 +0,3 @@ | ||
import { Author, Package } from '@verdaccio/types'; | ||
export declare type AuthorAvatar = Author & { | ||
import { Author, Manifest, Package } from '@verdaccio/types'; | ||
export type AuthorAvatar = Author & { | ||
avatar?: string; | ||
@@ -27,3 +27,3 @@ }; | ||
export declare function buildToken(type: string, token: string): string; | ||
export declare type AuthorFormat = Author | string | null | void; | ||
export type AuthorFormat = Author | string | null | void; | ||
/** | ||
@@ -50,3 +50,3 @@ * Formats author field for webui. | ||
export declare function isVersionValid(packageMeta: any, packageVersion: any): boolean; | ||
export declare function addGravatarSupport(pkgInfo: Package, online?: boolean): AuthorAvatar; | ||
export declare function addGravatarSupport(pkgInfo: Manifest, online?: boolean): AuthorAvatar; | ||
export declare const GENERIC_AVATAR: string; | ||
@@ -53,0 +53,0 @@ /** |
@@ -21,11 +21,6 @@ "use strict"; | ||
exports.validatePackage = validatePackage; | ||
var _lodash = _interopRequireDefault(require("lodash")); | ||
var _core = require("@verdaccio/core"); | ||
var _cryptoUtils = require("./crypto-utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
@@ -41,10 +36,9 @@ * From normalize-package-data/lib/fixer.js | ||
} | ||
let normalizedName = name.toLowerCase(); | ||
const isScoped = name.startsWith('@') && name.includes('/'); | ||
const scopedName = name.split('/', 2)[1]; | ||
if (isScoped && !_lodash.default.isUndefined(scopedName)) { | ||
normalizedName = scopedName.toLowerCase(); | ||
} | ||
/** | ||
@@ -61,7 +55,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)); | ||
} | ||
/** | ||
@@ -72,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]); | ||
} | ||
/** | ||
@@ -92,16 +83,11 @@ * Check whether an element is an Object | ||
*/ | ||
function isObject(obj) { | ||
return _lodash.default.isObject(obj) && _lodash.default.isNull(obj) === false && _lodash.default.isArray(obj) === false; | ||
} | ||
function getLatestVersion(pkgInfo) { | ||
return pkgInfo[_core.DIST_TAGS].latest; | ||
} | ||
function buildToken(type, token) { | ||
return `${_lodash.default.capitalize(type)} ${token}`; | ||
} | ||
/** | ||
@@ -118,21 +104,20 @@ * Formats author field for webui. | ||
}; | ||
if (_lodash.default.isNil(author)) { | ||
return authorDetails; | ||
} | ||
if (_lodash.default.isString(author)) { | ||
authorDetails = { ...authorDetails, | ||
authorDetails = { | ||
...authorDetails, | ||
name: author | ||
}; | ||
} | ||
if (_lodash.default.isObject(author)) { | ||
authorDetails = { ...authorDetails, | ||
authorDetails = { | ||
...authorDetails, | ||
...author | ||
}; | ||
} | ||
return authorDetails; | ||
} | ||
/** | ||
@@ -143,4 +128,2 @@ * Apply whitespaces based on the length | ||
*/ | ||
function pad(str, max) { | ||
@@ -150,5 +133,5 @@ if (str.length < max) { | ||
} | ||
return str; | ||
} | ||
/** | ||
@@ -160,35 +143,27 @@ * return a masquerade string with its first and last {charNum} and three dots in between. | ||
*/ | ||
function mask(str, charNum = 3) { | ||
return `${str.slice(0, charNum)}...${str.slice(-charNum)}`; | ||
} // @deprecated | ||
} | ||
// @deprecated | ||
function hasDiffOneKey(versions) { | ||
return Object.keys(versions).length !== 1; | ||
} | ||
function isVersionValid(packageMeta, packageVersion) { | ||
const hasVersion = typeof packageVersion !== 'undefined'; | ||
if (!hasVersion) { | ||
return false; | ||
} | ||
const hasMatchVersion = Object.keys(packageMeta.versions).includes(packageVersion); | ||
return hasMatchVersion; | ||
} | ||
function addGravatarSupport(pkgInfo, online = true) { | ||
const pkgInfoCopy = { ...pkgInfo | ||
const pkgInfoCopy = { | ||
...pkgInfo | ||
}; | ||
const author = _lodash.default.get(pkgInfo, 'latest.author', null); | ||
const contributors = normalizeContributors(_lodash.default.get(pkgInfo, 'latest.contributors', [])); | ||
const maintainers = _lodash.default.get(pkgInfo, 'latest.maintainers', []); | ||
const maintainers = _lodash.default.get(pkgInfo, 'latest.maintainers', []); // for author. | ||
// for author. | ||
if (author && _lodash.default.isObject(author)) { | ||
@@ -200,3 +175,2 @@ const { | ||
} | ||
if (author && _lodash.default.isString(author)) { | ||
@@ -208,5 +182,5 @@ pkgInfoCopy.latest.author = { | ||
}; | ||
} // for contributors | ||
} | ||
// for contributors | ||
if (_lodash.default.isEmpty(contributors) === false) { | ||
@@ -223,10 +197,10 @@ pkgInfoCopy.latest.contributors = contributors.map(contributor => { | ||
} | ||
return contributor; | ||
}); | ||
} // for maintainers | ||
} | ||
// for maintainers | ||
if (_lodash.default.isEmpty(maintainers) === false) { | ||
pkgInfoCopy.latest.maintainers = maintainers.map(maintainer => { | ||
// @ts-ignore | ||
maintainer.avatar = generateGravatarUrl(maintainer.email, online); | ||
@@ -236,14 +210,11 @@ return maintainer; | ||
} | ||
return pkgInfoCopy; | ||
} | ||
const AVATAR_PROVIDER = 'https://www.gravatar.com/avatar/'; | ||
const GENERIC_AVATAR = 'data:image/svg+xml;utf8,' + encodeURIComponent('<svg height="100" viewBox="-27 24 100 100" width="100" xmlns="http://www.w3.org/' + '2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><circle cx="23" cy="7' + '4" id="a" r="50"/></defs><use fill="#F5EEE5" overflow="visible" xlink:href="#a"/' + '><clipPath id="b"><use overflow="visible" xlink:href="#a"/></clipPath><g clip-pa' + 'th="url(#b)"><defs><path d="M36 95.9c0 4 4.7 5.2 7.1 5.8 7.6 2 22.8 5.9 22.8 5.9' + ' 3.2 1.1 5.7 3.5 7.1 6.6v9.8H-27v-9.8c1.3-3.1 3.9-5.5 7.1-6.6 0 0 15.2-3.9 22.8-' + '5.9 2.4-.6 7.1-1.8 7.1-5.8V85h26v10.9z" id="c"/></defs><use fill="#E6C19C" overf' + 'low="visible" xlink:href="#c"/><clipPath id="d"><use overflow="visible" xlink:hr' + 'ef="#c"/></clipPath><path clip-path="url(#d)" d="M23.2 35h.2c3.3 0 8.2.2 11.4 2 ' + '3.3 1.9 7.3 5.6 8.5 12.1 2.4 13.7-2.1 35.4-6.3 42.4-4 6.7-9.8 9.2-13.5 9.4H23h-.' + '1c-3.7-.2-9.5-2.7-13.5-9.4-4.2-7-8.7-28.7-6.3-42.4 1.2-6.5 5.2-10.2 8.5-12.1 3.2' + '-1.8 8.1-2 11.4-2h.2z" fill="#D4B08C"/></g><path d="M22.6 40c19.1 0 20.7 13.8 20' + '.8 15.1 1.1 11.9-3 28.1-6.8 33.7-4 5.9-9.8 8.1-13.5 8.3h-.5c-3.8-.3-9.6-2.5-13.6' + '-8.4-3.8-5.6-7.9-21.8-6.8-33.8C2.3 53.7 3.5 40 22.6 40z" fill="#F2CEA5"/></svg>'); | ||
/** | ||
* Generate gravatar url from email address | ||
*/ | ||
exports.GENERIC_AVATAR = GENERIC_AVATAR; | ||
function generateGravatarUrl(email = '', online = true) { | ||
@@ -255,6 +226,4 @@ if (online && _lodash.default.isString(email) && _lodash.default.size(email) > 0) { | ||
} | ||
return GENERIC_AVATAR; | ||
} | ||
function normalizeContributors(contributors) { | ||
@@ -272,6 +241,4 @@ if (_lodash.default.isNil(contributors)) { | ||
} | ||
return contributors; | ||
} | ||
function deleteProperties(propertiesToDelete, objectItem) { | ||
@@ -281,5 +248,4 @@ _lodash.default.forEach(propertiesToDelete, property => { | ||
}); | ||
return objectItem; | ||
} | ||
//# sourceMappingURL=utils.js.map |
# @verdaccio/utils | ||
## 6.0.0-6-next.20 | ||
### Patch Changes | ||
- @verdaccio/core@6.0.0-6-next.52 | ||
## 6.0.0-6-next.19 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@verdaccio/utils", | ||
"version": "6.0.0-6-next.19", | ||
"version": "6.0.0-6-next.20", | ||
"description": "verdaccio utilities", | ||
@@ -33,3 +33,3 @@ "main": "./build/index.js", | ||
"dependencies": { | ||
"@verdaccio/core": "6.0.0-6-next.51", | ||
"@verdaccio/core": "6.0.0-6-next.52", | ||
"minimatch": "3.1.2", | ||
@@ -36,0 +36,0 @@ "semver": "7.3.8", |
import _ from 'lodash'; | ||
import { DEFAULT_USER, DIST_TAGS } from '@verdaccio/core'; | ||
import { Author, Package } from '@verdaccio/types'; | ||
import { Author, Manifest, Package } from '@verdaccio/types'; | ||
@@ -151,3 +151,3 @@ import { stringToMD5 } from './crypto-utils'; | ||
export function addGravatarSupport(pkgInfo: Package, online = true): AuthorAvatar { | ||
export function addGravatarSupport(pkgInfo: Manifest, online = true): AuthorAvatar { | ||
const pkgInfoCopy = { ...pkgInfo } as any; | ||
@@ -194,2 +194,3 @@ const author: any = _.get(pkgInfo, 'latest.author', null) as any; | ||
pkgInfoCopy.latest.maintainers = maintainers.map((maintainer): void => { | ||
// @ts-ignore | ||
maintainer.avatar = generateGravatarUrl(maintainer.email, online); | ||
@@ -196,0 +197,0 @@ return maintainer; |
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
80468
1086
+ Added@verdaccio/core@6.0.0-6-next.52(transitive)
+ Addedajv@8.11.2(transitive)
+ Addedcore-js@3.26.1(transitive)
- Removed@verdaccio/core@6.0.0-6-next.51(transitive)
- Removedajv@8.11.0(transitive)
- Removedcore-js@3.25.5(transitive)