@verdaccio/web 6.0.0-6-next.29 → 6.0.0-6-next.32

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/user.ts"],"names":["debug","addUserAuthApi","auth","config","route","post","req","res","next","username","password","body","authenticate","err","user","errorCode","message","HTTP_STATUS","UNAUTHORIZED","INTERNAL_ERROR","errorUtils","getCode","remote_user","jWTSignOptions","security","web","sign","token","jwtEncrypt","name","flags","changePassword","put","_","isNil","status","API_ERROR","MUST_BE_LOGGED","new","old","isUpdated","ok","getInternalError","INTERNAL_SERVER_ERROR","BAD_REQUEST","APP_ERROR","PASSWORD_VALIDATION"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAGA;;AAEA;;;;AAIA,MAAMA,KAAK,GAAG,oBAAW,wBAAX,CAAd;;AAEA,SAASC,cAAT,CAAwBC,IAAxB,EAAqCC,MAArC,EAA6D;AAAA;;AAC3D,QAAMC,KAAK,GAAG,sBAAd;AAAwB;;AACxBA,EAAAA,KAAK,CAACC,IAAN,CAAW,QAAX,EAAqB,UAAUC,GAAV,EAAwBC,GAAxB,EAAuCC,IAAvC,EAAqE;AACxF,UAAM;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,QAAyBJ,GAAG,CAACK,IAAnC;AACAX,IAAAA,KAAK,CAAC,iBAAD,EAAoBS,QAApB,CAAL;AACAP,IAAAA,IAAI,CAACU,YAAL,CAAkBH,QAAlB,EAA4BC,QAA5B,EAAsC,OAAOG,GAAP,EAAYC,IAAZ,KAAgD;AACpF,UAAID,GAAJ,EAAS;AACP,cAAME,SAAS,GAAGF,GAAG,CAACG,OAAJ,GAAcC,kBAAYC,YAA1B,GAAyCD,kBAAYE,cAAvE;AACAnB,QAAAA,KAAK,CAAC,uBAAD,EAA0Be,SAA1B,CAAL;AACAP,QAAAA,IAAI,CAACY,iBAAWC,OAAX,CAAmBN,SAAnB,EAA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C,KAAF,CAAQrB,GAAR,KAAgB2B,SAApB,EAA+B;AAC7BhC,YAAAA,IAAI,CAAC;AACHiC,cAAAA,EAAE,EAAE;AADD,aAAD,CAAJ;AAGD,WAJD,MAIO;AACL,mBAAOjC,IAAI,CAACY,iBAAWsB,gBAAX,CAA4BN,gBAAUO,qBAAtC,CAAD,CAAX;AACD;AACF,SAZH;AAcD,OAfD,MAeO;AACL,eAAOnC,IAAI,CAACY,iBAAWC,OAAX,CAAmBJ,kBAAY2B,WAA/B,EAA4CC,gBAAUC,mBAAtD,CAAD,CAAX;AACD;AACF,KAhCH;AAkCD;;AAED,SAAO1C,KAAP;AACD;;eAEcH,c","sourcesContent":["import buildDebug from 'debug';\nimport { Request, Response, Router } from 'express';\nimport _ from 'lodash';\n\nimport { IAuth } from '@verdaccio/auth';\nimport { API_ERROR, APP_ERROR, HTTP_STATUS, errorUtils } from '@verdaccio/core';\nimport { Config, JWTSignOptions, RemoteUser } from '@verdaccio/types';\nimport { validatePassword } from '@verdaccio/utils';\n\nimport { $NextFunctionVer } from './package';\n\nconst debug = buildDebug('verdaccio:web:api:user');\n\nfunction addUserAuthApi(auth: IAuth, config: Config): Router {\n const route = Router(); /* eslint new-cap: 0 */\n route.post('/login', function (req: Request, res: Response, next: $NextFunctionVer): void {\n const { username, password } = req.body;\n debug('authenticate %o', username);\n auth.authenticate(username, password, async (err, 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;\n const jWTSignOptions: JWTSignOptions = config.security.web.sign;\n\n next({\n token: await auth.jwtEncrypt(user, jWTSignOptions),\n username: req.remote_user.name,\n });\n }\n });\n });\n\n if (config?.flags?.changePassword === true) {\n route.put(\n '/reset_password',\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 (validatePassword(password.new) === false) {\n auth.changePassword(\n name as string,\n password.old,\n password.new,\n (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 } else {\n return next(errorUtils.getCode(HTTP_STATUS.BAD_REQUEST, APP_ERROR.PASSWORD_VALIDATION));\n }\n }\n );\n }\n\n return route;\n}\n\nexport default addUserAuthApi;\n"],"file":"user.js"}
1
+ {"version":3,"file":"user.js","names":["debug","buildDebug","addUserAuthApi","auth","config","route","Router","post","req","res","next","username","password","body","authenticate","err","user","errorCode","message","HTTP_STATUS","UNAUTHORIZED","INTERNAL_ERROR","errorUtils","getCode","remote_user","jWTSignOptions","security","web","sign","token","jwtEncrypt","name","flags","changePassword","put","_","isNil","status","API_ERROR","MUST_BE_LOGGED","validatePassword","new","old","isUpdated","ok","getInternalError","INTERNAL_SERVER_ERROR","BAD_REQUEST","APP_ERROR","PASSWORD_VALIDATION"],"sources":["../../src/api/user.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { Request, Response, Router } from 'express';\nimport _ from 'lodash';\n\nimport { IAuth } from '@verdaccio/auth';\nimport { API_ERROR, APP_ERROR, HTTP_STATUS, errorUtils } from '@verdaccio/core';\nimport { Config, JWTSignOptions, RemoteUser } from '@verdaccio/types';\nimport { validatePassword } from '@verdaccio/utils';\n\nimport { $NextFunctionVer } from './package';\n\nconst debug = buildDebug('verdaccio:web:api:user');\n\nfunction addUserAuthApi(auth: IAuth, config: Config): Router {\n const route = Router(); /* eslint new-cap: 0 */\n route.post('/login', function (req: Request, res: Response, next: $NextFunctionVer): void {\n const { username, password } = req.body;\n debug('authenticate %o', username);\n auth.authenticate(username, password, async (err, 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;\n const jWTSignOptions: JWTSignOptions = config.security.web.sign;\n\n next({\n token: await auth.jwtEncrypt(user, jWTSignOptions),\n username: req.remote_user.name,\n });\n }\n });\n });\n\n if (config?.flags?.changePassword === true) {\n route.put(\n '/reset_password',\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 (validatePassword(password.new) === false) {\n auth.changePassword(\n name as string,\n password.old,\n password.new,\n (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 } else {\n return next(errorUtils.getCode(HTTP_STATUS.BAD_REQUEST, APP_ERROR.PASSWORD_VALIDATION));\n }\n }\n );\n }\n\n return route;\n}\n\nexport default addUserAuthApi;\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAGA;;AAEA;;;;AAIA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,wBAAX,CAAd;;AAEA,SAASC,cAAT,CAAwBC,IAAxB,EAAqCC,MAArC,EAA6D;EAAA;;EAC3D,MAAMC,KAAK,GAAG,IAAAC,eAAA,GAAd;EAAwB;;EACxBD,KAAK,CAACE,IAAN,CAAW,QAAX,EAAqB,UAAUC,GAAV,EAAwBC,GAAxB,EAAuCC,IAAvC,EAAqE;IACxF,MAAM;MAAEC,QAAF;MAAYC;IAAZ,IAAyBJ,GAAG,CAACK,IAAnC;IACAb,KAAK,CAAC,iBAAD,EAAoBW,QAAp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MACA,MAAM;QAAEkB;MAAF,IAAWvB,GAAG,CAACgB,WAArB;;MAEA,IAAI,IAAAgB,uBAAA,EAAiB5B,QAAQ,CAAC6B,GAA1B,MAAmC,KAAvC,EAA8C;QAC5CtC,IAAI,CAAC8B,cAAL,CACEF,IADF,EAEEnB,QAAQ,CAAC8B,GAFX,EAGE9B,QAAQ,CAAC6B,GAHX,EAIE,CAAC1B,GAAD,EAAM4B,SAAN,KAA0B;UACxB,IAAIR,eAAA,CAAEC,KAAF,CAAQrB,GAAR,KAAgB4B,SAApB,EAA+B;YAC7BjC,IAAI,CAAC;cACHkC,EAAE,EAAE;YADD,CAAD,CAAJ;UAGD,CAJD,MAIO;YACL,OAAOlC,IAAI,CAACY,gBAAA,CAAWuB,gBAAX,CAA4BP,eAAA,CAAUQ,qBAAtC,CAAD,CAAX;UACD;QACF,CAZH;MAcD,CAfD,MAeO;QACL,OAAOpC,IAAI,CAACY,gBAAA,CAAWC,OAAX,CAAmBJ,iBAAA,CAAY4B,WAA/B,EAA4CC,eAAA,CAAUC,mBAAtD,CAAD,CAAX;MACD;IACF,CAhCH;EAkCD;;EAED,OAAO5C,KAAP;AACD;;eAEcH,c"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA","sourcesContent":["export { default } from './web-middleware';\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { default } from './web-middleware';\n"],"mappings":";;;;;;;;;;;;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/middleware/render-web.ts"],"names":["debug","loadTheme","config","_","isNil","theme","head","plugin","isString","sendFileCallback","next","err","status","HTTP_STATUS","NOT_FOUND","renderWebMiddleware","auth","staticPath","manifest","manifestFiles","require","router","express","Router","use","webUIJWTmiddleware","setSecurityWebHeaders","logoURI","web","logo","path","posix","join","basename","get","req","res","sendFile","resolve","filename","params","file"],"mappings":";;;;;;;;AAAA;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4CgB,GAA5C,EAAiDC,GAAjD;AACApC,IAAAA,KAAK,CAAC,aAAD,CAAL;AACD,GAHD;AAKA,SAAOqB,MAAP;AACD","sourcesContent":["import buildDebug from 'debug';\nimport express from 'express';\nimport _ from 'lodash';\nimport path from 'path';\n\nimport { HTTP_STATUS } from '@verdaccio/core';\nimport { loadPlugin } from '@verdaccio/loaders';\nimport { isURLhasValidProtocol } from '@verdaccio/url';\n\nimport renderHTML from '../renderHTML';\nimport { setSecurityWebHeaders } from './security';\n\nconst debug = buildDebug('verdaccio:web:render');\n\nexport function loadTheme(config) {\n if (_.isNil(config.theme) === false) {\n return _.head(\n loadPlugin(\n config,\n config.theme,\n {},\n function (plugin) {\n return _.isString(plugin);\n },\n 'verdaccio-theme'\n )\n );\n }\n}\n\nconst sendFileCallback = (next) => (err) => {\n if (!err) {\n return;\n }\n if (err.status === HTTP_STATUS.NOT_FOUND) {\n next();\n } else {\n next(err);\n }\n};\n\nexport function renderWebMiddleware(config, auth): any {\n const { staticPath, manifest, manifestFiles } = require('@verdaccio/ui-theme')();\n debug('static path %o', staticPath);\n\n /* eslint new-cap:off */\n const router = express.Router();\n router.use(auth.webUIJWTmiddleware());\n router.use(setSecurityWebHeaders);\n\n // Logo\n let logoURI = config?.web?.logo ?? '';\n if (logoURI && !isURLhasValidProtocol(logoURI)) {\n // URI related to a local file\n\n // Note: `path.join` will break on Windows, because it transforms `/` to `\\`\n // Use POSIX version `path.posix.join` instead.\n logoURI = path.posix.join('/-/static/', path.basename(logoURI));\n router.get(logoURI, function (req, res, next) {\n res.sendFile(path.resolve(config.web.logo), sendFileCallback(next));\n debug('render static');\n });\n }\n\n // Static\n router.get('/-/static/*', function (req, res, next) {\n const filename = req.params[0];\n const file = `${staticPath}/${filename}`;\n debug('render static file %o', file);\n res.sendFile(file, sendFileCallback(next));\n });\n\n router.get('/-/web/:section/*', function (req, res) {\n renderHTML(config, manifest, manifestFiles, req, res);\n debug('render html section');\n });\n\n router.get('/', function (req, res) {\n renderHTML(config, manifest, manifestFiles, req, res);\n debug('render root');\n });\n\n return router;\n}\n"],"file":"render-web.js"}
1
+ {"version":3,"file":"render-web.js","names":["debug","buildDebug","loadTheme","config","_","isNil","theme","head","loadPlugin","plugin","isString","sendFileCallback","next","err","status","HTTP_STATUS","NOT_FOUND","renderWebMiddleware","auth","staticPath","manifest","manifestFiles","require","router","express","Router","use","webUIJWTmiddleware","setSecurityWebHeaders","logoURI","web","logo","isURLhasValidProtocol","path","posix","join","basename","get","req","res","sendFile","resolve","filename","params","file","renderHTML"],"sources":["../../src/middleware/render-web.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport express from 'express';\nimport _ from 'lodash';\nimport path from 'path';\n\nimport { HTTP_STATUS } from '@verdaccio/core';\nimport { loadPlugin } from '@verdaccio/loaders';\nimport { isURLhasValidProtocol } from '@verdaccio/url';\n\nimport renderHTML from '../renderHTML';\nimport { setSecurityWebHeaders } from './security';\n\nconst debug = buildDebug('verdaccio:web:render');\n\nexport function loadTheme(config) {\n if (_.isNil(config.theme) === false) {\n return _.head(\n loadPlugin(\n config,\n config.theme,\n {},\n function (plugin) {\n return _.isString(plugin);\n },\n 'verdaccio-theme'\n )\n );\n }\n}\n\nconst sendFileCallback = (next) => (err) => {\n if (!err) {\n return;\n }\n if (err.status === HTTP_STATUS.NOT_FOUND) {\n next();\n } else {\n next(err);\n }\n};\n\nexport function renderWebMiddleware(config, auth): any {\n const { staticPath, manifest, manifestFiles } = require('@verdaccio/ui-theme')();\n debug('static path %o', staticPath);\n\n /* eslint new-cap:off */\n const router = express.Router();\n router.use(auth.webUIJWTmiddleware());\n router.use(setSecurityWebHeaders);\n\n // Logo\n let logoURI = config?.web?.logo ?? '';\n if (logoURI && !isURLhasValidProtocol(logoURI)) {\n // URI related to a local file\n\n // Note: `path.join` will break on Windows, because it transforms `/` to `\\`\n // Use POSIX version `path.posix.join` instead.\n logoURI = path.posix.join('/-/static/', path.basename(logoURI));\n router.get(logoURI, function (req, res, next) {\n res.sendFile(path.resolve(config.web.logo), sendFileCallback(next));\n debug('render static');\n });\n }\n\n // Static\n router.get('/-/static/*', function (req, res, next) {\n const filename = req.params[0];\n const file = `${staticPath}/${filename}`;\n debug('render static file %o', file);\n res.sendFile(file, sendFileCallback(next));\n });\n\n router.get('/-/web/:section/*', function (req, res) {\n renderHTML(config, manifest, manifestFiles, req, res);\n debug('render html section');\n });\n\n router.get('/', function (req, res) {\n renderHTML(config, manifest, manifestFiles, req, res);\n debug('render root');\n });\n\n return router;\n}\n"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;;;AAEA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,sBAAX,CAAd;;AAEO,SAASC,SAAT,CAAmBC,MAAnB,EAA2B;EAChC,IAAIC,eAAA,CAAEC,KAAF,CAAQF,MAAM,CAACG,KAAf,MAA0B,KAA9B,EAAqC;IACnC,OAAOF,eAAA,CAAEG,IAAF,CACL,IAAAC,mBAAA,EACEL,MADF,EAEEA,MAAM,CAACG,KAFT,EAGE,EAHF,EAIE,UAAUG,MAAV,EAAkB;MAChB,OAAOL,eAAA,CAAEM,QAAF,CAAWD,MAAX,CAAP;IACD,CANH,EAOE,iBAPF,CADK,CAAP;EAWD;AACF;;AAED,MAAME,gBAAgB,GAAIC,IAAD,IAAWC,GAAD,IAAS;EAC1C,IAAI,CAACA,GAAL,EAAU;IACR;EACD;;EACD,IAAIA,GAAG,CAACC,MAAJ,KAAeC,iBAAA,CAAYC,SAA/B,EAA0C;IACxCJ,IAAI;EACL,CAFD,MAEO;IACLA,IAAI,CAACC,GAAD,CAAJ;EACD;AACF,CATD;;AAWO,SAASI,mBAAT,CAA6Bd,MAA7B,EAAqCe,IAArC,EAAgD;EAAA;;EACrD,MAAM;IAAEC,UAAF;IAAcC,QAAd;IAAwBC;EAAxB,IAA0CC,OAAO,CAAC,qBAAD,CAAP,EAAhD;;EACAtB,KAAK,CAAC,gBAAD,EAA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AUC,GAAV,EAAeC,GAAf,EAAoB;IAClD,IAAAM,mBAAA,EAAW1C,MAAX,EAAmBiB,QAAnB,EAA6BC,aAA7B,EAA4CiB,GAA5C,EAAiDC,GAAjD;IACAvC,KAAK,CAAC,qBAAD,CAAL;EACD,CAHD;EAKAuB,MAAM,CAACc,GAAP,CAAW,GAAX,EAAgB,UAAUC,GAAV,EAAeC,GAAf,EAAoB;IAClC,IAAAM,mBAAA,EAAW1C,MAAX,EAAmBiB,QAAnB,EAA6BC,aAA7B,EAA4CiB,GAA5C,EAAiDC,GAAjD;IACAvC,KAAK,CAAC,aAAD,CAAL;EACD,CAHD;EAKA,OAAOuB,MAAP;AACD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/middleware/security.ts"],"names":["setSecurityWebHeaders","req","res","next","header","HEADERS","FRAMES_OPTIONS","CSP","CTO","XSS"],"mappings":";;;;;;;AAAA;;AAGO,SAASA,qBAAT,CACLC,GADK,EAELC,GAFK,EAGLC,IAHK,EAIC;AACN;AACAD,EAAAA,GAAG,CAACE,MAAJ,CAAWC,cAAQC,cAAnB,EAAmC,MAAnC,EAFM,CAGN;;AACAJ,EAAAA,GAAG,CAACE,MAAJ,CAAWC,cAAQE,GAAnB,EAAwB,oBAAxB,EAJM,CAKN;;AACAL,EAAAA,GAAG,CAACE,MAAJ,CAAWC,cAAQG,GAAnB,EAAwB,SAAxB,EANM,CAON;;AACAN,EAAAA,GAAG,CAACE,MAAJ,CAAWC,cAAQI,GAAnB,EAAwB,eAAxB;AACAN,EAAAA,IAAI;AACL","sourcesContent":["import { HEADERS } from '@verdaccio/core';\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '@verdaccio/middleware';\n\nexport function setSecurityWebHeaders(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n): void {\n // disable loading in frames (clickjacking, etc.)\n res.header(HEADERS.FRAMES_OPTIONS, 'deny');\n // avoid stablish connections outside of domain\n res.header(HEADERS.CSP, \"connect-src 'self'\");\n // https://stackoverflow.com/questions/18337630/what-is-x-content-type-options-nosniff\n res.header(HEADERS.CTO, 'nosniff');\n // https://stackoverflow.com/questions/9090577/what-is-the-http-header-x-xss-protection\n res.header(HEADERS.XSS, '1; mode=block');\n next();\n}\n"],"file":"security.js"}
1
+ {"version":3,"file":"security.js","names":["setSecurityWebHeaders","req","res","next","header","HEADERS","FRAMES_OPTIONS","CSP","CTO","XSS"],"sources":["../../src/middleware/security.ts"],"sourcesContent":["import { HEADERS } from '@verdaccio/core';\nimport { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '@verdaccio/middleware';\n\nexport function setSecurityWebHeaders(\n req: $RequestExtend,\n res: $ResponseExtend,\n next: $NextFunctionVer\n): void {\n // disable loading in frames (clickjacking, etc.)\n res.header(HEADERS.FRAMES_OPTIONS, 'deny');\n // avoid stablish connections outside of domain\n res.header(HEADERS.CSP, \"connect-src 'self'\");\n // https://stackoverflow.com/questions/18337630/what-is-x-content-type-options-nosniff\n res.header(HEADERS.CTO, 'nosniff');\n // https://stackoverflow.com/questions/9090577/what-is-the-http-header-x-xss-protection\n res.header(HEADERS.XSS, '1; mode=block');\n next();\n}\n"],"mappings":";;;;;;;AAAA;;AAGO,SAASA,qBAAT,CACLC,GADK,EAELC,GAFK,EAGLC,IAHK,EAIC;EACN;EACAD,GAAG,CAACE,MAAJ,CAAWC,aAAA,CAAQC,cAAnB,EAAmC,MAAnC,EAFM,CAGN;;EACAJ,GAAG,CAACE,MAAJ,CAAWC,aAAA,CAAQE,GAAnB,EAAwB,oBAAxB,EAJM,CAKN;;EACAL,GAAG,CAACE,MAAJ,CAAWC,aAAA,CAAQG,GAAnB,EAAwB,SAAxB,EANM,CAON;;EACAN,GAAG,CAACE,MAAJ,CAAWC,aAAA,CAAQI,GAAnB,EAAwB,eAAxB;EACAN,IAAI;AACL"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/middleware/web-api.ts"],"names":["webAPI","config","auth","storage","route","param","validatePackage","validateName","use","bodyParser","urlencoded","extended","webUIJWTmiddleware","setSecurityWebHeaders"],"mappings":";;;;;;;AAAA;;AACA;;AAGA;;AAIA;;AACA;;;;AAEO,SAASA,MAAT,CAAgBC,MAAhB,EAAgCC,IAAhC,EAA6CC,OAA7C,EAAuE;AAC5E;AACA,QAAMC,KAAK,GAAG,sBAAd,CAF4E,CAG5E;AACA;;AACAA,EAAAA,KAAK,CAACC,KAAN,CAAY,SAAZ,EAAuBC,2BAAvB;AACAF,EAAAA,KAAK,CAACC,KAAN,CAAY,UAAZ,EAAwBE,wBAAxB;AACAH,EAAAA,KAAK,CAACC,KAAN,CAAY,SAAZ,EAAuBE,wBAAvB;AACAH,EAAAA,KAAK,CAACC,KAAN,CAAY,UAAZ,EAAwB,uBAAM,IAAN,CAAxB;AACAD,EAAAA,KAAK,CAACI,GAAN,CAAUC,oBAAWC,UAAX,CAAsB;AAAEC,IAAAA,QAAQ,EAAE;AAAZ,GAAtB,CAAV;AACAP,EAAAA,KAAK,CAACI,GAAN,CAAUN,IAAI,CAACU,kBAAL,EAAV;AACAR,EAAAA,KAAK,CAACI,GAAN,CAAUK,+BAAV;AACAT,EAAAA,KAAK,CAACI,GAAN,CAAU,kBAAgBN,IAAhB,EAAsBC,OAAtB,EAA+BF,MAA/B,CAAV;AACA,SAAOG,KAAP;AACD","sourcesContent":["import bodyParser from 'body-parser';\nimport { Router } from 'express';\n\nimport { IAuth } from '@verdaccio/auth';\nimport { match, validateName, validatePackage } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { Config } from '@verdaccio/types';\n\nimport webEndpointsApi from '../api';\nimport { setSecurityWebHeaders } from './security';\n\nexport function webAPI(config: Config, auth: IAuth, storage: Storage): Router {\n // eslint-disable-next-line new-cap\n const route = Router();\n // validate all of these params as a package name\n // this might be too harsh, so ask if it causes trouble=\n route.param('package', validatePackage);\n route.param('filename', validateName);\n route.param('version', validateName);\n route.param('anything', match(/.*/));\n route.use(bodyParser.urlencoded({ extended: false }));\n route.use(auth.webUIJWTmiddleware());\n route.use(setSecurityWebHeaders);\n route.use(webEndpointsApi(auth, storage, config));\n return route;\n}\n"],"file":"web-api.js"}
1
+ {"version":3,"file":"web-api.js","names":["webAPI","config","auth","storage","route","Router","param","validatePackage","validateName","match","use","bodyParser","urlencoded","extended","webUIJWTmiddleware","setSecurityWebHeaders","webEndpointsApi"],"sources":["../../src/middleware/web-api.ts"],"sourcesContent":["import bodyParser from 'body-parser';\nimport { Router } from 'express';\n\nimport { IAuth } from '@verdaccio/auth';\nimport { match, validateName, validatePackage } from '@verdaccio/middleware';\nimport { Storage } from '@verdaccio/store';\nimport { Config } from '@verdaccio/types';\n\nimport webEndpointsApi from '../api';\nimport { setSecurityWebHeaders } from './security';\n\nexport function webAPI(config: Config, auth: IAuth, storage: Storage): Router {\n // eslint-disable-next-line new-cap\n const route = Router();\n // validate all of these params as a package name\n // this might be too harsh, so ask if it causes trouble=\n route.param('package', validatePackage);\n route.param('filename', validateName);\n route.param('version', validateName);\n route.param('anything', match(/.*/));\n route.use(bodyParser.urlencoded({ extended: false }));\n route.use(auth.webUIJWTmiddleware());\n route.use(setSecurityWebHeaders);\n route.use(webEndpointsApi(auth, storage, config));\n return route;\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAGA;;AAIA;;AACA;;;;AAEO,SAASA,MAAT,CAAgBC,MAAhB,EAAgCC,IAAhC,EAA6CC,OAA7C,EAAuE;EAC5E;EACA,MAAMC,KAAK,GAAG,IAAAC,eAAA,GAAd,CAF4E,CAG5E;EACA;;EACAD,KAAK,CAACE,KAAN,CAAY,SAAZ,EAAuBC,2BAAvB;EACAH,KAAK,CAACE,KAAN,CAAY,UAAZ,EAAwBE,wBAAxB;EACAJ,KAAK,CAACE,KAAN,CAAY,SAAZ,EAAuBE,wBAAvB;EACAJ,KAAK,CAACE,KAAN,CAAY,UAAZ,EAAwB,IAAAG,iBAAA,EAAM,IAAN,CAAxB;EACAL,KAAK,CAACM,GAAN,CAAUC,mBAAA,CAAWC,UAAX,CAAsB;IAAEC,QAAQ,EAAE;EAAZ,CAAtB,CAAV;EACAT,KAAK,CAACM,GAAN,CAAUR,IAAI,CAACY,kBAAL,EAAV;EACAV,KAAK,CAACM,GAAN,CAAUK,+BAAV;EACAX,KAAK,CAACM,GAAN,CAAU,IAAAM,YAAA,EAAgBd,IAAhB,EAAsBC,OAAtB,EAA+BF,MAA/B,CAAV;EACA,OAAOG,KAAP;AACD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/renderHTML.ts"],"names":["pkgJSON","require","DEFAULT_LANGUAGE","cache","LRU","max","maxAge","debug","defaultManifestFiles","js","ico","renderHTML","config","manifest","manifestFiles","req","res","url_prefix","base","basename","URL","pathname","language","i18n","web","needHtmlCache","undefined","includes","html_cache","darkMode","title","WEB_TITLE","login","scope","logoURI","logo","pkgManagers","version","flags","primaryColor","primary_color","scriptsBodyAfter","metaScripts","scriptsbodyBefore","showInfo","showSettings","showThemeSwitch","showFooter","showSearch","showDownloadTarball","Object","assign","bodyBefore","options","webPage","get","set","error","Error","stack","setHeader","HEADERS","TEXT_HTML","send"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;;;AAEA,MAAMA,OAAO,GAAGC,OAAO,CAAC,iBAAD,CAAvB;;AACA,MAAMC,gBAAgB,GAAG,OAAzB;AACA,MAAMC,KAAK,GAAG,IAAIC,iBAAJ,CAAQ;AAAEC,EAAAA,GAAG,EAAE,GAAP;AAAYC,EAAAA,MAAM,EAAE,OAAO,EAAP,GAAY;AAAhC,CAAR,CAAd;AAEA,MAAMC,KAAK,GAAG,oBAAW,sBAAX,CAAd;AAEA,MAAMC,oBAAoB,GAAG;AAC3BC,EAAAA,EAAE,EAAE,CAAC,YAAD,EAAe,YAAf,EAA6B,SAA7B,CADuB;AAE3BC,EAAAA,GAAG,EAAE;AAFsB,CAA7B;;AAKe,SAASC,UAAT,CAAoBC,MAApB,EAA4BC,QAA5B,EAA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ACoD,GAAN,CAAU,UAAV,CAAV;;AACA,QAAI,CAACD,OAAL,EAAc;AACZA,MAAAA,OAAO,GAAG,uBACR;AACEzC,QAAAA,QAAQ,EAAEC,aAAa,IAAIN,oBAD7B;AAEE6C,QAAAA,OAFF;AAGEZ,QAAAA,gBAHF;AAIEC,QAAAA,WAJF;AAKEC,QAAAA;AALF,OADQ,EAQR9B,QARQ,CAAV;;AAUA,UAAIY,aAAJ,EAAmB;AACjBtB,QAAAA,KAAK,CAACqD,GAAN,CAAU,UAAV,EAAsBF,OAAtB;AACA/C,QAAAA,KAAK,CAAC,oBAAD,CAAL;AACD;AACF,KAfD,MAeO;AACLA,MAAAA,KAAK,CAAC,sBAAD,CAAL;AACD;AACF,GApBD,CAoBE,OAAOkD,KAAP,EAAmB;AACnB,UAAM,IAAIC,KAAJ,CAAW,kCAAiCD,KAAK,CAACE,KAAM,EAAxD,CAAN;AACD;;AACD3C,EAAAA,GAAG,CAAC4C,SAAJ,CAAc,cAAd,EAA8BC,cAAQC,SAAtC;AACA9C,EAAAA,GAAG,CAAC+C,IAAJ,CAAST,OAAT;AACA/C,EAAAA,KAAK,CAAC,cAAD,CAAL;AACD","sourcesContent":["import buildDebug from 'debug';\nimport LRU from 'lru-cache';\nimport { URL } from 'url';\n\nimport { WEB_TITLE } from '@verdaccio/config';\nimport { HEADERS } from '@verdaccio/core';\nimport { TemplateUIOptions } from '@verdaccio/types';\nimport { getPublicUrl } from '@verdaccio/url';\n\nimport renderTemplate from './template';\nimport { hasLogin, validatePrimaryColor } from './utils/web-utils';\n\nconst pkgJSON = require('../package.json');\nconst DEFAULT_LANGUAGE = 'es-US';\nconst cache = new LRU({ max: 500, maxAge: 1000 * 60 * 60 });\n\nconst debug = buildDebug('verdaccio:web:render');\n\nconst defaultManifestFiles = {\n js: ['runtime.js', 'vendors.js', 'main.js'],\n ico: 'favicon.ico',\n};\n\nexport default function renderHTML(config, manifest, manifestFiles, req, res) {\n const { url_prefix } = config;\n const base = getPublicUrl(config?.url_prefix, req);\n const basename = new URL(base).pathname;\n const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;\n const needHtmlCache = [undefined, null].includes(config?.web?.html_cache)\n ? true\n : config.web.html_cache;\n const darkMode = config?.web?.darkMode ?? false;\n const title = config?.web?.title ?? WEB_TITLE;\n const login = hasLogin(config);\n const scope = config?.web?.scope ?? '';\n const logoURI = config?.web?.logo ?? '';\n const pkgManagers = config?.web?.pkgManagers ?? ['yarn', 'pnpm', 'npm'];\n const version = pkgJSON.version;\n const flags = {\n ...config.flags,\n };\n const primaryColor = validatePrimaryColor(config?.web?.primary_color) ?? '#4b5e40';\n const {\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n } = Object.assign(\n {},\n {\n scriptsBodyAfter: [],\n bodyBefore: [],\n metaScripts: [],\n },\n config?.web\n );\n const options: TemplateUIOptions = {\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n darkMode,\n url_prefix,\n basename,\n base,\n primaryColor,\n version,\n logoURI,\n flags,\n login,\n pkgManagers,\n title,\n scope,\n language,\n };\n\n let webPage;\n\n try {\n webPage = cache.get('template');\n if (!webPage) {\n webPage = renderTemplate(\n {\n manifest: manifestFiles ?? defaultManifestFiles,\n options,\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n },\n manifest\n );\n if (needHtmlCache) {\n cache.set('template', webPage);\n debug('set template cache');\n }\n } else {\n debug('reuse template cache');\n }\n } catch (error: any) {\n throw new Error(`theme could not be load, stack ${error.stack}`);\n }\n res.setHeader('Content-Type', HEADERS.TEXT_HTML);\n res.send(webPage);\n debug('web rendered');\n}\n"],"file":"renderHTML.js"}
1
+ {"version":3,"file":"renderHTML.js","names":["pkgJSON","require","DEFAULT_LANGUAGE","cache","LRU","max","maxAge","debug","buildDebug","defaultManifestFiles","js","ico","renderHTML","config","manifest","manifestFiles","req","res","url_prefix","base","getPublicUrl","basename","URL","pathname","language","i18n","web","needHtmlCache","undefined","includes","html_cache","darkMode","title","WEB_TITLE","login","hasLogin","scope","logoURI","logo","pkgManagers","version","flags","primaryColor","validatePrimaryColor","primary_color","scriptsBodyAfter","metaScripts","scriptsbodyBefore","showInfo","showSettings","showThemeSwitch","showFooter","showSearch","showDownloadTarball","Object","assign","bodyBefore","options","webPage","get","renderTemplate","set","error","Error","stack","setHeader","HEADERS","TEXT_HTML","send"],"sources":["../src/renderHTML.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport LRU from 'lru-cache';\nimport { URL } from 'url';\n\nimport { WEB_TITLE } from '@verdaccio/config';\nimport { HEADERS } from '@verdaccio/core';\nimport { TemplateUIOptions } from '@verdaccio/types';\nimport { getPublicUrl } from '@verdaccio/url';\n\nimport renderTemplate from './template';\nimport { hasLogin, validatePrimaryColor } from './utils/web-utils';\n\nconst pkgJSON = require('../package.json');\nconst DEFAULT_LANGUAGE = 'es-US';\nconst cache = new LRU({ max: 500, maxAge: 1000 * 60 * 60 });\n\nconst debug = buildDebug('verdaccio:web:render');\n\nconst defaultManifestFiles = {\n js: ['runtime.js', 'vendors.js', 'main.js'],\n ico: 'favicon.ico',\n};\n\nexport default function renderHTML(config, manifest, manifestFiles, req, res) {\n const { url_prefix } = config;\n const base = getPublicUrl(config?.url_prefix, req);\n const basename = new URL(base).pathname;\n const language = config?.i18n?.web ?? DEFAULT_LANGUAGE;\n const needHtmlCache = [undefined, null].includes(config?.web?.html_cache)\n ? true\n : config.web.html_cache;\n const darkMode = config?.web?.darkMode ?? false;\n const title = config?.web?.title ?? WEB_TITLE;\n const login = hasLogin(config);\n const scope = config?.web?.scope ?? '';\n const logoURI = config?.web?.logo ?? '';\n const pkgManagers = config?.web?.pkgManagers ?? ['yarn', 'pnpm', 'npm'];\n const version = pkgJSON.version;\n const flags = {\n ...config.flags,\n };\n const primaryColor = validatePrimaryColor(config?.web?.primary_color) ?? '#4b5e40';\n const {\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n } = Object.assign(\n {},\n {\n scriptsBodyAfter: [],\n bodyBefore: [],\n metaScripts: [],\n },\n config?.web\n );\n const options: TemplateUIOptions = {\n showInfo,\n showSettings,\n showThemeSwitch,\n showFooter,\n showSearch,\n showDownloadTarball,\n darkMode,\n url_prefix,\n basename,\n base,\n primaryColor,\n version,\n logoURI,\n flags,\n login,\n pkgManagers,\n title,\n scope,\n language,\n };\n\n let webPage;\n\n try {\n webPage = cache.get('template');\n if (!webPage) {\n webPage = renderTemplate(\n {\n manifest: manifestFiles ?? defaultManifestFiles,\n options,\n scriptsBodyAfter,\n metaScripts,\n scriptsbodyBefore,\n },\n manifest\n );\n if (needHtmlCache) {\n cache.set('template', webPage);\n debug('set template cache');\n }\n } else {\n debug('reuse template cache');\n }\n } catch (error: any) {\n throw new Error(`theme could not be load, stack ${error.stack}`);\n }\n res.setHeader('Content-Type', HEADERS.TEXT_HTML);\n res.send(webPage);\n debug('web rendered');\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;;;AAEA,MAAMA,OAAO,GAAGC,OAAO,CAAC,iBAAD,CAAvB;;AACA,MAAMC,gBAAgB,GAAG,OAAzB;AACA,MAAMC,KAAK,GAAG,IAAIC,iBAAJ,CAAQ;EAAEC,GAAG,EAAE,GAAP;EAAYC,MAAM,EAAE,OAAO,EAAP,GAAY;AAAhC,CAAR,CAAd;AAEA,MAAMC,KAAK,GAAG,IAAAC,cAAA,EAAW,sBAAX,CAAd;AAEA,MAAMC,oBAAoB,GAAG;EAC3BC,EAAE,EAAE,CAAC,YAAD,EAAe,YAAf,EAA6B,SAA7B,CADuB;EAE3BC,GAAG,EAAE;AAFsB,CAA7B;;AAKe,SAASC,UAAT,CAAoBC,MAApB,EAA4BC,QAA5B,EAAsCC,aAAt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C,QARQ,CAAV;;MAUA,IAAIa,aAAJ,EAAmB;QACjBxB,KAAK,CAAC0D,GAAN,CAAU,UAAV,EAAsBH,OAAtB;QACAnD,KAAK,CAAC,oBAAD,CAAL;MACD;IACF,CAfD,MAeO;MACLA,KAAK,CAAC,sBAAD,CAAL;IACD;EACF,CApBD,CAoBE,OAAOuD,KAAP,EAAmB;IACnB,MAAM,IAAIC,KAAJ,CAAW,kCAAiCD,KAAK,CAACE,KAAM,EAAxD,CAAN;EACD;;EACD/C,GAAG,CAACgD,SAAJ,CAAc,cAAd,EAA8BC,aAAA,CAAQC,SAAtC;EACAlD,GAAG,CAACmD,IAAJ,CAASV,OAAT;EACAnD,KAAK,CAAC,cAAD,CAAL;AACD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/template.ts"],"names":["debug","renderTemplate","template","manifest","options","base","title","JSON","stringify","metaScripts","join","scriptsbodyBefore","js","map","item","scriptsBodyAfter"],"mappings":";;;;;;;AAAA;;AAIA;;;;AAEA,MAAMA,KAAK,GAAG,oBAAW,+BAAX,CAAd;;AAee,SAASC,cAAT,CAAwBC,QAAxB,EAA4CC,QAA5C,EAAuE;AAAA;;AACpFH,EAAAA,KAAK,CAAC,aAAD,EAAgBE,QAAhB,CAAL;AACAF,EAAAA,KAAK,CAAC,aAAD,EAAgBG,QAAhB,CAAL;AAEA,SAAQ;AACV;AACA;AACA;AACA;AACA,sBAAsBD,QALb,aAKaA,QALb,uBAKaA,QAAQ,CAAEE,OAAV,CAAkBC,IAAK;AAC7C,iBAAiB,CAAAH,QAAQ,SAAR,IAAAA,QAAQ,WAAR,iCAAAA,QAAQ,CAAEE,OAAV,wEAAmBE,KAAnB,KAA4B,EAAG;AAChD,iCAAiCJ,QAPxB,aAOwBA,QAPxB,uBAOwBA,QAAQ,CAAEE,OAAV,CAAkBC,IAAK;AACxD;AACA;AACA,qDAAqDE,IAAI,CAACC,SAAL,CAAeN,QAAQ,CAACE,OAAxB,CAAiC;AACtF;AACA,UAAUF,QAAQ,SAAR,IAAAA,QAAQ,WAAR,IAAAA,QAAQ,CAAEO,WAAV,GAAwBP,QAAQ,CAACO,WAAT,CAAqBC,IAArB,CAA0B,EAA1B,CAAxB,GAAwD,EAAG;AACrE;AACA;AACA,QAAQR,QAAQ,SAAR,IAAAA,QAAQ,WAAR,IAAAA,QAAQ,CAAES,iBAAV,GAA8BT,QAAQ,CAACS,iBAAT,CAA2BD,IAA3B,CAAgC,EAAhC,CAA9B,GAAoE,EAAG;AAC/E;AACA,UAAU,gCAAiBR,QAAQ,CAACC,QAAT,CAAkBS,EAAnC,EAAuCT,QAAvC,EAAiDD,QAAjD,aAAiDA,QAAjD,uBAAiDA,QAAQ,CAAEE,OAAV,CAAkBC,IAAnE,EACCQ,GADD,CACMC,IAAD,IAAW,8BAA6BA,IAAK,aADlD,EAECJ,IAFD,CAEM,EAFN,CAEU;AACpB,UAAUR,QAAQ,SAAR,IAAAA,QAAQ,WAAR,IAAAA,QAAQ,CAAEa,gBAAV,GAA6Bb,QAAQ,CAACa,gBAAT,CAA0BL,IAA1B,CAA+B,EAA/B,CAA7B,GAAkE,EAAG;AAC/E;AACA;AACA,GAvBE;AAwBD","sourcesContent":["import buildDebug from 'debug';\n\nimport { TemplateUIOptions } from '@verdaccio/types';\n\nimport { Manifest, getManifestValue } from './utils/manifest';\n\nconst debug = buildDebug('verdaccio:web:render:template');\n\nexport type Template = {\n manifest: Manifest;\n options: TemplateUIOptions;\n metaScripts?: string[];\n scriptsBodyAfter?: string[];\n scriptsbodyBefore?: string[];\n};\n\n// the outcome of the Webpack Manifest Plugin\nexport interface WebpackManifest {\n [key: string]: string;\n}\n\nexport default function renderTemplate(template: Template, manifest: WebpackManifest) {\n debug('template %o', template);\n debug('manifest %o', manifest);\n\n return `\n <!DOCTYPE html>\n <html lang=\"en-us\"> \n <head>\n <meta charset=\"utf-8\">\n <base href=\"${template?.options.base}\">\n <title>${template?.options?.title ?? ''}</title> \n <link rel=\"icon\" href=\"${template?.options.base}-/static/favicon.ico\"/>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /> \n <script>\n window.__VERDACCIO_BASENAME_UI_OPTIONS=${JSON.stringify(template.options)}\n </script>\n ${template?.metaScripts ? template.metaScripts.join('') : ''}\n </head> \n <body class=\"body\">\n ${template?.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}\n <div id=\"root\"></div>\n ${getManifestValue(template.manifest.js, manifest, template?.options.base)\n .map((item) => `<script defer=\"defer\" src=\"${item}\"></script>`)\n .join('')}\n ${template?.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''}\n </body>\n </html>\n `;\n}\n"],"file":"template.js"}
1
+ {"version":3,"file":"template.js","names":["debug","buildDebug","renderTemplate","template","manifest","options","base","title","JSON","stringify","metaScripts","join","scriptsbodyBefore","getManifestValue","js","map","item","scriptsBodyAfter"],"sources":["../src/template.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nimport { TemplateUIOptions } from '@verdaccio/types';\n\nimport { Manifest, getManifestValue } from './utils/manifest';\n\nconst debug = buildDebug('verdaccio:web:render:template');\n\nexport type Template = {\n manifest: Manifest;\n options: TemplateUIOptions;\n metaScripts?: string[];\n scriptsBodyAfter?: string[];\n scriptsbodyBefore?: string[];\n};\n\n// the outcome of the Webpack Manifest Plugin\nexport interface WebpackManifest {\n [key: string]: string;\n}\n\nexport default function renderTemplate(template: Template, manifest: WebpackManifest) {\n debug('template %o', template);\n debug('manifest %o', manifest);\n\n return `\n <!DOCTYPE html>\n <html lang=\"en-us\"> \n <head>\n <meta charset=\"utf-8\">\n <base href=\"${template?.options.base}\">\n <title>${template?.options?.title ?? ''}</title> \n <link rel=\"icon\" href=\"${template?.options.base}-/static/favicon.ico\"/>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /> \n <script>\n window.__VERDACCIO_BASENAME_UI_OPTIONS=${JSON.stringify(template.options)}\n </script>\n ${template?.metaScripts ? template.metaScripts.join('') : ''}\n </head> \n <body class=\"body\">\n ${template?.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}\n <div id=\"root\"></div>\n ${getManifestValue(template.manifest.js, manifest, template?.options.base)\n .map((item) => `<script defer=\"defer\" src=\"${item}\"></script>`)\n .join('')}\n ${template?.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''}\n </body>\n </html>\n `;\n}\n"],"mappings":";;;;;;;AAAA;;AAIA;;;;AAEA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,+BAAX,CAAd;;AAee,SAASC,cAAT,CAAwBC,QAAxB,EAA4CC,QAA5C,EAAuE;EAAA;;EACpFJ,KAAK,CAAC,aAAD,EAAgBG,QAAhB,CAAL;EACAH,KAAK,CAAC,aAAD,EAAgBI,QAAhB,CAAL;EAEA,OAAQ;AACV;AACA;AACA;AACA;AACA,sBAAsBD,QALb,aAKaA,QALb,uBAKaA,QAAQ,CAAEE,OAAV,CAAkBC,IAAK;AAC7C,iBAAiB,CAAAH,QAAQ,SAAR,IAAAA,QAAQ,WAAR,iCAAAA,QAAQ,CAAEE,OAAV,wEAAmBE,KAAnB,KAA4B,EAAG;AAChD,iCAAiCJ,QAPxB,aAOwBA,QAPxB,uBAOwBA,QAAQ,CAAEE,OAAV,CAAkBC,IAAK;AACxD;AACA;AACA,qDAAqDE,IAAI,CAACC,SAAL,CAAeN,QAAQ,CAACE,OAAxB,CAAiC;AACtF;AACA,UAAUF,QAAQ,SAAR,IAAAA,QAAQ,WAAR,IAAAA,QAAQ,CAAEO,WAAV,GAAwBP,QAAQ,CAACO,WAAT,CAAqBC,IAArB,CAA0B,EAA1B,CAAxB,GAAwD,EAAG;AACrE;AACA;AACA,QAAQR,QAAQ,SAAR,IAAAA,QAAQ,WAAR,IAAAA,QAAQ,CAAES,iBAAV,GAA8BT,QAAQ,CAACS,iBAAT,CAA2BD,IAA3B,CAAgC,EAAhC,CAA9B,GAAoE,EAAG;AAC/E;AACA,UAAU,IAAAE,0BAAA,EAAiBV,QAAQ,CAACC,QAAT,CAAkBU,EAAnC,EAAuCV,QAAvC,EAAiDD,QAAjD,aAAiDA,QAAjD,uBAAiDA,QAAQ,CAAEE,OAAV,CAAkBC,IAAnE,EACCS,GADD,CACMC,IAAD,IAAW,8BAA6BA,IAAK,aADlD,EAECL,IAFD,CAEM,EAFN,CAEU;AACpB,UAAUR,QAAQ,SAAR,IAAAA,QAAQ,WAAR,IAAAA,QAAQ,CAAEc,gBAAV,GAA6Bd,QAAQ,CAACc,gBAAT,CAA0BN,IAA1B,CAA+B,EAA/B,CAA7B,GAAkE,EAAG;AAC/E;AACA;AACA,GAvBE;AAwBD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/manifest.ts"],"names":["debug","getManifestValue","manifestItems","manifest","basePath","map","item","resolvedItem"],"mappings":";;;;;;;AAAA;;;;AASA,MAAMA,KAAK,GAAG,oBAAW,+BAAX,CAAd;;AAEO,SAASC,gBAAT,CACLC,aADK,EAELC,QAFK,EAGLC,QAAgB,GAAG,EAHd,EAIK;AACV,SAAOF,aAAP,aAAOA,aAAP,uBAAOA,aAAa,CAAEG,GAAf,CAAoBC,IAAD,IAAU;AAClCN,IAAAA,KAAK,CAAC,iBAAD,EAAoBM,IAApB,CAAL;AACA,UAAMC,YAAY,GAAI,GAAEH,QAAS,GAAED,QAAQ,CAACG,IAAD,CAAO,EAAlD;AACAN,IAAAA,KAAK,CAAC,kBAAD,EAAqBO,YAArB,CAAL;AACA,WAAOA,YAAP;AACD,GALM,CAAP;AAMD","sourcesContent":["import buildDebug from 'debug';\n\nexport type Manifest = {\n // goes on first place at the header\n ico: string;\n css: string[];\n js: string[];\n};\n\nconst debug = buildDebug('verdaccio:web:render:manifest');\n\nexport function getManifestValue(\n manifestItems: string[],\n manifest,\n basePath: string = ''\n): string[] {\n return manifestItems?.map((item) => {\n debug('resolve item %o', item);\n const resolvedItem = `${basePath}${manifest[item]}`;\n debug('resolved item %o', resolvedItem);\n return resolvedItem;\n });\n}\n"],"file":"manifest.js"}
1
+ {"version":3,"file":"manifest.js","names":["debug","buildDebug","getManifestValue","manifestItems","manifest","basePath","map","item","resolvedItem"],"sources":["../../src/utils/manifest.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nexport type Manifest = {\n // goes on first place at the header\n ico: string;\n css: string[];\n js: string[];\n};\n\nconst debug = buildDebug('verdaccio:web:render:manifest');\n\nexport function getManifestValue(\n manifestItems: string[],\n manifest,\n basePath: string = ''\n): string[] {\n return manifestItems?.map((item) => {\n debug('resolve item %o', item);\n const resolvedItem = `${basePath}${manifest[item]}`;\n debug('resolved item %o', resolvedItem);\n return resolvedItem;\n });\n}\n"],"mappings":";;;;;;;AAAA;;;;AASA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,+BAAX,CAAd;;AAEO,SAASC,gBAAT,CACLC,aADK,EAELC,QAFK,EAGLC,QAAgB,GAAG,EAHd,EAIK;EACV,OAAOF,aAAP,aAAOA,aAAP,uBAAOA,aAAa,CAAEG,GAAf,CAAoBC,IAAD,IAAU;IAClCP,KAAK,CAAC,iBAAD,EAAoBO,IAApB,CAAL;IACA,MAAMC,YAAY,GAAI,GAAEH,QAAS,GAAED,QAAQ,CAACG,IAAD,CAAO,EAAlD;IACAP,KAAK,CAAC,kBAAD,EAAqBQ,YAArB,CAAL;IACA,OAAOA,YAAP;EACD,CALM,CAAP;AAMD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/web-utils.ts"],"names":["debug","validatePrimaryColor","primaryColor","isHex","test","parseReadme","packageName","readme","_","isEmpty","Error","deleteProperties","propertiesToDelete","objectItem","forEach","property","addScope","scope","sortByName","packages","orderAscending","slice","sort","a","b","comparatorNames","name","toLowerCase","hasLogin","config","isNil","web","login"],"mappings":";;;;;;;;;;;;AAAA;;AACA;;AAEA;;;;AAMA,MAAMA,KAAK,GAAG,oBAAW,qBAAX,CAAd;;AAEO,SAASC,oBAAT,CAA8BC,YAA9B,EAA4C;AACjD,QAAMC,KAAK,GAAG,yBAAyBC,IAAzB,CA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,SAAOrB,gBAAEsB,KAAF,CAAQD,MAAR,aAAQA,MAAR,sCAAQA,MAAM,CAAEE,GAAhB,gDAAQ,YAAaC,KAArB,KAA+B,CAAAH,MAAM,SAAN,IAAAA,MAAM,WAAN,4BAAAA,MAAM,CAAEE,GAAR,8DAAaC,KAAb,MAAuB,IAA7D;AACD","sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport sanitizyReadme from '@verdaccio/readme';\n// import { normalizeContributors } from '@verdaccio/store';\nimport { Author, ConfigYaml } from '@verdaccio/types';\n\nexport type AuthorAvatar = Author & { avatar?: string };\n\nconst debug = buildDebug('verdaccio:web:utils');\n\nexport function validatePrimaryColor(primaryColor) {\n const isHex = /^#([0-9A-F]{3}){1,2}$/i.test(primaryColor);\n if (!isHex) {\n debug('invalid primary color %o', primaryColor);\n return;\n }\n\n return primaryColor;\n}\n\n/**\n * parse package readme - markdown/ascii\n * @param {String} packageName name of package\n * @param {String} readme package readme\n * @return {String} converted html template\n */\nexport function parseReadme(packageName: string, readme: string): string | void {\n if (_.isEmpty(readme) === false) {\n debug('sanizity readme');\n return sanitizyReadme(readme);\n }\n\n // logs readme not found error\n // logger.error({ packageName }, '@{packageName}: No readme found');\n throw new Error('ERROR: No README data found!');\n}\n\nexport function deleteProperties(propertiesToDelete: string[], objectItem: any): any {\n debug('deleted unused version properties');\n _.forEach(propertiesToDelete, (property): any => {\n delete objectItem[property];\n });\n\n return objectItem;\n}\n\nexport function addScope(scope: string, packageName: string): string {\n return `@${scope}/${packageName}`;\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 hasLogin(config: ConfigYaml) {\n return _.isNil(config?.web?.login) || config?.web?.login === true;\n}\n"],"file":"web-utils.js"}
1
+ {"version":3,"file":"web-utils.js","names":["debug","buildDebug","validatePrimaryColor","primaryColor","isHex","test","parseReadme","packageName","readme","_","isEmpty","sanitizyReadme","Error","deleteProperties","propertiesToDelete","objectItem","forEach","property","addScope","scope","sortByName","packages","orderAscending","slice","sort","a","b","comparatorNames","name","toLowerCase","hasLogin","config","isNil","web","login"],"sources":["../../src/utils/web-utils.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport sanitizyReadme from '@verdaccio/readme';\n// import { normalizeContributors } from '@verdaccio/store';\nimport { Author, ConfigYaml } from '@verdaccio/types';\n\nexport type AuthorAvatar = Author & { avatar?: string };\n\nconst debug = buildDebug('verdaccio:web:utils');\n\nexport function validatePrimaryColor(primaryColor) {\n const isHex = /^#([0-9A-F]{3}){1,2}$/i.test(primaryColor);\n if (!isHex) {\n debug('invalid primary color %o', primaryColor);\n return;\n }\n\n return primaryColor;\n}\n\n/**\n * parse package readme - markdown/ascii\n * @param {String} packageName name of package\n * @param {String} readme package readme\n * @return {String} converted html template\n */\nexport function parseReadme(packageName: string, readme: string): string | void {\n if (_.isEmpty(readme) === false) {\n debug('sanizity readme');\n return sanitizyReadme(readme);\n }\n\n // logs readme not found error\n // logger.error({ packageName }, '@{packageName}: No readme found');\n throw new Error('ERROR: No README data found!');\n}\n\nexport function deleteProperties(propertiesToDelete: string[], objectItem: any): any {\n debug('deleted unused version properties');\n _.forEach(propertiesToDelete, (property): any => {\n delete objectItem[property];\n });\n\n return objectItem;\n}\n\nexport function addScope(scope: string, packageName: string): string {\n return `@${scope}/${packageName}`;\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 hasLogin(config: ConfigYaml) {\n return _.isNil(config?.web?.login) || config?.web?.login === true;\n}\n"],"mappings":";;;;;;;;;;;;AAAA;;AACA;;AA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AG,CAAC,CAAJ,GAAQ,CAA3B,GAAgCA,eAAe,GAAG,CAAH,GAAO,CAAC,CAA5E;EACD,CAHM,CAAP;AAID;;AAEM,SAASG,QAAT,CAAkBC,MAAlB,EAAsC;EAAA;;EAC3C,OAAOtB,eAAA,CAAEuB,KAAF,CAAQD,MAAR,aAAQA,MAAR,sCAAQA,MAAM,CAAEE,GAAhB,gDAAQ,YAAaC,KAArB,KAA+B,CAAAH,MAAM,SAAN,IAAAA,MAAM,WAAN,4BAAAA,MAAM,CAAEE,GAAR,8DAAaC,KAAb,MAAuB,IAA7D;AACD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/web-middleware.ts"],"names":["config","auth","storage","app","express","Router","use"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;eAEe,CAACA,MAAD,EAASC,IAAT,EAAeC,OAAf,KAA2B;AACxC;AACA,QAAMC,GAAG,GAAGC,iBAAQC,MAAR,EAAZ,CAFwC,CAGxC;;;AACAF,EAAAA,GAAG,CAACG,GAAJ,CAAQ,GAAR,EAAa,oCAAoBN,MAApB,EAA4BC,IAA5B,CAAb,EAJwC,CAKxC;;AACAE,EAAAA,GAAG,CAACG,GAAJ,CAAQ,eAAR,EAAyB,oBAAON,MAAP,EAAeC,IAAf,EAAqBC,OAArB,CAAzB;AACA,SAAOC,GAAP;AACD,C","sourcesContent":["import express from 'express';\n\nimport { renderWebMiddleware } from './middleware/render-web';\nimport { webAPI } from './middleware/web-api';\n\nexport default (config, auth, storage) => {\n // eslint-disable-next-line new-cap\n const app = express.Router();\n // load application\n app.use('/', renderWebMiddleware(config, auth));\n // web endpoints, search, packages, etc\n app.use('/-/verdaccio/', webAPI(config, auth, storage));\n return app;\n};\n"],"file":"web-middleware.js"}
1
+ {"version":3,"file":"web-middleware.js","names":["config","auth","storage","app","express","Router","use","renderWebMiddleware","webAPI"],"sources":["../src/web-middleware.ts"],"sourcesContent":["import express from 'express';\n\nimport { renderWebMiddleware } from './middleware/render-web';\nimport { webAPI } from './middleware/web-api';\n\nexport default (config, auth, storage) => {\n // eslint-disable-next-line new-cap\n const app = express.Router();\n // load application\n app.use('/', renderWebMiddleware(config, auth));\n // web endpoints, search, packages, etc\n app.use('/-/verdaccio/', webAPI(config, auth, storage));\n return app;\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;eAEe,CAACA,MAAD,EAASC,IAAT,EAAeC,OAAf,KAA2B;EACxC;EACA,MAAMC,GAAG,GAAGC,gBAAA,CAAQC,MAAR,EAAZ,CAFwC,CAGxC;;;EACAF,GAAG,CAACG,GAAJ,CAAQ,GAAR,EAAa,IAAAC,8BAAA,EAAoBP,MAApB,EAA4BC,IAA5B,CAAb,EAJwC,CAKxC;;EACAE,GAAG,CAACG,GAAJ,CAAQ,eAAR,EAAyB,IAAAE,cAAA,EAAOR,MAAP,EAAeC,IAAf,EAAqBC,OAArB,CAAzB;EACA,OAAOC,GAAP;AACD,C"}
package/jest.config.js CHANGED
@@ -1,3 +1,10 @@
1
1
  const config = require('../../jest/config');
2
2
 
3
- module.exports = Object.assign({}, config, {});
3
+ module.exports = Object.assign({}, config, {
4
+ coverageThreshold: {
5
+ global: {
6
+ // FIXME: increase to 90
7
+ lines: 79,
8
+ },
9
+ },
10
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/web",
3
- "version": "6.0.0-6-next.29",
3
+ "version": "6.0.0-6-next.32",
4
4
  "description": "web ui middleware",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -25,35 +25,35 @@
25
25
  },
26
26
  "license": "MIT",
27
27
  "dependencies": {
28
- "@verdaccio/auth": "6.0.0-6-next.22",
29
- "@verdaccio/core": "6.0.0-6-next.5",
30
- "@verdaccio/config": "6.0.0-6-next.14",
31
- "@verdaccio/loaders": "6.0.0-6-next.12",
32
- "@verdaccio/logger": "6.0.0-6-next.11",
33
- "@verdaccio/middleware": "6.0.0-6-next.22",
34
- "@verdaccio/readme": "11.0.0-6-next.4",
35
- "@verdaccio/store": "6.0.0-6-next.22",
36
- "@verdaccio/tarball": "11.0.0-6-next.12",
37
- "@verdaccio/url": "11.0.0-6-next.9",
38
- "@verdaccio/utils": "6.0.0-6-next.11",
39
- "body-parser": "1.19.1",
40
- "debug": "4.3.3",
41
- "express": "4.17.2",
28
+ "@verdaccio/auth": "6.0.0-6-next.24",
29
+ "@verdaccio/core": "6.0.0-6-next.7",
30
+ "@verdaccio/config": "6.0.0-6-next.16",
31
+ "@verdaccio/loaders": "6.0.0-6-next.14",
32
+ "@verdaccio/logger": "6.0.0-6-next.13",
33
+ "@verdaccio/middleware": "6.0.0-6-next.24",
34
+ "@verdaccio/readme": "11.0.0-6-next.6",
35
+ "@verdaccio/store": "6.0.0-6-next.25",
36
+ "@verdaccio/tarball": "11.0.0-6-next.14",
37
+ "@verdaccio/url": "11.0.0-6-next.11",
38
+ "@verdaccio/utils": "6.0.0-6-next.13",
39
+ "body-parser": "1.20.0",
40
+ "debug": "4.3.4",
41
+ "express": "4.18.1",
42
42
  "lodash": "4.17.21",
43
43
  "lru-cache": "6.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@types/node": "16.11.21",
47
- "@verdaccio/types": "11.0.0-6-next.12",
48
- "@verdaccio/test-helper": "1.1.0-6-next.1",
49
- "@verdaccio/api": "6.0.0-6-next.25",
46
+ "@types/node": "16.11.56",
47
+ "@verdaccio/types": "11.0.0-6-next.15",
48
+ "@verdaccio/test-helper": "1.1.0-6-next.3",
49
+ "@verdaccio/api": "6.0.0-6-next.28",
50
50
  "node-html-parser": "4.1.5",
51
- "supertest": "6.2.2",
52
- "nock": "13.2.2",
51
+ "supertest": "6.2.4",
52
+ "nock": "13.2.9",
53
53
  "jsdom": "20.0.0",
54
- "undici": "4.15.0",
55
- "verdaccio-auth-memory": "11.0.0-6-next.8",
56
- "verdaccio-memory": "11.0.0-6-next.10"
54
+ "undici": "4.16.0",
55
+ "verdaccio-auth-memory": "11.0.0-6-next.10",
56
+ "verdaccio-memory": "11.0.0-6-next.12"
57
57
  },
58
58
  "funding": {
59
59
  "type": "opencollective",
@@ -7,10 +7,10 @@ import { logger } from '@verdaccio/logger';
7
7
  import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '@verdaccio/middleware';
8
8
  import { Storage } from '@verdaccio/store';
9
9
  import { getLocalRegistryTarballUri } from '@verdaccio/tarball';
10
- import { Config, Package, RemoteUser } from '@verdaccio/types';
10
+ import { Config, RemoteUser, Version } from '@verdaccio/types';
11
11
  import { formatAuthor, generateGravatarUrl } from '@verdaccio/utils';
12
12
 
13
- import { AuthorAvatar, sortByName } from '../utils/web-utils';
13
+ import { sortByName } from '../utils/web-utils';
14
14
 
15
15
  export { $RequestExtend, $ResponseExtend, $NextFunctionVer }; // Was required by other packages
16
16
 
@@ -18,8 +18,6 @@ const getOrder = (order = 'asc') => {
18
18
  return order === 'asc';
19
19
  };
20
20
 
21
- export type PackageExt = Package & { author: AuthorAvatar; dist?: { tarball: string } };
22
-
23
21
  const debug = buildDebug('verdaccio:web:api:package');
24
22
 
25
23
  function addPackageWebApi(storage: Storage, auth: IAuth, config: Config): Router {
@@ -50,66 +48,67 @@ function addPackageWebApi(storage: Storage, auth: IAuth, config: Config): Router
50
48
  }
51
49
  });
52
50
 
51
+ async function processPackages(packages: Version[] = [], req): Promise<Version[]> {
52
+ const permissions: Version[] = [];
53
+ const packagesToProcess = packages.slice();
54
+ debug('process packages %o', packagesToProcess);
55
+ for (const pkg of packagesToProcess) {
56
+ const pkgCopy = { ...pkg };
57
+ pkgCopy.author = formatAuthor(pkg.author);
58
+ try {
59
+ if (await checkAllow(pkg.name, req.remote_user)) {
60
+ if (config.web) {
61
+ // @ts-ignore
62
+ pkgCopy.author.avatar = generateGravatarUrl(pkgCopy.author.email, config.web.gravatar);
63
+ }
64
+ // convert any remote dist to a local reference
65
+ // eg: if the dist points to npmjs, switch to localhost:4873/prefix/etc.tar.gz
66
+ if (!_.isNil(pkgCopy.dist) && !_.isNull(pkgCopy.dist.tarball)) {
67
+ pkgCopy.dist.tarball = getLocalRegistryTarballUri(
68
+ pkgCopy.dist.tarball,
69
+ pkg.name,
70
+ { protocol: req.protocol, headers: req.headers as any, host: req.hostname },
71
+ config?.url_prefix
72
+ );
73
+ }
74
+ permissions.push(pkgCopy);
75
+ }
76
+ } catch (err: any) {
77
+ debug('process packages error %o', err);
78
+ logger.error(
79
+ { name: pkg.name, error: err },
80
+ 'permission process for @{name} has failed: @{error}'
81
+ );
82
+ throw err;
83
+ }
84
+ }
85
+
86
+ return permissions;
87
+ }
88
+
53
89
  // Get list of all visible package
54
90
  pkgRouter.get(
55
91
  '/packages',
56
- function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
92
+ async function (
93
+ req: $RequestExtend,
94
+ res: $ResponseExtend,
95
+ next: $NextFunctionVer
96
+ ): Promise<void> {
57
97
  debug('hit package web api %o');
58
- storage.getLocalDatabase(async function (err, packages): Promise<void> {
59
- if (err) {
60
- throw err;
61
- }
62
- async function processPackages(packages: PackageExt[] = []): Promise<PackageExt[]> {
63
- const permissions: PackageExt[] = [];
64
- const packagesToProcess = packages.slice();
65
- debug('process packages %o', packagesToProcess);
66
- for (const pkg of packagesToProcess) {
67
- const pkgCopy = { ...pkg };
68
- pkgCopy.author = formatAuthor(pkg.author);
69
- try {
70
- if (await checkAllow(pkg.name, req.remote_user)) {
71
- if (config.web) {
72
- pkgCopy.author.avatar = generateGravatarUrl(
73
- pkgCopy.author.email,
74
- config.web.gravatar
75
- );
76
- }
77
- // convert any remote dist to a local reference
78
- // eg: if the dist points to npmjs, switch to localhost:4873/prefix/etc.tar.gz
79
- if (!_.isNil(pkgCopy.dist) && !_.isNull(pkgCopy.dist.tarball)) {
80
- pkgCopy.dist.tarball = getLocalRegistryTarballUri(
81
- pkgCopy.dist.tarball,
82
- pkg.name,
83
- { protocol: req.protocol, headers: req.headers as any, host: req.hostname },
84
- config?.url_prefix
85
- );
86
- }
87
- permissions.push(pkgCopy);
88
- }
89
- } catch (err: any) {
90
- debug('process packages error %o', err);
91
- logger.logger.error(
92
- { name: pkg.name, error: err },
93
- 'permission process for @{name} has failed: @{error}'
94
- );
95
- throw err;
96
- }
97
- }
98
98
 
99
- return permissions;
100
- }
99
+ try {
100
+ const localPackages: Version[] = await storage.getLocalDatabaseNext();
101
101
 
102
102
  const order = getOrder(config?.web?.sort_packages);
103
103
  debug('order %o', order);
104
-
105
- try {
106
- next(sortByName(await processPackages(packages), order));
107
- } catch (error: any) {
108
- next(error);
109
- }
110
- });
104
+ const pkgs = await processPackages(localPackages, req);
105
+ next(sortByName(pkgs, order));
106
+ } catch (error: any) {
107
+ next(error);
108
+ }
111
109
  }
112
110
  );
111
+
113
112
  return pkgRouter;
114
113
  }
115
114
 
package/src/api/readme.ts CHANGED
@@ -6,13 +6,14 @@ import { HEADERS, HEADER_TYPE } from '@verdaccio/core';
6
6
  import { $NextFunctionVer, $RequestExtend, $ResponseExtend, allow } from '@verdaccio/middleware';
7
7
  import sanitizyReadme from '@verdaccio/readme';
8
8
  import { Storage } from '@verdaccio/store';
9
- import { Package } from '@verdaccio/types';
9
+ import { Manifest } from '@verdaccio/types';
10
10
 
11
11
  import { AuthorAvatar, addScope, parseReadme } from '../utils/web-utils';
12
12
 
13
13
  export { $RequestExtend, $ResponseExtend, $NextFunctionVer }; // Was required by other packages
14
14
 
15
- export type PackageExt = Package & { author: AuthorAvatar; dist?: { tarball: string } };
15
+ // TODO: review this type, should be on @verdacid/types
16
+ export type PackageExt = Manifest & { author: AuthorAvatar; dist?: { tarball: string } };
16
17
 
17
18
  const debug = buildDebug('verdaccio:web:api:readme');
18
19
 
@@ -26,31 +27,40 @@ function addReadmeWebApi(storage: Storage, auth: IAuth): Router {
26
27
  pkgRouter.get(
27
28
  '/package/readme/(@:scope/)?:package/:version?',
28
29
  can('access'),
29
- function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
30
+ async function (
31
+ req: $RequestExtend,
32
+ res: $ResponseExtend,
33
+ next: $NextFunctionVer
34
+ ): Promise<void> {
30
35
  debug('readme hit');
31
- const packageName = req.params.scope
36
+ const name = req.params.scope
32
37
  ? addScope(req.params.scope, req.params.package)
33
38
  : req.params.package;
34
- debug('readme name %o', packageName);
35
-
36
- // @ts-ignore
37
- storage.getPackage({
38
- name: packageName,
39
- uplinksLook: true,
40
- req,
41
- callback: function (err, info): void {
42
- debug('readme pkg %o', info?.name);
43
- res.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_PLAIN_UTF8);
44
- if (err) {
45
- return next(err);
46
- }
47
- try {
48
- next(parseReadme(info.name, info.readme));
49
- } catch {
50
- next(sanitizyReadme(NOT_README_FOUND));
51
- }
52
- },
53
- });
39
+ debug('readme name %o', name);
40
+ const requestOptions = {
41
+ protocol: req.protocol,
42
+ headers: req.headers as any,
43
+ // FIXME: if we migrate to req.hostname, the port is not longer included.
44
+ host: req.host,
45
+ remoteAddress: req.socket.remoteAddress,
46
+ };
47
+ try {
48
+ const manifest = (await storage.getPackageByOptions({
49
+ name,
50
+ uplinksLook: true,
51
+ abbreviated: false,
52
+ requestOptions,
53
+ })) as Manifest;
54
+ debug('readme pkg %o', manifest?.name);
55
+ res.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_PLAIN_UTF8);
56
+ try {
57
+ next(parseReadme(manifest.name, manifest.readme as string));
58
+ } catch {
59
+ next(sanitizyReadme(NOT_README_FOUND));
60
+ }
61
+ } catch (err) {
62
+ next(err);
63
+ }
54
64
  }
55
65
  );
56
66
  return pkgRouter;
package/src/api/search.ts CHANGED
@@ -64,7 +64,7 @@ function addSearchWebApi(storage: Storage, auth: IAuth): Router {
64
64
  // @ts-ignore
65
65
  const urlParams = new URLSearchParams(query);
66
66
  debug('search web init');
67
- data = await storage.searchManager?.search({
67
+ data = await storage?.search({
68
68
  query,
69
69
  url: `/-/v1/search?${urlParams.toString()}`,
70
70
  abort,