@verdaccio/web 8.1.0-next-8.15 → 8.1.0-next-8.16
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/build/api/package.js +3 -3
- package/build/api/package.js.map +1 -1
- package/build/api/readme.d.ts +0 -8
- package/build/api/readme.js +3 -5
- package/build/api/readme.js.map +1 -1
- package/build/api/sidebar.d.ts +1 -11
- package/build/api/sidebar.js +6 -10
- package/build/api/sidebar.js.map +1 -1
- package/build/api/user.js +1 -1
- package/build/api/user.js.map +1 -1
- package/build/author-utils.d.ts +13 -0
- package/build/author-utils.js +172 -0
- package/build/author-utils.js.map +1 -0
- package/build/index.d.ts +2 -1
- package/build/index.js +12 -7
- package/build/index.js.map +1 -1
- package/build/middleware.d.ts +0 -1
- package/build/middleware.js +2 -3
- package/build/middleware.js.map +1 -1
- package/build/web-utils.d.ts +2 -4
- package/build/web-utils.js +9 -0
- package/build/web-utils.js.map +1 -1
- package/package.json +16 -17
package/build/api/package.js
CHANGED
|
@@ -29,7 +29,7 @@ var _config = require("@verdaccio/config");
|
|
|
29
29
|
var _logger = require("@verdaccio/logger");
|
|
30
30
|
var _middleware = require("@verdaccio/middleware");
|
|
31
31
|
var _tarball = require("@verdaccio/tarball");
|
|
32
|
-
var
|
|
32
|
+
var _authorUtils = require("../author-utils");
|
|
33
33
|
var _webUtils = require("../web-utils");
|
|
34
34
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
35
35
|
// Was required by other packages
|
|
@@ -67,12 +67,12 @@ function addPackageWebApi(storage, auth, config) {
|
|
|
67
67
|
const pkgCopy = {
|
|
68
68
|
...pkg
|
|
69
69
|
};
|
|
70
|
-
pkgCopy.author = (0,
|
|
70
|
+
pkgCopy.author = (0, _authorUtils.formatAuthor)(pkg.author);
|
|
71
71
|
try {
|
|
72
72
|
if (await checkAllow(pkg.name, req.remote_user)) {
|
|
73
73
|
if (config.web) {
|
|
74
74
|
// @ts-ignore
|
|
75
|
-
pkgCopy.author.avatar = (0,
|
|
75
|
+
pkgCopy.author.avatar = (0, _authorUtils.generateGravatarUrl)(pkgCopy.author.email, config.web.gravatar);
|
|
76
76
|
}
|
|
77
77
|
// convert any remote dist to a local reference
|
|
78
78
|
// eg: if the dist points to npmjs, switch to localhost:4873/prefix/etc.tar.gz
|
package/build/api/package.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","names":["_debug","_interopRequireDefault","require","_express","_lodash","_config","_logger","_middleware","_tarball","
|
|
1
|
+
{"version":3,"file":"package.js","names":["_debug","_interopRequireDefault","require","_express","_lodash","_config","_logger","_middleware","_tarball","_authorUtils","_webUtils","e","__esModule","default","getOrder","order","debug","buildDebug","addPackageWebApi","storage","auth","config","isLoginEnabled","web","login","pkgRouter","Router","anonymousRemoteUser","createAnonymousRemoteUser","checkAllow","name","remoteUser","Promise","resolve","reject","remoteUserAccess","allow_access","packageName","err","allowed","processPackages","packages","req","permissions","packagesToProcess","slice","pkg","pkgCopy","author","formatAuthor","remote_user","avatar","generateGravatarUrl","email","gravatar","_","isNil","dist","isNull","tarball","getLocalRegistryTarballUri","protocol","headers","host","hostname","url_prefix","push","logger","error","get","WebUrls","packages_all","res","next","localPackages","getLocalDatabase","sort_packages","pkgs","sortByName","_default","exports"],"sources":["../../src/api/package.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\nimport _ from 'lodash';\n\nimport { Auth } from '@verdaccio/auth';\nimport { createAnonymousRemoteUser } from '@verdaccio/config';\nimport { logger } from '@verdaccio/logger';\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '@verdaccio/middleware';\nimport { WebUrls } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { getLocalRegistryTarballUri } from '@verdaccio/tarball';\nimport { Config, RemoteUser, Version } from '@verdaccio/types';\n\nimport { formatAuthor, generateGravatarUrl } from '../author-utils';\nimport { sortByName } from '../web-utils';\n\nexport { $RequestExtend, $ResponseExtend, $NextFunctionVer }; // Was required by other packages\n\nconst getOrder = (order = 'asc') => {\n return order === 'asc';\n};\n\nconst debug = buildDebug('verdaccio:web:api:package');\n\nfunction addPackageWebApi(storage: Storage, auth: Auth, config: Config): Router {\n const isLoginEnabled = config?.web?.login === true;\n const pkgRouter = Router(); /* eslint new-cap: 0 */\n const anonymousRemoteUser: RemoteUser = createAnonymousRemoteUser();\n\n debug('initialized package web api');\n const checkAllow = (name: string, remoteUser: RemoteUser): Promise<boolean> =>\n new Promise((resolve, reject): void => {\n debug('is login enabled: %o', isLoginEnabled);\n const remoteUserAccess = !isLoginEnabled ? anonymousRemoteUser : remoteUser;\n try {\n auth.allow_access({ packageName: name }, remoteUserAccess, (err, allowed): void => {\n if (err) {\n resolve(false);\n }\n return resolve(allowed as boolean);\n });\n } catch (err: any) {\n reject(err);\n }\n });\n\n async function processPackages(packages: Version[] = [], req): Promise<Version[]> {\n const permissions: Version[] = [];\n const packagesToProcess = packages.slice();\n debug('process packages %o', packagesToProcess);\n for (const pkg of packagesToProcess) {\n const pkgCopy = { ...pkg };\n pkgCopy.author = formatAuthor(pkg.author);\n try {\n if (await checkAllow(pkg.name, req.remote_user)) {\n if (config.web) {\n // @ts-ignore\n pkgCopy.author.avatar = generateGravatarUrl(pkgCopy.author.email, config.web.gravatar);\n }\n // convert any remote dist to a local reference\n // eg: if the dist points to npmjs, switch to localhost:4873/prefix/etc.tar.gz\n if (!_.isNil(pkgCopy.dist) && !_.isNull(pkgCopy.dist.tarball)) {\n pkgCopy.dist.tarball = getLocalRegistryTarballUri(\n pkgCopy.dist.tarball,\n pkg.name,\n { protocol: req.protocol, headers: req.headers as any, host: req.hostname },\n config?.url_prefix\n );\n }\n permissions.push(pkgCopy);\n }\n } catch (err: any) {\n debug('process packages error %o', err);\n logger.error(\n { name: pkg.name, error: err },\n 'permission process for @{name} has failed: @{error}'\n );\n throw err;\n }\n }\n\n return permissions;\n }\n\n // Get list of all visible package\n pkgRouter.get(\n WebUrls.packages_all,\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n debug('hit package web api %o');\n\n try {\n const localPackages: Version[] = await storage.getLocalDatabase();\n\n const order = getOrder(config?.web?.sort_packages);\n debug('order %o', order);\n const pkgs = await processPackages(localPackages, req);\n next(sortByName(pkgs, order));\n } catch (error: any) {\n next(error);\n }\n }\n );\n\n return pkgRouter;\n}\n\nexport default addPackageWebApi;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AAGA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAGA,IAAAM,QAAA,GAAAN,OAAA;AAGA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAA0C,SAAAD,uBAAAU,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEoB;;AAE9D,MAAMG,QAAQ,GAAGA,CAACC,KAAK,GAAG,KAAK,KAAK;EAClC,OAAOA,KAAK,KAAK,KAAK;AACxB,CAAC;AAED,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,2BAA2B,CAAC;AAErD,SAASC,gBAAgBA,CAACC,OAAgB,EAAEC,IAAU,EAAEC,MAAc,EAAU;EAC9E,MAAMC,cAAc,GAAGD,MAAM,EAAEE,GAAG,EAAEC,KAAK,KAAK,IAAI;EAClD,MAAMC,SAAS,GAAG,IAAAC,eAAM,EAAC,CAAC,CAAC,CAAC;EAC5B,MAAMC,mBAA+B,GAAG,IAAAC,iCAAyB,EAAC,CAAC;EAEnEZ,KAAK,CAAC,6BAA6B,CAAC;EACpC,MA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AAC,IAAAK,oBAAU,EAACD,IAAI,EAAE9D,KAAK,CAAC,CAAC;IAC/B,CAAC,CAAC,OAAOqD,KAAU,EAAE;MACnBK,IAAI,CAACL,KAAK,CAAC;IACb;EACF,CACF,CAAC;EAED,OAAO3C,SAAS;AAClB;AAAC,IAAAsD,QAAA,GAAAC,OAAA,CAAAnE,OAAA,GAEcK,gBAAgB","ignoreList":[]}
|
package/build/api/readme.d.ts
CHANGED
|
@@ -2,15 +2,7 @@ import { Router } from 'express';
|
|
|
2
2
|
import { Auth } from '@verdaccio/auth';
|
|
3
3
|
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '@verdaccio/middleware';
|
|
4
4
|
import { Storage } from '@verdaccio/store';
|
|
5
|
-
import { Manifest } from '@verdaccio/types';
|
|
6
|
-
import { AuthorAvatar } from '../web-utils';
|
|
7
5
|
export { $RequestExtend, $ResponseExtend, $NextFunctionVer };
|
|
8
|
-
export type PackageExt = Manifest & {
|
|
9
|
-
author: AuthorAvatar;
|
|
10
|
-
dist?: {
|
|
11
|
-
tarball: string;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
6
|
export declare const NOT_README_FOUND = "ERROR: No README data found!";
|
|
15
7
|
declare function addReadmeWebApi(storage: Storage, auth: Auth): Router;
|
|
16
8
|
export default addReadmeWebApi;
|
package/build/api/readme.js
CHANGED
|
@@ -27,15 +27,12 @@ var _express = require("express");
|
|
|
27
27
|
var _core = require("@verdaccio/core");
|
|
28
28
|
var _logger = require("@verdaccio/logger");
|
|
29
29
|
var _middleware = require("@verdaccio/middleware");
|
|
30
|
-
var _utils = require("@verdaccio/utils");
|
|
31
30
|
var _webUtils = require("../web-utils");
|
|
32
31
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
33
32
|
// Was required by other packages
|
|
34
33
|
|
|
35
34
|
// Was required by other packages
|
|
36
35
|
|
|
37
|
-
// TODO: review this type, should be on @verdacid/types
|
|
38
|
-
|
|
39
36
|
const NOT_README_FOUND = exports.NOT_README_FOUND = 'ERROR: No README data found!';
|
|
40
37
|
const debug = (0, _debug.default)('verdaccio:web:api:readme');
|
|
41
38
|
const getReadme = readme => {
|
|
@@ -51,11 +48,11 @@ const getReadme = readme => {
|
|
|
51
48
|
const getReadmeFromManifest = (manifest, v) => {
|
|
52
49
|
let id;
|
|
53
50
|
let readme;
|
|
54
|
-
if (typeof v === 'string' && (0,
|
|
51
|
+
if (typeof v === 'string' && (0, _webUtils.isVersionValid)(manifest, v)) {
|
|
55
52
|
id = 'version';
|
|
56
53
|
readme = manifest.versions[v].readme;
|
|
57
54
|
}
|
|
58
|
-
if (!readme && (0,
|
|
55
|
+
if (!readme && (0, _webUtils.isVersionValid)(manifest, manifest[_core.DIST_TAGS]?.latest)) {
|
|
59
56
|
id = 'latest';
|
|
60
57
|
readme = manifest.versions[manifest[_core.DIST_TAGS].latest].readme;
|
|
61
58
|
}
|
|
@@ -96,6 +93,7 @@ function addReadmeWebApi(storage, auth) {
|
|
|
96
93
|
});
|
|
97
94
|
debug('readme pkg %o', manifest?.name);
|
|
98
95
|
res.set(_core.HEADER_TYPE.CONTENT_TYPE, _core.HEADERS.TEXT_PLAIN_UTF8);
|
|
96
|
+
// TODO: sanitize query
|
|
99
97
|
const {
|
|
100
98
|
v
|
|
101
99
|
} = req.query;
|
package/build/api/readme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readme.js","names":["_debug","_interopRequireDefault","require","_express","_core","_logger","_middleware","
|
|
1
|
+
{"version":3,"file":"readme.js","names":["_debug","_interopRequireDefault","require","_express","_core","_logger","_middleware","_webUtils","e","__esModule","default","NOT_README_FOUND","exports","debug","buildDebug","getReadme","readme","length","getReadmeFromManifest","manifest","v","id","isVersionValid","versions","DIST_TAGS","latest","addReadmeWebApi","storage","auth","can","allow","beforeAll","a","b","logger","trace","afterAll","pkgRouter","Router","get","WebUrls","readme_package_scoped_version","readme_package_version","req","res","next","rawScope","params","scope","slice","name","addScope","package","requestOptions","protocol","headers","host","remoteAddress","socket","getPackageByOptions","uplinksLook","abbreviated","set","HEADER_TYPE","CONTENT_TYPE","HEADERS","TEXT_PLAIN_UTF8","query","err","_default"],"sources":["../../src/api/readme.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\n\nimport { Auth } from '@verdaccio/auth';\nimport { DIST_TAGS, HEADERS, HEADER_TYPE } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend, allow } from '@verdaccio/middleware';\n// Was required by other packages\nimport { WebUrls } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { Manifest } from '@verdaccio/types';\n\nimport { addScope, isVersionValid } from '../web-utils';\n\nexport { $RequestExtend, $ResponseExtend, $NextFunctionVer }; // Was required by other packages\n\nexport const NOT_README_FOUND = 'ERROR: No README data found!';\n\nconst debug = buildDebug('verdaccio:web:api:readme');\n\nconst getReadme = (readme) => {\n if (typeof readme === 'string' && readme.length === 0) {\n return NOT_README_FOUND;\n }\n if (typeof readme !== 'string') {\n return NOT_README_FOUND;\n } else {\n return readme;\n }\n};\n\nconst getReadmeFromManifest = (manifest: Manifest, v?: any): string | undefined => {\n let id;\n let readme;\n if (typeof v === 'string' && isVersionValid(manifest, v)) {\n id = 'version';\n readme = manifest.versions[v].readme;\n }\n if (!readme && isVersionValid(manifest, manifest[DIST_TAGS]?.latest)) {\n id = 'latest';\n readme = manifest.versions[manifest[DIST_TAGS].latest].readme;\n }\n if (!readme && manifest.readme) {\n id = 'root';\n readme = manifest.readme;\n }\n debug('readme: %o %o', v, id);\n return readme;\n};\n\nfunction addReadmeWebApi(storage: Storage, auth: Auth): Router {\n debug('initialized readme web api');\n const can = allow(auth, {\n beforeAll: (a, b) => logger.trace(a, b),\n afterAll: (a, b) => logger.trace(a, b),\n });\n const pkgRouter = Router(); /* eslint new-cap: 0 */\n\n pkgRouter.get(\n [WebUrls.readme_package_scoped_version, WebUrls.readme_package_version],\n can('access'),\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n debug('readme hit');\n const rawScope = req.params.scope; // May include '@'\n const scope = rawScope ? rawScope.slice(1) : null; // Remove '@' if present\n const name = scope ? addScope(scope, req.params.package) : req.params.package;\n debug('readme name %o', name);\n const requestOptions = {\n protocol: req.protocol,\n headers: req.headers as any,\n // FIXME: if we migrate to req.hostname, the port is not longer included.\n host: req.host,\n remoteAddress: req.socket.remoteAddress,\n };\n try {\n const manifest = (await storage.getPackageByOptions({\n name,\n uplinksLook: true,\n abbreviated: false,\n requestOptions,\n })) as Manifest;\n debug('readme pkg %o', manifest?.name);\n res.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_PLAIN_UTF8);\n // TODO: sanitize query\n const { v } = req.query;\n const readme = getReadmeFromManifest(manifest, v);\n next(getReadme(readme));\n } catch (err) {\n next(err);\n }\n }\n );\n return pkgRouter;\n}\n\nexport default addReadmeWebApi;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAGA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAMA,IAAAK,SAAA,GAAAL,OAAA;AAAwD,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AALxD;;AAO8D;;AAEvD,MAAMG,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,8BAA8B;AAE9D,MAAME,KAAK,GAAG,IAAAC,cAAU,EAAC,0BAA0B,CAAC;AAEpD,MAAMC,SAAS,GAAIC,MAAM,IAAK;EAC5B,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAIA,MAAM,CAACC,MAAM,KAAK,CAA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,CAAC,GAAGuB,GAAG,CAACwB,KAAK;MACvB,MAAMnD,MAAM,GAAGE,qBAAqB,CAACC,QAAQ,EAAEC,CAAC,CAAC;MACjDyB,IAAI,CAAC9B,SAAS,CAACC,MAAM,CAAC,CAAC;IACzB,CAAC,CAAC,OAAOoD,GAAG,EAAE;MACZvB,IAAI,CAACuB,GAAG,CAAC;IACX;EACF,CACF,CAAC;EACD,OAAO/B,SAAS;AAClB;AAAC,IAAAgC,QAAA,GAAAzD,OAAA,CAAAF,OAAA,GAEcgB,eAAe","ignoreList":[]}
|
package/build/api/sidebar.d.ts
CHANGED
|
@@ -2,17 +2,7 @@ import { Router } from 'express';
|
|
|
2
2
|
import { Auth } from '@verdaccio/auth';
|
|
3
3
|
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '@verdaccio/middleware';
|
|
4
4
|
import { Storage } from '@verdaccio/store';
|
|
5
|
-
import { Config
|
|
6
|
-
import { AuthorAvatar } from '../web-utils';
|
|
5
|
+
import { Config } from '@verdaccio/types';
|
|
7
6
|
export { $RequestExtend, $ResponseExtend, $NextFunctionVer };
|
|
8
|
-
export type PackageExt = Manifest & {
|
|
9
|
-
author: AuthorAvatar;
|
|
10
|
-
dist?: {
|
|
11
|
-
tarball: string;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export type $SidebarPackage = Manifest & {
|
|
15
|
-
latest: Version;
|
|
16
|
-
};
|
|
17
7
|
declare function addSidebarWebApi(config: Config, storage: Storage, auth: Auth): Router;
|
|
18
8
|
export default addSidebarWebApi;
|
package/build/api/sidebar.js
CHANGED
|
@@ -28,7 +28,7 @@ var _core = require("@verdaccio/core");
|
|
|
28
28
|
var _logger = require("@verdaccio/logger");
|
|
29
29
|
var _middleware = require("@verdaccio/middleware");
|
|
30
30
|
var _tarball = require("@verdaccio/tarball");
|
|
31
|
-
var
|
|
31
|
+
var _authorUtils = require("../author-utils");
|
|
32
32
|
var _webUtils = require("../web-utils");
|
|
33
33
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
34
34
|
// Was required by other packages
|
|
@@ -62,6 +62,7 @@ function addSidebarWebApi(config, storage, auth) {
|
|
|
62
62
|
keepUpLinkData: true,
|
|
63
63
|
requestOptions
|
|
64
64
|
});
|
|
65
|
+
// TODO: sanitize query
|
|
65
66
|
const {
|
|
66
67
|
v
|
|
67
68
|
} = req.query;
|
|
@@ -73,20 +74,15 @@ function addSidebarWebApi(config, storage, auth) {
|
|
|
73
74
|
headers: req.headers,
|
|
74
75
|
host: req.hostname
|
|
75
76
|
}, config.url_prefix).versions;
|
|
76
|
-
|
|
77
|
-
if (typeof v === 'string' && (0, _utils.isVersionValid)(info, v)) {
|
|
78
|
-
// @ts-ignore
|
|
77
|
+
if (typeof v === 'string' && (0, _webUtils.isVersionValid)(info, v)) {
|
|
79
78
|
sideBarInfo.latest = sideBarInfo.versions[v];
|
|
80
|
-
|
|
81
|
-
sideBarInfo.latest.author = (0, _utils.formatAuthor)(sideBarInfo.latest.author);
|
|
79
|
+
sideBarInfo.latest.author = (0, _authorUtils.formatAuthor)(sideBarInfo.latest.author);
|
|
82
80
|
} else {
|
|
83
|
-
// @ts-ignore
|
|
84
81
|
sideBarInfo.latest = sideBarInfo.versions[info[_core.DIST_TAGS].latest];
|
|
85
|
-
|
|
86
|
-
sideBarInfo.latest.author = (0, _utils.formatAuthor)(sideBarInfo.latest.author);
|
|
82
|
+
sideBarInfo.latest.author = (0, _authorUtils.formatAuthor)(sideBarInfo.latest.author);
|
|
87
83
|
}
|
|
88
84
|
sideBarInfo = (0, _webUtils.deleteProperties)(['readme', '_attachments', '_rev', 'name'], sideBarInfo);
|
|
89
|
-
const authorAvatar = config.web ? (0,
|
|
85
|
+
const authorAvatar = config.web ? (0, _authorUtils.addGravatarSupport)(sideBarInfo, config.web.gravatar) : (0, _authorUtils.addGravatarSupport)(sideBarInfo);
|
|
90
86
|
next(authorAvatar);
|
|
91
87
|
} catch (err) {
|
|
92
88
|
res.status(_core.HTTP_STATUS.NOT_FOUND);
|
package/build/api/sidebar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar.js","names":["_debug","_interopRequireDefault","require","_express","_core","_logger","_middleware","_tarball","
|
|
1
|
+
{"version":3,"file":"sidebar.js","names":["_debug","_interopRequireDefault","require","_express","_core","_logger","_middleware","_tarball","_authorUtils","_webUtils","e","__esModule","default","debug","buildDebug","addSidebarWebApi","config","storage","auth","router","Router","can","allow","beforeAll","a","b","logger","trace","afterAll","get","WebUrls","sidebar_scopped_package","sidebar_package","req","res","next","rawScope","params","scope","slice","name","addScope","package","requestOptions","protocol","headers","host","remoteAddress","socket","info","getPackageByOptions","uplinksLook","keepUpLinkData","v","query","sideBarInfo","versions","convertDistRemoteToLocalTarballUrls","hostname","url_prefix","isVersionValid","latest","author","formatAuthor","DIST_TAGS","deleteProperties","authorAvatar","web","addGravatarSupport","gravatar","err","status","HTTP_STATUS","NOT_FOUND","end","_default","exports"],"sources":["../../src/api/sidebar.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Router } from 'express';\n\nimport { Auth } from '@verdaccio/auth';\nimport { DIST_TAGS, HTTP_STATUS } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend, allow } from '@verdaccio/middleware';\n// Was required by other packages\nimport { WebUrls } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { convertDistRemoteToLocalTarballUrls } from '@verdaccio/tarball';\nimport { Config, Manifest, WebManifest } from '@verdaccio/types';\n\nimport { addGravatarSupport, formatAuthor } from '../author-utils';\nimport { addScope, deleteProperties, isVersionValid } from '../web-utils';\n\nexport { $RequestExtend, $ResponseExtend, $NextFunctionVer }; // Was required by other packages\n\nconst debug = buildDebug('verdaccio:web:api:sidebar');\n\nfunction addSidebarWebApi(config: Config, storage: Storage, auth: Auth): Router {\n debug('initialized sidebar web api');\n const router = Router(); /* eslint new-cap: 0 */\n const can = allow(auth, {\n beforeAll: (a, b) => logger.trace(a, b),\n afterAll: (a, b) => logger.trace(a, b),\n });\n // Get package sidebar\n router.get(\n [WebUrls.sidebar_scopped_package, WebUrls.sidebar_package],\n can('access'),\n async function (\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n ): Promise<void> {\n const rawScope = req.params.scope; // May include '@'\n const scope = rawScope ? rawScope.slice(1) : null; // Remove '@' if present\n const name: string = scope ? addScope(scope, req.params.package) : req.params.package;\n const requestOptions = {\n protocol: req.protocol,\n headers: req.headers as any,\n // FIXME: if we migrate to req.hostname, the port is not longer included.\n host: req.host,\n remoteAddress: req.socket.remoteAddress,\n };\n try {\n const info = (await storage.getPackageByOptions({\n name,\n uplinksLook: true,\n keepUpLinkData: true,\n requestOptions,\n })) as Manifest;\n // TODO: sanitize query\n const { v } = req.query;\n let sideBarInfo = { ...info } as WebManifest;\n sideBarInfo.versions = convertDistRemoteToLocalTarballUrls(\n info,\n { protocol: req.protocol, headers: req.headers as any, host: req.hostname },\n config.url_prefix\n ).versions;\n if (typeof v === 'string' && isVersionValid(info, v)) {\n sideBarInfo.latest = sideBarInfo.versions[v];\n sideBarInfo.latest.author = formatAuthor(sideBarInfo.latest.author);\n } else {\n sideBarInfo.latest = sideBarInfo.versions[info[DIST_TAGS].latest];\n sideBarInfo.latest.author = formatAuthor(sideBarInfo.latest.author);\n }\n sideBarInfo = deleteProperties(['readme', '_attachments', '_rev', 'name'], sideBarInfo);\n const authorAvatar = config.web\n ? addGravatarSupport(sideBarInfo, config.web.gravatar)\n : addGravatarSupport(sideBarInfo);\n next(authorAvatar);\n } catch (err) {\n res.status(HTTP_STATUS.NOT_FOUND);\n res.end();\n }\n }\n );\n\n return router;\n}\n\nexport default addSidebarWebApi;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAGA,IAAAE,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Y,EAACR,WAAW,CAACM,MAAM,CAACC,MAAM,CAAC;MACrE;MACAP,WAAW,GAAG,IAAAU,0BAAgB,EAAC,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAEV,WAAW,CAAC;MACvF,MAAMW,YAAY,GAAGlD,MAAM,CAACmD,GAAG,GAC3B,IAAAC,+BAAkB,EAACb,WAAW,EAAEvC,MAAM,CAACmD,GAAG,CAACE,QAAQ,CAAC,GACpD,IAAAD,+BAAkB,EAACb,WAAW,CAAC;MACnCpB,IAAI,CAAC+B,YAAY,CAAC;IACpB,CAAC,CAAC,OAAOI,GAAG,EAAE;MACZpC,GAAG,CAACqC,MAAM,CAACC,iBAAW,CAACC,SAAS,CAAC;MACjCvC,GAAG,CAACwC,GAAG,CAAC,CAAC;IACX;EACF,CACF,CAAC;EAED,OAAOvD,MAAM;AACf;AAAC,IAAAwD,QAAA,GAAAC,OAAA,CAAAhE,OAAA,GAEcG,gBAAgB","ignoreList":[]}
|
package/build/api/user.js
CHANGED
|
@@ -50,7 +50,7 @@ function addUserAuthApi(auth, config) {
|
|
|
50
50
|
const {
|
|
51
51
|
name
|
|
52
52
|
} = req.remote_user;
|
|
53
|
-
if (_core.validationUtils.validatePassword(password.new, config?.
|
|
53
|
+
if (_core.validationUtils.validatePassword(password.new, config?.server?.passwordValidationRegex) === false) {
|
|
54
54
|
return next(_core.errorUtils.getCode(_core.HTTP_STATUS.BAD_REQUEST, _core.APP_ERROR.PASSWORD_VALIDATION));
|
|
55
55
|
}
|
|
56
56
|
auth.changePassword(name, password.old, password.new, (err, isUpdated) => {
|
package/build/api/user.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","names":["_debug","_interopRequireDefault","require","_express","_lodash","_core","_middleware","e","__esModule","default","debug","buildDebug","addUserAuthApi","auth","config","route","Router","post","WebUrls","user_login","rateLimit","userRateLimit","req","res","next","username","password","body","authenticate","err","user","errorCode","message","HTTP_STATUS","UNAUTHORIZED","INTERNAL_ERROR","errorUtils","getCode","remote_user","jWTSignOptions","security","web","sign","set","HEADERS","CACHE_CONTROL","token","jwtEncrypt","name","flags","changePassword","put","reset_password","_","isNil","status","API_ERROR","MUST_BE_LOGGED","validationUtils","validatePassword","new","
|
|
1
|
+
{"version":3,"file":"user.js","names":["_debug","_interopRequireDefault","require","_express","_lodash","_core","_middleware","e","__esModule","default","debug","buildDebug","addUserAuthApi","auth","config","route","Router","post","WebUrls","user_login","rateLimit","userRateLimit","req","res","next","username","password","body","authenticate","err","user","errorCode","message","HTTP_STATUS","UNAUTHORIZED","INTERNAL_ERROR","errorUtils","getCode","remote_user","jWTSignOptions","security","web","sign","set","HEADERS","CACHE_CONTROL","token","jwtEncrypt","name","flags","changePassword","put","reset_password","_","isNil","status","API_ERROR","MUST_BE_LOGGED","validationUtils","validatePassword","new","server","passwordValidationRegex","BAD_REQUEST","APP_ERROR","PASSWORD_VALIDATION","old","isUpdated","ok","getInternalError","INTERNAL_SERVER_ERROR","_default","exports"],"sources":["../../src/api/user.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Request, Response, Router } from 'express';\nimport _ from 'lodash';\n\nimport { Auth } from '@verdaccio/auth';\nimport {\n API_ERROR,\n APP_ERROR,\n HEADERS,\n HTTP_STATUS,\n VerdaccioError,\n errorUtils,\n validationUtils,\n} from '@verdaccio/core';\nimport { rateLimit } from '@verdaccio/middleware';\nimport { WebUrls } from '@verdaccio/middleware';\nimport { Config, JWTSignOptions, RemoteUser } from '@verdaccio/types';\n\nimport { $NextFunctionVer } from './package';\n\nconst debug = buildDebug('verdaccio:web:api:user');\n\nfunction addUserAuthApi(auth: Auth, config: Config): Router {\n const route = Router(); /* eslint new-cap: 0 */\n route.post(\n WebUrls.user_login,\n rateLimit(config?.userRateLimit),\n function (req: Request, res: Response, next: $NextFunctionVer): void {\n const { username, password } = req.body;\n debug('authenticate %o', username);\n auth.authenticate(\n username,\n password,\n async (err: VerdaccioError | null, user?: RemoteUser): Promise<void> => {\n if (err) {\n const errorCode = err.message ? HTTP_STATUS.UNAUTHORIZED : HTTP_STATUS.INTERNAL_ERROR;\n debug('error authenticate %o', errorCode);\n next(errorUtils.getCode(errorCode, err.message));\n } else {\n req.remote_user = user as RemoteUser;\n const jWTSignOptions: JWTSignOptions = config.security.web.sign;\n res.set(HEADERS.CACHE_CONTROL, 'no-cache, no-store');\n next({\n token: await auth.jwtEncrypt(user as RemoteUser, jWTSignOptions),\n username: req.remote_user.name,\n });\n }\n }\n );\n }\n );\n\n if (config?.flags?.changePassword === true) {\n route.put(\n WebUrls.reset_password,\n rateLimit(config?.userRateLimit),\n function (req: Request, res: Response, next: $NextFunctionVer): void {\n if (_.isNil(req.remote_user.name)) {\n res.status(HTTP_STATUS.UNAUTHORIZED);\n return next({\n // FUTURE: update to a more meaningful message\n message: API_ERROR.MUST_BE_LOGGED,\n });\n }\n\n const { password } = req.body;\n const { name } = req.remote_user;\n\n if (\n validationUtils.validatePassword(\n password.new,\n config?.server?.passwordValidationRegex\n ) === false\n ) {\n return next(errorUtils.getCode(HTTP_STATUS.BAD_REQUEST, APP_ERROR.PASSWORD_VALIDATION));\n }\n\n auth.changePassword(name as string, password.old, password.new, (err, isUpdated): void => {\n if (_.isNil(err) && isUpdated) {\n next({\n ok: true,\n });\n } else {\n return next(errorUtils.getInternalError(API_ERROR.INTERNAL_SERVER_ERROR));\n }\n });\n }\n );\n }\n\n return route;\n}\n\nexport default addUserAuthApi;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AAGA,IAAAG,KAAA,GAAAH,OAAA;AASA,IAAAI,WAAA,GAAAJ,OAAA;AAAkD,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;A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AAOvD,KAAK;AACd;AAAC,IAAAwD,QAAA,GAAAC,OAAA,CAAA/D,OAAA,GAEcG,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Author, Person, WebManifest } from '@verdaccio/types';
|
|
2
|
+
export declare const GENERIC_AVATAR: string;
|
|
3
|
+
/**
|
|
4
|
+
* Formats author field for webui.
|
|
5
|
+
* @see https://docs.npmjs.com/files/package.json#author
|
|
6
|
+
* @param {string|object|undefined} author
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatAuthor(author?: Person): any;
|
|
9
|
+
export declare function addGravatarSupport(pkgInfo: WebManifest, online?: boolean): Author;
|
|
10
|
+
/**
|
|
11
|
+
* Generate gravatar url from email address
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateGravatarUrl(email?: string | void, online?: boolean): string;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GENERIC_AVATAR = void 0;
|
|
7
|
+
exports.addGravatarSupport = addGravatarSupport;
|
|
8
|
+
exports.formatAuthor = formatAuthor;
|
|
9
|
+
exports.generateGravatarUrl = generateGravatarUrl;
|
|
10
|
+
var _core = require("@verdaccio/core");
|
|
11
|
+
const AVATAR_PROVIDER = 'https://www.gravatar.com/avatar/';
|
|
12
|
+
const GENERIC_AVATAR = exports.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>');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Formats author field for webui.
|
|
16
|
+
* @see https://docs.npmjs.com/files/package.json#author
|
|
17
|
+
* @param {string|object|undefined} author
|
|
18
|
+
*/
|
|
19
|
+
function formatAuthor(author) {
|
|
20
|
+
let authorDetails = {
|
|
21
|
+
name: _core.DEFAULT_USER,
|
|
22
|
+
email: '',
|
|
23
|
+
url: ''
|
|
24
|
+
};
|
|
25
|
+
if (author === null || author === undefined) {
|
|
26
|
+
return authorDetails;
|
|
27
|
+
}
|
|
28
|
+
if (typeof author === 'string') {
|
|
29
|
+
authorDetails = {
|
|
30
|
+
...authorDetails,
|
|
31
|
+
name: author
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (typeof author === 'object') {
|
|
35
|
+
authorDetails = {
|
|
36
|
+
...authorDetails,
|
|
37
|
+
...author
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return authorDetails;
|
|
41
|
+
}
|
|
42
|
+
function addGravatarSupport(pkgInfo, online = true) {
|
|
43
|
+
const pkgInfoCopy = {
|
|
44
|
+
...pkgInfo
|
|
45
|
+
};
|
|
46
|
+
const author = pkgInfo?.latest?.author ?? null;
|
|
47
|
+
const contributors = normalizeAuthors(pkgInfo?.latest?.contributors ?? []);
|
|
48
|
+
const maintainers = normalizeAuthors(pkgInfo?.latest?.maintainers ?? []);
|
|
49
|
+
|
|
50
|
+
// for author
|
|
51
|
+
if (author && typeof author === 'object') {
|
|
52
|
+
const {
|
|
53
|
+
email
|
|
54
|
+
} = author;
|
|
55
|
+
pkgInfoCopy.latest.author._avatar = generateGravatarUrl(email, online);
|
|
56
|
+
} else if (author && typeof author === 'string') {
|
|
57
|
+
const {
|
|
58
|
+
email,
|
|
59
|
+
name,
|
|
60
|
+
url
|
|
61
|
+
} = splitAuthorString(author);
|
|
62
|
+
pkgInfoCopy.latest.author = {
|
|
63
|
+
_avatar: generateGravatarUrl(email, online),
|
|
64
|
+
email,
|
|
65
|
+
name,
|
|
66
|
+
url
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// for contributors
|
|
71
|
+
if (contributors && contributors.length > 0) {
|
|
72
|
+
pkgInfoCopy.latest.contributors = contributors.map(contributor => {
|
|
73
|
+
if (typeof contributor === 'object') {
|
|
74
|
+
contributor._avatar = generateGravatarUrl(contributor.email, online);
|
|
75
|
+
} else if (typeof contributor === 'string') {
|
|
76
|
+
const {
|
|
77
|
+
email,
|
|
78
|
+
name,
|
|
79
|
+
url
|
|
80
|
+
} = splitAuthorString(contributor);
|
|
81
|
+
contributor = {
|
|
82
|
+
_avatar: generateGravatarUrl(email, online),
|
|
83
|
+
email,
|
|
84
|
+
name,
|
|
85
|
+
url
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return contributor;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// for maintainers
|
|
93
|
+
if (maintainers && maintainers.length > 0) {
|
|
94
|
+
pkgInfoCopy.latest.maintainers = maintainers.map(maintainer => {
|
|
95
|
+
if (typeof maintainer === 'object') {
|
|
96
|
+
maintainer._avatar = generateGravatarUrl(maintainer.email, online);
|
|
97
|
+
} else if (typeof maintainer === 'string') {
|
|
98
|
+
const {
|
|
99
|
+
email,
|
|
100
|
+
name,
|
|
101
|
+
url
|
|
102
|
+
} = splitAuthorString(maintainer);
|
|
103
|
+
maintainer = {
|
|
104
|
+
_avatar: generateGravatarUrl(email, online),
|
|
105
|
+
email,
|
|
106
|
+
name,
|
|
107
|
+
url
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return maintainer;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return pkgInfoCopy;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Generate gravatar url from email address
|
|
118
|
+
*/
|
|
119
|
+
function generateGravatarUrl(email = '', online = true) {
|
|
120
|
+
if (online && typeof email === 'string' && email.length > 0) {
|
|
121
|
+
email = email.trim().toLocaleLowerCase();
|
|
122
|
+
const emailMD5 = _core.cryptoUtils.stringToMD5(email);
|
|
123
|
+
return `${AVATAR_PROVIDER}${emailMD5}`;
|
|
124
|
+
}
|
|
125
|
+
return GENERIC_AVATAR;
|
|
126
|
+
}
|
|
127
|
+
function normalizeAuthors(authors) {
|
|
128
|
+
if (authors === null || authors === undefined) {
|
|
129
|
+
return [];
|
|
130
|
+
} else if (authors && !Array.isArray(authors)) {
|
|
131
|
+
return [authors];
|
|
132
|
+
} else if (typeof authors === 'string') {
|
|
133
|
+
return [{
|
|
134
|
+
name: authors
|
|
135
|
+
}];
|
|
136
|
+
}
|
|
137
|
+
return authors;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Split author string into name, email and url
|
|
142
|
+
* Example: "Barney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)"
|
|
143
|
+
* @param {string} author
|
|
144
|
+
* @returns {Object} { name: string, email: string, url: string }
|
|
145
|
+
*/
|
|
146
|
+
function splitAuthorString(author) {
|
|
147
|
+
// Limit author string length to prevent ReDoS
|
|
148
|
+
const maxLength = 256;
|
|
149
|
+
const truncatedAuthor = author.slice(0, maxLength);
|
|
150
|
+
|
|
151
|
+
// Split on fixed delimiters rather than using regex
|
|
152
|
+
const emailStart = truncatedAuthor.indexOf('<');
|
|
153
|
+
const emailEnd = truncatedAuthor.indexOf('>');
|
|
154
|
+
const urlStart = truncatedAuthor.indexOf('(');
|
|
155
|
+
const urlEnd = truncatedAuthor.indexOf(')');
|
|
156
|
+
let name = truncatedAuthor;
|
|
157
|
+
let email = '';
|
|
158
|
+
let url = '';
|
|
159
|
+
if (emailStart >= 0 && emailEnd > emailStart) {
|
|
160
|
+
name = truncatedAuthor.slice(0, emailStart).trim();
|
|
161
|
+
email = truncatedAuthor.slice(emailStart + 1, emailEnd).trim();
|
|
162
|
+
}
|
|
163
|
+
if (urlStart >= 0 && urlEnd > urlStart) {
|
|
164
|
+
url = truncatedAuthor.slice(urlStart + 1, urlEnd).trim();
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
name: name || author,
|
|
168
|
+
email,
|
|
169
|
+
url
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=author-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"author-utils.js","names":["_core","require","AVATAR_PROVIDER","GENERIC_AVATAR","exports","encodeURIComponent","formatAuthor","author","authorDetails","name","DEFAULT_USER","email","url","undefined","addGravatarSupport","pkgInfo","online","pkgInfoCopy","latest","contributors","normalizeAuthors","maintainers","_avatar","generateGravatarUrl","splitAuthorString","length","map","contributor","maintainer","trim","toLocaleLowerCase","emailMD5","cryptoUtils","stringToMD5","authors","Array","isArray","maxLength","truncatedAuthor","slice","emailStart","indexOf","emailEnd","urlStart","urlEnd"],"sources":["../src/author-utils.ts"],"sourcesContent":["import { DEFAULT_USER, cryptoUtils } from '@verdaccio/core';\nimport { Author, Person, WebManifest } from '@verdaccio/types';\n\nconst AVATAR_PROVIDER = 'https://www.gravatar.com/avatar/';\n\nexport const GENERIC_AVATAR =\n 'data:image/svg+xml;utf8,' +\n encodeURIComponent(\n '<svg height=\"100\" viewBox=\"-27 24 100 100\" width=\"100\" xmlns=\"http://www.w3.org/' +\n '2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs><circle cx=\"23\" cy=\"7' +\n '4\" id=\"a\" r=\"50\"/></defs><use fill=\"#F5EEE5\" overflow=\"visible\" xlink:href=\"#a\"/' +\n '><clipPath id=\"b\"><use overflow=\"visible\" xlink:href=\"#a\"/></clipPath><g clip-pa' +\n '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' +\n ' 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-' +\n '5.9 2.4-.6 7.1-1.8 7.1-5.8V85h26v10.9z\" id=\"c\"/></defs><use fill=\"#E6C19C\" overf' +\n 'low=\"visible\" xlink:href=\"#c\"/><clipPath id=\"d\"><use overflow=\"visible\" xlink:hr' +\n 'ef=\"#c\"/></clipPath><path clip-path=\"url(#d)\" d=\"M23.2 35h.2c3.3 0 8.2.2 11.4 2 ' +\n '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-.' +\n '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' +\n '-1.8 8.1-2 11.4-2h.2z\" fill=\"#D4B08C\"/></g><path d=\"M22.6 40c19.1 0 20.7 13.8 20' +\n '.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' +\n '-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>'\n );\n\n/**\n * Formats author field for webui.\n * @see https://docs.npmjs.com/files/package.json#author\n * @param {string|object|undefined} author\n */\nexport function formatAuthor(author?: Person): any {\n let authorDetails = {\n name: DEFAULT_USER,\n email: '',\n url: '',\n };\n\n if (author === null || author === undefined) {\n return authorDetails;\n }\n\n if (typeof author === 'string') {\n authorDetails = {\n ...authorDetails,\n name: author as string,\n };\n }\n\n if (typeof author === 'object') {\n authorDetails = {\n ...authorDetails,\n ...(author as Author),\n };\n }\n\n return authorDetails;\n}\n\nexport function addGravatarSupport(pkgInfo: WebManifest, online: boolean = true): Author {\n const pkgInfoCopy = { ...pkgInfo } as any;\n const author: any = pkgInfo?.latest?.author ?? null;\n const contributors: Person[] = normalizeAuthors(pkgInfo?.latest?.contributors ?? []);\n const maintainers: Person[] = normalizeAuthors(pkgInfo?.latest?.maintainers ?? []);\n\n // for author\n if (author && typeof author === 'object') {\n const { email } = author as Author;\n pkgInfoCopy.latest.author._avatar = generateGravatarUrl(email, online);\n } else if (author && typeof author === 'string') {\n const { email, name, url } = splitAuthorString(author);\n pkgInfoCopy.latest.author = {\n _avatar: generateGravatarUrl(email, online),\n email,\n name,\n url,\n };\n }\n\n // for contributors\n if (contributors && contributors.length > 0) {\n pkgInfoCopy.latest.contributors = contributors.map((contributor): Person => {\n if (typeof contributor === 'object') {\n contributor._avatar = generateGravatarUrl(contributor.email, online);\n } else if (typeof contributor === 'string') {\n const { email, name, url } = splitAuthorString(contributor);\n contributor = {\n _avatar: generateGravatarUrl(email, online),\n email,\n name,\n url,\n };\n }\n\n return contributor;\n });\n }\n\n // for maintainers\n if (maintainers && maintainers.length > 0) {\n pkgInfoCopy.latest.maintainers = maintainers.map((maintainer): Person => {\n if (typeof maintainer === 'object') {\n maintainer._avatar = generateGravatarUrl(maintainer.email, online);\n } else if (typeof maintainer === 'string') {\n const { email, name, url } = splitAuthorString(maintainer);\n maintainer = {\n _avatar: generateGravatarUrl(email, online),\n email,\n name,\n url,\n };\n }\n\n return maintainer;\n });\n }\n\n return pkgInfoCopy;\n}\n\n/**\n * Generate gravatar url from email address\n */\nexport function generateGravatarUrl(email: string | void = '', online: boolean = true): string {\n if (online && typeof email === 'string' && email.length > 0) {\n email = email.trim().toLocaleLowerCase();\n const emailMD5 = cryptoUtils.stringToMD5(email);\n return `${AVATAR_PROVIDER}${emailMD5}`;\n }\n return GENERIC_AVATAR;\n}\n\nfunction normalizeAuthors(authors: Person[]): Person[] {\n if (authors === null || authors === undefined) {\n return [];\n } else if (authors && !Array.isArray(authors)) {\n return [authors];\n } else if (typeof authors === 'string') {\n return [\n {\n name: authors,\n },\n ];\n }\n\n return authors;\n}\n\n/**\n * Split author string into name, email and url\n * Example: \"Barney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)\"\n * @param {string} author\n * @returns {Object} { name: string, email: string, url: string }\n */\nfunction splitAuthorString(author: string): { name: string; email?: string; url: string } {\n // Limit author string length to prevent ReDoS\n const maxLength = 256;\n const truncatedAuthor = author.slice(0, maxLength);\n\n // Split on fixed delimiters rather than using regex\n const emailStart = truncatedAuthor.indexOf('<');\n const emailEnd = truncatedAuthor.indexOf('>');\n const urlStart = truncatedAuthor.indexOf('(');\n const urlEnd = truncatedAuthor.indexOf(')');\n\n let name = truncatedAuthor;\n let email = '';\n let url = '';\n\n if (emailStart >= 0 && emailEnd > emailStart) {\n name = truncatedAuthor.slice(0, emailStart).trim();\n email = truncatedAuthor.slice(emailStart + 1, emailEnd).trim();\n }\n\n if (urlStart >= 0 && urlEnd > urlStart) {\n url = truncatedAuthor.slice(urlStart + 1, urlEnd).trim();\n }\n\n return {\n name: name || author,\n email,\n url,\n };\n}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[]}
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
-
PLUGIN_UI_PREFIX: true,
|
|
8
7
|
DEFAULT_PLUGIN_UI_THEME: true
|
|
9
8
|
};
|
|
10
9
|
Object.defineProperty(exports, "DEFAULT_PLUGIN_UI_THEME", {
|
|
@@ -13,12 +12,6 @@ Object.defineProperty(exports, "DEFAULT_PLUGIN_UI_THEME", {
|
|
|
13
12
|
return _middleware.DEFAULT_PLUGIN_UI_THEME;
|
|
14
13
|
}
|
|
15
14
|
});
|
|
16
|
-
Object.defineProperty(exports, "PLUGIN_UI_PREFIX", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () {
|
|
19
|
-
return _middleware.PLUGIN_UI_PREFIX;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
15
|
Object.defineProperty(exports, "default", {
|
|
23
16
|
enumerable: true,
|
|
24
17
|
get: function () {
|
|
@@ -26,6 +19,18 @@ Object.defineProperty(exports, "default", {
|
|
|
26
19
|
}
|
|
27
20
|
});
|
|
28
21
|
var _middleware = _interopRequireWildcard(require("./middleware"));
|
|
22
|
+
var _authorUtils = require("./author-utils");
|
|
23
|
+
Object.keys(_authorUtils).forEach(function (key) {
|
|
24
|
+
if (key === "default" || key === "__esModule") return;
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
26
|
+
if (key in exports && exports[key] === _authorUtils[key]) return;
|
|
27
|
+
Object.defineProperty(exports, key, {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () {
|
|
30
|
+
return _authorUtils[key];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
29
34
|
var _webUtils = require("./web-utils");
|
|
30
35
|
Object.keys(_webUtils).forEach(function (key) {
|
|
31
36
|
if (key === "default" || key === "__esModule") return;
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_middleware","_interopRequireWildcard","require","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_middleware","_interopRequireWildcard","require","_authorUtils","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_webUtils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set"],"sources":["../src/index.ts"],"sourcesContent":["export { default, DEFAULT_PLUGIN_UI_THEME } from './middleware';\nexport * from './author-utils';\nexport * from './web-utils';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,YAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,YAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,YAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,SAAA,GAAAd,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAW,SAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,SAAA,CAAAT,GAAA;EA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
|
package/build/middleware.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare const PLUGIN_UI_PREFIX = "verdaccio-theme";
|
|
2
1
|
export declare const DEFAULT_PLUGIN_UI_THEME = "@verdaccio/ui-theme";
|
|
3
2
|
export declare function loadTheme(config: any): Promise<any>;
|
|
4
3
|
declare const _default: (config: any, auth: any, storage: any, logger: any) => Promise<import("express-serve-static-core").Router>;
|
package/build/middleware.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.
|
|
6
|
+
exports.default = exports.DEFAULT_PLUGIN_UI_THEME = void 0;
|
|
7
7
|
exports.loadTheme = loadTheme;
|
|
8
8
|
var _express = _interopRequireDefault(require("express"));
|
|
9
9
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
@@ -13,7 +13,6 @@ var _logger = require("@verdaccio/logger");
|
|
|
13
13
|
var _middleware = require("@verdaccio/middleware");
|
|
14
14
|
var _api = _interopRequireDefault(require("./api"));
|
|
15
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
-
const PLUGIN_UI_PREFIX = exports.PLUGIN_UI_PREFIX = 'verdaccio-theme';
|
|
17
16
|
const DEFAULT_PLUGIN_UI_THEME = exports.DEFAULT_PLUGIN_UI_THEME = '@verdaccio/ui-theme';
|
|
18
17
|
async function loadTheme(config) {
|
|
19
18
|
if (_lodash.default.isNil(config.theme) === false) {
|
|
@@ -30,7 +29,7 @@ async function loadTheme(config) {
|
|
|
30
29
|
- `manifestFiles`: A object with one property `js` and the array (order matters) of the manifest id to be loaded in the template dynamically.
|
|
31
30
|
*/
|
|
32
31
|
return plugin.staticPath && plugin.manifest && plugin.manifestFiles;
|
|
33
|
-
}, false, config?.
|
|
32
|
+
}, false, config.server?.pluginPrefix ?? _core.PLUGIN_UI_PREFIX, _core.PLUGIN_CATEGORY.THEME);
|
|
34
33
|
if (plugin.length > 1) {
|
|
35
34
|
_logger.logger.warn('multiple ui themes are not supported; only the first plugin is used');
|
|
36
35
|
}
|
package/build/middleware.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","names":["_express","_interopRequireDefault","require","_lodash","_core","_loaders","_logger","_middleware","_api","e","__esModule","default","
|
|
1
|
+
{"version":3,"file":"middleware.js","names":["_express","_interopRequireDefault","require","_lodash","_core","_loaders","_logger","_middleware","_api","e","__esModule","default","DEFAULT_PLUGIN_UI_THEME","exports","loadTheme","config","_","isNil","theme","plugin","asyncLoadPlugin","logger","staticPath","manifest","manifestFiles","server","pluginPrefix","PLUGIN_UI_PREFIX","PLUGIN_CATEGORY","THEME","length","warn","head","_default","auth","storage","pluginOptions","web","info","name","pluginCategory","router","express","Router","use","webMiddleware","tokenMiddleware","webUIJWTmiddleware","webEndpointsApi"],"sources":["../src/middleware.ts"],"sourcesContent":["import express from 'express';\nimport _ from 'lodash';\n\nimport { PLUGIN_CATEGORY, PLUGIN_UI_PREFIX } from '@verdaccio/core';\nimport { asyncLoadPlugin } from '@verdaccio/loaders';\nimport { logger } from '@verdaccio/logger';\nimport { webMiddleware } from '@verdaccio/middleware';\n\nimport webEndpointsApi from './api';\n\nexport const DEFAULT_PLUGIN_UI_THEME = '@verdaccio/ui-theme';\n\nexport async function loadTheme(config: any) {\n if (_.isNil(config.theme) === false) {\n const plugin = await asyncLoadPlugin(\n config.theme,\n { config, logger },\n // TODO: add types { staticPath: string; manifest: unknown; manifestFiles: unknown }\n function (plugin: any) {\n /**\n *\n - `staticPath`: is the same data returned in Verdaccio 5.\n - `manifest`: A webpack manifest object.\n - `manifestFiles`: A object with one property `js` and the array (order matters) of the manifest id to be loaded in the template dynamically.\n */\n return plugin.staticPath && plugin.manifest && plugin.manifestFiles;\n },\n false,\n config.server?.pluginPrefix ?? PLUGIN_UI_PREFIX,\n PLUGIN_CATEGORY.THEME\n );\n if (plugin.length > 1) {\n logger.warn('multiple ui themes are not supported; only the first plugin is used');\n }\n\n return _.head(plugin);\n }\n}\n\nexport default async (config, auth, storage, logger) => {\n let pluginOptions = await loadTheme(config);\n if (!pluginOptions) {\n pluginOptions = require(DEFAULT_PLUGIN_UI_THEME)(config.web);\n logger.info(\n { name: DEFAULT_PLUGIN_UI_THEME, pluginCategory: PLUGIN_CATEGORY.THEME },\n 'plugin @{name} successfully loaded (@{pluginCategory})'\n );\n }\n\n // eslint-disable-next-line new-cap\n const router = express.Router();\n // load application\n router.use(\n webMiddleware(\n config,\n {\n tokenMiddleware: auth.webUIJWTmiddleware(),\n webEndpointsApi: webEndpointsApi(auth, storage, config),\n },\n pluginOptions\n )\n );\n return router;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAEA,IAAAM,IAAA,GAAAP,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE7B,MAAMG,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,qBAAqB;AAErD,eAAeE,SAASA,CAACC,MAAW,EAAE;EAC3C,IAAIC,eAAC,CAACC,KAAK,CAACF,MAAM,CAACG,KAAK,CAAC,KAAK,KAAK,EAAE;IACnC,MAAMC,MAAM,GAAG,MAAM,IAAAC,wBAAe,EAClCL,MAAM,CAACG,KAAK,EACZ;MAAEH,MAAM;MAAEM,MAAM,EAANA;IAAO,CAAC;IAClB;IACA,UAAUF,MAAW,EAAE;MACrB;AACR;AACA;AACA;AACA;AACA;MACQ,OAAOA,MAAM,CAACG,UAAU,IAAIH,MAAM,CAACI,QAAQ,IAAIJ,MAAM,CAACK,aAAa;IACrE,CAAC,EACD,KAAK,EACLT,MAAM,CAACU,MAAM,EAAEC,YAAY,IAAIC,sBAAgB,EAC/CC,qBAAe,CAACC,KAClB,CAAC;IACD,IAAIV,MAAM,CAACW,MAAM,GAAG,CAAC,EAAE;MACrBT,cAAM,CAACU,IAAI,CAAC,qEAAqE,CAAC;IACpF;IAEA,OAAOf,eAAC,CAACgB,IAAI,CAACb,MAAM,CAAC;EACvB;AACF;AAAC,IAAAc,QAAA,GAEc,MAAAA,CAAOlB,MAAM,EAAEmB,IAAI,EAAEC,OAAO,EAAEd,MAAM,KAAK;EACtD,IAAIe,aAAa,GAAG,MAAMtB,SAAS,CAACC,MAAM,CAAC;EAC3C,IAAI,CAACqB,aAAa,EAAE;IAClBA,aAAa,GAAGlC,OAAO,CAACU,uBAAuB,CAAC,CAACG,MAAM,CAACsB,GAAG,CAAC;IAC5DhB,MAAM,CAACiB,IAAI,CACT;MAAEC,IAAI,EAAE3B,uBAAuB;MAAE4B,cAAc,EAAEZ,qBAAe,CAACC;IAAM,CAAC,EACxE,wDACF,CAAC;EACH;;EAEA;EACA,MAAMY,MAAM,GAAGC,gBAAO,CAACC,MAAM,CAAC,CAAC;EAC/B;EACAF,MAAM,CAACG,GAAG,CACR,IAAAC,yBAAa,EACX9B,MAAM,EACN;IACE+B,eAAe,EAAEZ,IAAI,CAACa,kBAAkB,CAAC,CAAC;IAC1CC,eAAe,EAAE,IAAAA,YAAe,EAACd,IAAI,EAAEC,OAAO,EAAEpB,MAAM;EACxD,CAAC,EACDqB,aACF,CACF,CAAC;EACD,OAAOK,MAAM;AACf,CAAC;AAAA5B,OAAA,CAAAF,OAAA,GAAAsB,QAAA","ignoreList":[]}
|
package/build/web-utils.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConfigYaml, Manifest } from '@verdaccio/types';
|
|
2
2
|
export declare function hasLogin(config: ConfigYaml): boolean;
|
|
3
3
|
export declare function sortByName(packages: any[], orderAscending?: boolean | void): string[];
|
|
4
|
-
export type AuthorAvatar = Author & {
|
|
5
|
-
avatar?: string;
|
|
6
|
-
};
|
|
7
4
|
export declare function addScope(scope: string, packageName: string): string;
|
|
8
5
|
export declare function deleteProperties(propertiesToDelete: string[], objectItem: any): any;
|
|
6
|
+
export declare function isVersionValid(packageMeta: Manifest, packageVersion: string): boolean;
|
package/build/web-utils.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.addScope = addScope;
|
|
7
7
|
exports.deleteProperties = deleteProperties;
|
|
8
8
|
exports.hasLogin = hasLogin;
|
|
9
|
+
exports.isVersionValid = isVersionValid;
|
|
9
10
|
exports.sortByName = sortByName;
|
|
10
11
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -27,4 +28,12 @@ function deleteProperties(propertiesToDelete, objectItem) {
|
|
|
27
28
|
});
|
|
28
29
|
return objectItem;
|
|
29
30
|
}
|
|
31
|
+
function isVersionValid(packageMeta, packageVersion) {
|
|
32
|
+
const hasVersion = typeof packageVersion !== 'undefined';
|
|
33
|
+
if (!hasVersion) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const hasMatchVersion = Object.keys(packageMeta.versions).includes(packageVersion);
|
|
37
|
+
return hasMatchVersion;
|
|
38
|
+
}
|
|
30
39
|
//# sourceMappingURL=web-utils.js.map
|
package/build/web-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-utils.js","names":["_lodash","_interopRequireDefault","require","e","__esModule","default","hasLogin","config","_","isNil","web","login","sortByName","packages","orderAscending","slice","sort","a","b","comparatorNames","name","toLowerCase","addScope","scope","packageName","deleteProperties","propertiesToDelete","objectItem","forEach","property"],"sources":["../src/web-utils.ts"],"sourcesContent":["import _ from 'lodash';\n\nimport {
|
|
1
|
+
{"version":3,"file":"web-utils.js","names":["_lodash","_interopRequireDefault","require","e","__esModule","default","hasLogin","config","_","isNil","web","login","sortByName","packages","orderAscending","slice","sort","a","b","comparatorNames","name","toLowerCase","addScope","scope","packageName","deleteProperties","propertiesToDelete","objectItem","forEach","property","isVersionValid","packageMeta","packageVersion","hasVersion","hasMatchVersion","Object","keys","versions","includes"],"sources":["../src/web-utils.ts"],"sourcesContent":["import _ from 'lodash';\n\nimport { ConfigYaml, Manifest } from '@verdaccio/types';\n\nexport function hasLogin(config: ConfigYaml) {\n return _.isNil(config?.web?.login) || config?.web?.login === true;\n}\n\nexport function sortByName(packages: any[], orderAscending: boolean | void = true): string[] {\n return packages.slice().sort(function (a, b): number {\n const comparatorNames = a.name.toLowerCase() < b.name.toLowerCase();\n return orderAscending ? (comparatorNames ? -1 : 1) : comparatorNames ? 1 : -1;\n });\n}\n\nexport function addScope(scope: string, packageName: string): string {\n return `@${scope}/${packageName}`;\n}\n\nexport function deleteProperties(propertiesToDelete: string[], objectItem: any): any {\n _.forEach(propertiesToDelete, (property): any => {\n delete objectItem[property];\n });\n\n return objectItem;\n}\n\nexport function isVersionValid(packageMeta: Manifest, packageVersion: string): boolean {\n const hasVersion = typeof packageVersion !== 'undefined';\n if (!hasVersion) {\n return false;\n }\n\n const hasMatchVersion = Object.keys(packageMeta.versions).includes(packageVersion);\n return hasMatchVersion;\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuB,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIhB,SAASG,QAAQA,CAACC,MAAkB,EAAE;EAC3C,OAAOC,eAAC,CAACC,KAAK,CAACF,MAAM,EAAEG,GAAG,EAAEC,KAAK,CAAC,IAAIJ,MAAM,EAAEG,GAAG,EAAEC,KAAK,KAAK,IAAI;AACnE;AAEO,SAASC,UAAUA,CAACC,QAAe,EAAEC,cAA8B,GAAG,IAAI,EAAY;EAC3F,OAAOD,QAAQ,CAACE,KAAK,CAAC,CAAC,CAACC,IAAI,CAAC,UAAUC,CAAC,EAAEC,CAAC,EAAU;IACnD,MAAMC,eAAe,GAAGF,CAAC,CAACG,IAAI,CAACC,WAAW,CAAC,CAAC,GAAGH,CAAC,CAACE,IAAI,CAACC,WAAW,CAAC,CAAC;IACnE,OAAOP,cAAc,GAAIK,eAAe,GAAG,CAAC,CAAC,GAAG,CAAC,GAAIA,eAAe,GAAG,CAAC,GAAG,CAAC,CAAC;EAC/E,CAAC,CAAC;AACJ;AAEO,SAASG,QAAQA,CAACC,KAAa,EAAEC,WAAmB,EAAU;EACnE,OAAO,IAAID,KAAK,IAAIC,WAAW,EAAE;AACnC;AAEO,SAASC,gBAAgBA,CAACC,kBAA4B,EAAEC,UAAe,EAAO;EACnFnB,eAAC,CAACoB,OAAO,CAACF,kBAAkB,EAAGG,QAAQ,IAAU;IAC/C,OAAOF,UAAU,CAACE,QAAQ,CAAC;EAC7B,CAAC,CAAC;EAEF,OAAOF,UAAU;AACnB;AAEO,SAASG,cAAcA,CAACC,WAAqB,EAAEC,cAAsB,EAAW;EACrF,MAAMC,UAAU,GAAG,OAAOD,cAAc,KAAK,WAAW;EACxD,IAAI,CAACC,UAAU,EAAE;IACf,OAAO,KAAK;EACd;EAEA,MAAMC,eAAe,GAAGC,MAAM,CAACC,IAAI,CAACL,WAAW,CAACM,QAAQ,CAAC,CAACC,QAAQ,CAACN,cAAc,CAAC;EAClF,OAAOE,eAAe;AACxB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/web",
|
|
3
|
-
"version": "8.1.0-next-8.
|
|
3
|
+
"version": "8.1.0-next-8.16",
|
|
4
4
|
"description": "Verdaccio Web Middleware",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -28,29 +28,28 @@
|
|
|
28
28
|
},
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@verdaccio/auth": "8.0.0-next-8.
|
|
32
|
-
"@verdaccio/config": "8.0.0-next-8.
|
|
33
|
-
"@verdaccio/core": "8.0.0-next-8.
|
|
34
|
-
"@verdaccio/loaders": "8.0.0-next-8.
|
|
35
|
-
"@verdaccio/logger": "8.0.0-next-8.
|
|
36
|
-
"@verdaccio/middleware": "8.0.0-next-8.
|
|
37
|
-
"@verdaccio/store": "8.0.0-next-8.
|
|
38
|
-
"@verdaccio/tarball": "13.0.0-next-8.
|
|
39
|
-
"@verdaccio/url": "13.0.0-next-8.
|
|
40
|
-
"@verdaccio/utils": "8.1.0-next-8.15",
|
|
31
|
+
"@verdaccio/auth": "8.0.0-next-8.16",
|
|
32
|
+
"@verdaccio/config": "8.0.0-next-8.16",
|
|
33
|
+
"@verdaccio/core": "8.0.0-next-8.16",
|
|
34
|
+
"@verdaccio/loaders": "8.0.0-next-8.7",
|
|
35
|
+
"@verdaccio/logger": "8.0.0-next-8.16",
|
|
36
|
+
"@verdaccio/middleware": "8.0.0-next-8.16",
|
|
37
|
+
"@verdaccio/store": "8.0.0-next-8.16",
|
|
38
|
+
"@verdaccio/tarball": "13.0.0-next-8.16",
|
|
39
|
+
"@verdaccio/url": "13.0.0-next-8.16",
|
|
41
40
|
"debug": "4.4.0",
|
|
42
41
|
"express": "4.21.2",
|
|
43
42
|
"lodash": "4.17.21"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
|
-
"@verdaccio/api": "8.1.0-next-8.
|
|
47
|
-
"@verdaccio/test-helper": "4.0.0-next-8.
|
|
48
|
-
"@verdaccio/types": "13.0.0-next-8.
|
|
49
|
-
"jsdom": "
|
|
45
|
+
"@verdaccio/api": "8.1.0-next-8.16",
|
|
46
|
+
"@verdaccio/test-helper": "4.0.0-next-8.5",
|
|
47
|
+
"@verdaccio/types": "13.0.0-next-8.6",
|
|
48
|
+
"jsdom": "26.1.0",
|
|
50
49
|
"node-html-parser": "4.1.5",
|
|
51
50
|
"supertest": "7.0.0",
|
|
52
|
-
"verdaccio-auth-memory": "13.0.0-next-8.
|
|
53
|
-
"verdaccio-memory": "13.0.0-next-8.
|
|
51
|
+
"verdaccio-auth-memory": "13.0.0-next-8.16",
|
|
52
|
+
"verdaccio-memory": "13.0.0-next-8.16"
|
|
54
53
|
},
|
|
55
54
|
"funding": {
|
|
56
55
|
"type": "opencollective",
|