@verdaccio/web 9.0.0-next-9.3 → 9.0.0-next-9.5
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/_virtual/_rolldown/runtime.js +23 -0
- package/build/_virtual/_rolldown/runtime.mjs +7 -0
- package/build/api/index.d.ts +1 -1
- package/build/api/index.js +26 -37
- package/build/api/index.js.map +1 -1
- package/build/api/index.mjs +27 -0
- package/build/api/index.mjs.map +1 -0
- package/build/api/package.d.ts +3 -3
- package/build/api/package.js +79 -200
- package/build/api/package.js.map +1 -1
- package/build/api/package.mjs +80 -0
- package/build/api/package.mjs.map +1 -0
- package/build/api/readme.d.ts +2 -2
- package/build/api/readme.js +64 -122
- package/build/api/readme.js.map +1 -1
- package/build/api/readme.mjs +67 -0
- package/build/api/readme.mjs.map +1 -0
- package/build/api/search.d.ts +2 -2
- package/build/api/search.js +57 -99
- package/build/api/search.js.map +1 -1
- package/build/api/search.mjs +59 -0
- package/build/api/search.mjs.map +1 -0
- package/build/api/sidebar.d.ts +3 -3
- package/build/api/sidebar.js +56 -109
- package/build/api/sidebar.js.map +1 -1
- package/build/api/sidebar.mjs +57 -0
- package/build/api/sidebar.mjs.map +1 -0
- package/build/api/user.d.ts +2 -2
- package/build/api/user.js +97 -212
- package/build/api/user.js.map +1 -1
- package/build/api/user.mjs +97 -0
- package/build/api/user.mjs.map +1 -0
- package/build/author-utils.d.ts +1 -1
- package/build/author-utils.js +109 -160
- package/build/author-utils.js.map +1 -1
- package/build/author-utils.mjs +117 -0
- package/build/author-utils.mjs.map +1 -0
- package/build/index.js +18 -47
- package/build/index.mjs +4 -0
- package/build/middleware.d.ts +1 -1
- package/build/middleware.js +49 -90
- package/build/middleware.js.map +1 -1
- package/build/middleware.mjs +48 -0
- package/build/middleware.mjs.map +1 -0
- package/build/web-utils.d.ts +2 -1
- package/build/web-utils.js +31 -31
- package/build/web-utils.js.map +1 -1
- package/build/web-utils.mjs +34 -0
- package/build/web-utils.mjs.map +1 -0
- package/package.json +30 -19
- package/build/index.js.map +0 -1
package/build/author-utils.js
CHANGED
|
@@ -1,172 +1,121 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
15
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
-
var AVATAR_PROVIDER = 'https://www.gravatar.com/avatar/';
|
|
18
|
-
var 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>');
|
|
19
|
-
|
|
1
|
+
require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
let _verdaccio_core = require("@verdaccio/core");
|
|
3
|
+
//#region src/author-utils.ts
|
|
4
|
+
var AVATAR_PROVIDER = "https://www.gravatar.com/avatar/";
|
|
5
|
+
var 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=\"74\" 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-path=\"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\" overflow=\"visible\" xlink:href=\"#c\"/><clipPath id=\"d\"><use overflow=\"visible\" xlink:href=\"#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>");
|
|
20
6
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
* Formats author field for webui.
|
|
8
|
+
* @see https://docs.npmjs.com/files/package.json#author
|
|
9
|
+
* @param {string|object|undefined} author
|
|
10
|
+
*/
|
|
25
11
|
function formatAuthor(author) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
return authorDetails;
|
|
12
|
+
let authorDetails = {
|
|
13
|
+
name: _verdaccio_core.DEFAULT_USER,
|
|
14
|
+
email: "",
|
|
15
|
+
url: ""
|
|
16
|
+
};
|
|
17
|
+
if (author === null || author === void 0) return authorDetails;
|
|
18
|
+
if (typeof author === "string") authorDetails = {
|
|
19
|
+
...authorDetails,
|
|
20
|
+
name: author
|
|
21
|
+
};
|
|
22
|
+
if (typeof author === "object") authorDetails = {
|
|
23
|
+
...authorDetails,
|
|
24
|
+
...author
|
|
25
|
+
};
|
|
26
|
+
return authorDetails;
|
|
43
27
|
}
|
|
44
|
-
function addGravatarSupport(pkgInfo) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// for maintainers
|
|
92
|
-
if (maintainers && maintainers.length > 0) {
|
|
93
|
-
pkgInfoCopy.latest.maintainers = maintainers.map(function (maintainer) {
|
|
94
|
-
if (_typeof(maintainer) === 'object') {
|
|
95
|
-
maintainer._avatar = generateGravatarUrl(maintainer.email, online);
|
|
96
|
-
} else if (typeof maintainer === 'string') {
|
|
97
|
-
var _splitAuthorString3 = splitAuthorString(maintainer),
|
|
98
|
-
_email3 = _splitAuthorString3.email,
|
|
99
|
-
_name2 = _splitAuthorString3.name,
|
|
100
|
-
_url2 = _splitAuthorString3.url;
|
|
101
|
-
maintainer = {
|
|
102
|
-
_avatar: generateGravatarUrl(_email3, online),
|
|
103
|
-
email: _email3,
|
|
104
|
-
name: _name2,
|
|
105
|
-
url: _url2
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
return maintainer;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
return pkgInfoCopy;
|
|
28
|
+
function addGravatarSupport(pkgInfo, online = true) {
|
|
29
|
+
const pkgInfoCopy = { ...pkgInfo };
|
|
30
|
+
const author = pkgInfo?.latest?.author ?? null;
|
|
31
|
+
const contributors = normalizeAuthors(pkgInfo?.latest?.contributors ?? []);
|
|
32
|
+
const maintainers = normalizeAuthors(pkgInfo?.latest?.maintainers ?? []);
|
|
33
|
+
if (author && typeof author === "object") {
|
|
34
|
+
const { email } = author;
|
|
35
|
+
pkgInfoCopy.latest.author._avatar = generateGravatarUrl(email, online);
|
|
36
|
+
} else if (author && typeof author === "string") {
|
|
37
|
+
const { email, name, url } = splitAuthorString(author);
|
|
38
|
+
pkgInfoCopy.latest.author = {
|
|
39
|
+
_avatar: generateGravatarUrl(email, online),
|
|
40
|
+
email,
|
|
41
|
+
name,
|
|
42
|
+
url
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (contributors && contributors.length > 0) pkgInfoCopy.latest.contributors = contributors.map((contributor) => {
|
|
46
|
+
if (typeof contributor === "object") contributor._avatar = generateGravatarUrl(contributor.email, online);
|
|
47
|
+
else if (typeof contributor === "string") {
|
|
48
|
+
const { email, name, url } = splitAuthorString(contributor);
|
|
49
|
+
contributor = {
|
|
50
|
+
_avatar: generateGravatarUrl(email, online),
|
|
51
|
+
email,
|
|
52
|
+
name,
|
|
53
|
+
url
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return contributor;
|
|
57
|
+
});
|
|
58
|
+
if (maintainers && maintainers.length > 0) pkgInfoCopy.latest.maintainers = maintainers.map((maintainer) => {
|
|
59
|
+
if (typeof maintainer === "object") maintainer._avatar = generateGravatarUrl(maintainer.email, online);
|
|
60
|
+
else if (typeof maintainer === "string") {
|
|
61
|
+
const { email, name, url } = splitAuthorString(maintainer);
|
|
62
|
+
maintainer = {
|
|
63
|
+
_avatar: generateGravatarUrl(email, online),
|
|
64
|
+
email,
|
|
65
|
+
name,
|
|
66
|
+
url
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return maintainer;
|
|
70
|
+
});
|
|
71
|
+
return pkgInfoCopy;
|
|
112
72
|
}
|
|
113
|
-
|
|
114
73
|
/**
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
function generateGravatarUrl() {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return "".concat(AVATAR_PROVIDER).concat(emailMD5);
|
|
124
|
-
}
|
|
125
|
-
return GENERIC_AVATAR;
|
|
74
|
+
* Generate gravatar url from email address
|
|
75
|
+
*/
|
|
76
|
+
function generateGravatarUrl(email = "", online = true) {
|
|
77
|
+
if (online && typeof email === "string" && email.length > 0) {
|
|
78
|
+
email = email.trim().toLocaleLowerCase();
|
|
79
|
+
return `${AVATAR_PROVIDER}${_verdaccio_core.cryptoUtils.stringToMD5(email)}`;
|
|
80
|
+
}
|
|
81
|
+
return GENERIC_AVATAR;
|
|
126
82
|
}
|
|
127
83
|
function normalizeAuthors(authors) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
} else if (typeof authors === 'string') {
|
|
133
|
-
return [{
|
|
134
|
-
name: authors
|
|
135
|
-
}];
|
|
136
|
-
}
|
|
137
|
-
return authors;
|
|
84
|
+
if (authors === null || authors === void 0) return [];
|
|
85
|
+
else if (authors && !Array.isArray(authors)) return [authors];
|
|
86
|
+
else if (typeof authors === "string") return [{ name: authors }];
|
|
87
|
+
return authors;
|
|
138
88
|
}
|
|
139
|
-
|
|
140
89
|
/**
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
90
|
+
* Split author string into name, email and url
|
|
91
|
+
* Example: "Barney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)"
|
|
92
|
+
* @param {string} author
|
|
93
|
+
* @returns {Object} { name: string, email: string, url: string }
|
|
94
|
+
*/
|
|
146
95
|
function splitAuthorString(author) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
return {
|
|
167
|
-
name: name || author,
|
|
168
|
-
email: email,
|
|
169
|
-
url: url
|
|
170
|
-
};
|
|
96
|
+
const truncatedAuthor = author.slice(0, 256);
|
|
97
|
+
const emailStart = truncatedAuthor.indexOf("<");
|
|
98
|
+
const emailEnd = truncatedAuthor.indexOf(">");
|
|
99
|
+
const urlStart = truncatedAuthor.indexOf("(");
|
|
100
|
+
const urlEnd = truncatedAuthor.indexOf(")");
|
|
101
|
+
let name = truncatedAuthor;
|
|
102
|
+
let email = "";
|
|
103
|
+
let url = "";
|
|
104
|
+
if (emailStart >= 0 && emailEnd > emailStart) {
|
|
105
|
+
name = truncatedAuthor.slice(0, emailStart).trim();
|
|
106
|
+
email = truncatedAuthor.slice(emailStart + 1, emailEnd).trim();
|
|
107
|
+
}
|
|
108
|
+
if (urlStart >= 0 && urlEnd > urlStart) url = truncatedAuthor.slice(urlStart + 1, urlEnd).trim();
|
|
109
|
+
return {
|
|
110
|
+
name: name || author,
|
|
111
|
+
email,
|
|
112
|
+
url
|
|
113
|
+
};
|
|
171
114
|
}
|
|
115
|
+
//#endregion
|
|
116
|
+
exports.GENERIC_AVATAR = GENERIC_AVATAR;
|
|
117
|
+
exports.addGravatarSupport = addGravatarSupport;
|
|
118
|
+
exports.formatAuthor = formatAuthor;
|
|
119
|
+
exports.generateGravatarUrl = generateGravatarUrl;
|
|
120
|
+
|
|
172
121
|
//# sourceMappingURL=author-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"author-utils.js","names":["_core","require","_typeof","o","Symbol","iterator","constructor","prototype","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","toPrimitive","call","TypeError","String","Number","AVATAR_PROVIDER","GENERIC_AVATAR","exports","encodeURIComponent","formatAuthor","author","authorDetails","name","DEFAULT_USER","email","url","undefined","addGravatarSupport","pkgInfo","_pkgInfo$latest$autho","_pkgInfo$latest","_pkgInfo$latest$contr","_pkgInfo$latest2","_pkgInfo$latest$maint","_pkgInfo$latest3","online","pkgInfoCopy","latest","contributors","normalizeAuthors","maintainers","_ref","_avatar","generateGravatarUrl","_splitAuthorString","splitAuthorString","map","contributor","_splitAuthorString2","maintainer","_splitAuthorString3","trim","toLocaleLowerCase","emailMD5","cryptoUtils","stringToMD5","concat","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 type { 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 >= 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,GAAGF,eAAe,CAACG,OAAO,CAAC,GAAG,CAAC;EAC/C,IAAMC,QAAQ,GAAGJ,eAAe,CAACG,OAAO,CAAC,GAAG,CAAC;EAC7C,IAAME,QAAQ,GAAGL,eAAe,CAACG,OAAO,CAAC,GAAG,CAAC;EAC7C,IAAMG,MAAM,GAAGN,eAAe,CAACG,OAAO,CAAC,GAAG,CAAC;EAE3C,IAAI1C,IAAI,GAAGuC,eAAe;EAC1B,IAAIrC,KAAK,GAAG,EAAE;EACd,IAAIC,GAAG,GAAG,EAAE;EAEZ,IAAIsC,UAAU,IAAI,CAAC,IAAIE,QAAQ,GAAGF,UAAU,EAAE;IAC5CzC,IAAI,GAAGuC,eAAe,CAACC,KAAK,CAAC,CAAC,EAAEC,UAAU,CAAC,CAACZ,IAAI,CAAC,CAAC;IAClD3B,KAAK,GAAGqC,eAAe,CAACC,KAAK,CAACC,UAAU,GAAG,CAAC,EAAEE,QAAQ,CAAC,CAACd,IAAI,CAAC,CAAC;EAChE;EAEA,IAAIe,QAAQ,IAAI,CAAC,IAAIC,MAAM,GAAGD,QAAQ,EAAE;IACtCzC,GAAG,GAAGoC,eAAe,CAACC,KAAK,CAACI,QAAQ,GAAG,CAAC,EAAEC,MAAM,CAAC,CAAChB,IAAI,CAAC,CAAC;EAC1D;EAEA,OAAO;IACL7B,IAAI,EAAEA,IAAI,IAAIF,MAAM;IACpBI,KAAK,EAALA,KAAK;IACLC,GAAG,EAAHA;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"author-utils.js","names":[],"sources":["../src/author-utils.ts"],"sourcesContent":["import { DEFAULT_USER, cryptoUtils } from '@verdaccio/core';\nimport type { 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}\n"],"mappings":";;;AAGA,IAAM,kBAAkB;AAExB,IAAa,iBACX,6BACA,mBACE,4pCAcD;;;;;;AAOH,SAAgB,aAAa,QAAsB;CACjD,IAAI,gBAAgB;EAClB,MAAM,gBAAA;EACN,OAAO;EACP,KAAK;EACN;AAED,KAAI,WAAW,QAAQ,WAAW,KAAA,EAChC,QAAO;AAGT,KAAI,OAAO,WAAW,SACpB,iBAAgB;EACd,GAAG;EACH,MAAM;EACP;AAGH,KAAI,OAAO,WAAW,SACpB,iBAAgB;EACd,GAAG;EAC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F,KAAI,UAAU,OAAO,UAAU,YAAY,MAAM,SAAS,GAAG;AAC3D,UAAQ,MAAM,MAAM,CAAC,mBAAmB;AAExC,SAAO,GAAG,kBADO,gBAAA,YAAY,YAAY,MAAM;;AAGjD,QAAO;;AAGT,SAAS,iBAAiB,SAA6B;AACrD,KAAI,YAAY,QAAQ,YAAY,KAAA,EAClC,QAAO,EAAE;UACA,WAAW,CAAC,MAAM,QAAQ,QAAQ,CAC3C,QAAO,CAAC,QAAQ;UACP,OAAO,YAAY,SAC5B,QAAO,CACL,EACE,MAAM,SACP,CACF;AAGH,QAAO;;;;;;;;AAST,SAAS,kBAAkB,QAA+D;CAGxF,MAAM,kBAAkB,OAAO,MAAM,GADnB,IACgC;CAGlD,MAAM,aAAa,gBAAgB,QAAQ,IAAI;CAC/C,MAAM,WAAW,gBAAgB,QAAQ,IAAI;CAC7C,MAAM,WAAW,gBAAgB,QAAQ,IAAI;CAC7C,MAAM,SAAS,gBAAgB,QAAQ,IAAI;CAE3C,IAAI,OAAO;CACX,IAAI,QAAQ;CACZ,IAAI,MAAM;AAEV,KAAI,cAAc,KAAK,WAAW,YAAY;AAC5C,SAAO,gBAAgB,MAAM,GAAG,WAAW,CAAC,MAAM;AAClD,UAAQ,gBAAgB,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM;;AAGhE,KAAI,YAAY,KAAK,SAAS,SAC5B,OAAM,gBAAgB,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM;AAG1D,QAAO;EACL,MAAM,QAAQ;EACd;EACA;EACD"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { DEFAULT_USER, cryptoUtils } from "@verdaccio/core";
|
|
2
|
+
//#region src/author-utils.ts
|
|
3
|
+
var AVATAR_PROVIDER = "https://www.gravatar.com/avatar/";
|
|
4
|
+
var 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=\"74\" 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-path=\"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\" overflow=\"visible\" xlink:href=\"#c\"/><clipPath id=\"d\"><use overflow=\"visible\" xlink:href=\"#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>");
|
|
5
|
+
/**
|
|
6
|
+
* Formats author field for webui.
|
|
7
|
+
* @see https://docs.npmjs.com/files/package.json#author
|
|
8
|
+
* @param {string|object|undefined} author
|
|
9
|
+
*/
|
|
10
|
+
function formatAuthor(author) {
|
|
11
|
+
let authorDetails = {
|
|
12
|
+
name: DEFAULT_USER,
|
|
13
|
+
email: "",
|
|
14
|
+
url: ""
|
|
15
|
+
};
|
|
16
|
+
if (author === null || author === void 0) return authorDetails;
|
|
17
|
+
if (typeof author === "string") authorDetails = {
|
|
18
|
+
...authorDetails,
|
|
19
|
+
name: author
|
|
20
|
+
};
|
|
21
|
+
if (typeof author === "object") authorDetails = {
|
|
22
|
+
...authorDetails,
|
|
23
|
+
...author
|
|
24
|
+
};
|
|
25
|
+
return authorDetails;
|
|
26
|
+
}
|
|
27
|
+
function addGravatarSupport(pkgInfo, online = true) {
|
|
28
|
+
const pkgInfoCopy = { ...pkgInfo };
|
|
29
|
+
const author = pkgInfo?.latest?.author ?? null;
|
|
30
|
+
const contributors = normalizeAuthors(pkgInfo?.latest?.contributors ?? []);
|
|
31
|
+
const maintainers = normalizeAuthors(pkgInfo?.latest?.maintainers ?? []);
|
|
32
|
+
if (author && typeof author === "object") {
|
|
33
|
+
const { email } = author;
|
|
34
|
+
pkgInfoCopy.latest.author._avatar = generateGravatarUrl(email, online);
|
|
35
|
+
} else if (author && typeof author === "string") {
|
|
36
|
+
const { email, name, url } = splitAuthorString(author);
|
|
37
|
+
pkgInfoCopy.latest.author = {
|
|
38
|
+
_avatar: generateGravatarUrl(email, online),
|
|
39
|
+
email,
|
|
40
|
+
name,
|
|
41
|
+
url
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (contributors && contributors.length > 0) pkgInfoCopy.latest.contributors = contributors.map((contributor) => {
|
|
45
|
+
if (typeof contributor === "object") contributor._avatar = generateGravatarUrl(contributor.email, online);
|
|
46
|
+
else if (typeof contributor === "string") {
|
|
47
|
+
const { email, name, url } = splitAuthorString(contributor);
|
|
48
|
+
contributor = {
|
|
49
|
+
_avatar: generateGravatarUrl(email, online),
|
|
50
|
+
email,
|
|
51
|
+
name,
|
|
52
|
+
url
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return contributor;
|
|
56
|
+
});
|
|
57
|
+
if (maintainers && maintainers.length > 0) pkgInfoCopy.latest.maintainers = maintainers.map((maintainer) => {
|
|
58
|
+
if (typeof maintainer === "object") maintainer._avatar = generateGravatarUrl(maintainer.email, online);
|
|
59
|
+
else if (typeof maintainer === "string") {
|
|
60
|
+
const { email, name, url } = splitAuthorString(maintainer);
|
|
61
|
+
maintainer = {
|
|
62
|
+
_avatar: generateGravatarUrl(email, online),
|
|
63
|
+
email,
|
|
64
|
+
name,
|
|
65
|
+
url
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return maintainer;
|
|
69
|
+
});
|
|
70
|
+
return pkgInfoCopy;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Generate gravatar url from email address
|
|
74
|
+
*/
|
|
75
|
+
function generateGravatarUrl(email = "", online = true) {
|
|
76
|
+
if (online && typeof email === "string" && email.length > 0) {
|
|
77
|
+
email = email.trim().toLocaleLowerCase();
|
|
78
|
+
return `${AVATAR_PROVIDER}${cryptoUtils.stringToMD5(email)}`;
|
|
79
|
+
}
|
|
80
|
+
return GENERIC_AVATAR;
|
|
81
|
+
}
|
|
82
|
+
function normalizeAuthors(authors) {
|
|
83
|
+
if (authors === null || authors === void 0) return [];
|
|
84
|
+
else if (authors && !Array.isArray(authors)) return [authors];
|
|
85
|
+
else if (typeof authors === "string") return [{ name: authors }];
|
|
86
|
+
return authors;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Split author string into name, email and url
|
|
90
|
+
* Example: "Barney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)"
|
|
91
|
+
* @param {string} author
|
|
92
|
+
* @returns {Object} { name: string, email: string, url: string }
|
|
93
|
+
*/
|
|
94
|
+
function splitAuthorString(author) {
|
|
95
|
+
const truncatedAuthor = author.slice(0, 256);
|
|
96
|
+
const emailStart = truncatedAuthor.indexOf("<");
|
|
97
|
+
const emailEnd = truncatedAuthor.indexOf(">");
|
|
98
|
+
const urlStart = truncatedAuthor.indexOf("(");
|
|
99
|
+
const urlEnd = truncatedAuthor.indexOf(")");
|
|
100
|
+
let name = truncatedAuthor;
|
|
101
|
+
let email = "";
|
|
102
|
+
let url = "";
|
|
103
|
+
if (emailStart >= 0 && emailEnd > emailStart) {
|
|
104
|
+
name = truncatedAuthor.slice(0, emailStart).trim();
|
|
105
|
+
email = truncatedAuthor.slice(emailStart + 1, emailEnd).trim();
|
|
106
|
+
}
|
|
107
|
+
if (urlStart >= 0 && urlEnd > urlStart) url = truncatedAuthor.slice(urlStart + 1, urlEnd).trim();
|
|
108
|
+
return {
|
|
109
|
+
name: name || author,
|
|
110
|
+
email,
|
|
111
|
+
url
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
export { GENERIC_AVATAR, addGravatarSupport, formatAuthor, generateGravatarUrl };
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=author-utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"author-utils.mjs","names":[],"sources":["../src/author-utils.ts"],"sourcesContent":["import { DEFAULT_USER, cryptoUtils } from '@verdaccio/core';\nimport type { 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}\n"],"mappings":";;AAGA,IAAM,kBAAkB;AAExB,IAAa,iBACX,6BACA,mBACE,4pCAcD;;;;;;AAOH,SAAgB,aAAa,QAAsB;CACjD,IAAI,gBAAgB;EAClB,MAAM;EACN,OAAO;EACP,KAAK;EACN;AAED,KAAI,WAAW,QAAQ,WAAW,KAAA,EAChC,QAAO;AAGT,KAAI,OAAO,WAAW,SACpB,iBAAgB;EACd,GAAG;EACH,MAAM;EACP;AAGH,KAAI,OAAO,WAAW,SACpB,iBAAgB;EACd,GAAG;EACH,GAAI;EACL;AAGH,QAAO;;AAGT,SAAgB,mBAAmB,SAAsB,SAAkB,MAAc;CACvF,MAAM,cAAc,EAAE,GAAG,SAAS;CAClC,MAAM,SAAc,SAAS,QAAQ,UAAU;CAC/C,MAAM,eAAyB,iBAAiB,SAAS,QAAQ,gBAAgB,EAAE,CAAC;CACpF,MAAM,cAAwB,iBAAiB,SAAS,QAAQ,eAAe,EAAE,CAAC;AAGlF,KAAI,UAAU,OAAO,WAAW,UAAU;EACxC,MAAM,EAAE,UAAU;AAClB,cAAY,OAAO,OAAO,UAAU,oBAAoB,OAAO,OAAO;YAC7D,UAAU,OAAO,WAAW,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GxF,MAAM,kBAAkB,OAAO,MAAM,GADnB,IACgC;CAGlD,MAAM,aAAa,gBAAgB,QAAQ,IAAI;CAC/C,MAAM,WAAW,gBAAgB,QAAQ,IAAI;CAC7C,MAAM,WAAW,gBAAgB,QAAQ,IAAI;CAC7C,MAAM,SAAS,gBAAgB,QAAQ,IAAI;CAE3C,IAAI,OAAO;CACX,IAAI,QAAQ;CACZ,IAAI,MAAM;AAEV,KAAI,cAAc,KAAK,WAAW,YAAY;AAC5C,SAAO,gBAAgB,MAAM,GAAG,WAAW,CAAC,MAAM;AAClD,UAAQ,gBAAgB,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM;;AAGhE,KAAI,YAAY,KAAK,SAAS,SAC5B,OAAM,gBAAgB,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM;AAG1D,QAAO;EACL,MAAM,QAAQ;EACd;EACA;EACD"}
|
package/build/index.js
CHANGED
|
@@ -1,48 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
6
4
|
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var _middleware = _interopRequireWildcard(require("./middleware"));
|
|
23
|
-
var _authorUtils = require("./author-utils");
|
|
24
|
-
Object.keys(_authorUtils).forEach(function (key) {
|
|
25
|
-
if (key === "default" || key === "__esModule") return;
|
|
26
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
27
|
-
if (key in exports && exports[key] === _authorUtils[key]) return;
|
|
28
|
-
Object.defineProperty(exports, key, {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: function get() {
|
|
31
|
-
return _authorUtils[key];
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
var _webUtils = require("./web-utils");
|
|
36
|
-
Object.keys(_webUtils).forEach(function (key) {
|
|
37
|
-
if (key === "default" || key === "__esModule") return;
|
|
38
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
39
|
-
if (key in exports && exports[key] === _webUtils[key]) return;
|
|
40
|
-
Object.defineProperty(exports, key, {
|
|
41
|
-
enumerable: true,
|
|
42
|
-
get: function get() {
|
|
43
|
-
return _webUtils[key];
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
48
|
-
//# sourceMappingURL=index.js.map
|
|
5
|
+
const require_web_utils = require("./web-utils.js");
|
|
6
|
+
const require_author_utils = require("./author-utils.js");
|
|
7
|
+
const require_middleware = require("./middleware.js");
|
|
8
|
+
exports.DEFAULT_PLUGIN_UI_THEME = require_middleware.DEFAULT_PLUGIN_UI_THEME;
|
|
9
|
+
exports.GENERIC_AVATAR = require_author_utils.GENERIC_AVATAR;
|
|
10
|
+
exports.addGravatarSupport = require_author_utils.addGravatarSupport;
|
|
11
|
+
exports.addScope = require_web_utils.addScope;
|
|
12
|
+
exports.default = require_middleware.default;
|
|
13
|
+
exports.deleteProperties = require_web_utils.deleteProperties;
|
|
14
|
+
exports.formatAuthor = require_author_utils.formatAuthor;
|
|
15
|
+
exports.generateGravatarUrl = require_author_utils.generateGravatarUrl;
|
|
16
|
+
exports.hasLogin = require_web_utils.hasLogin;
|
|
17
|
+
exports.isVersionValid = require_web_utils.isVersionValid;
|
|
18
|
+
exports.sortByName = require_web_utils.sortByName;
|
|
19
|
+
exports.sortByTime = require_web_utils.sortByTime;
|
package/build/index.mjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { addScope, deleteProperties, hasLogin, isVersionValid, sortByName, sortByTime } from "./web-utils.mjs";
|
|
2
|
+
import { GENERIC_AVATAR, addGravatarSupport, formatAuthor, generateGravatarUrl } from "./author-utils.mjs";
|
|
3
|
+
import middleware_default, { DEFAULT_PLUGIN_UI_THEME } from "./middleware.mjs";
|
|
4
|
+
export { DEFAULT_PLUGIN_UI_THEME, GENERIC_AVATAR, addGravatarSupport, addScope, middleware_default as default, deleteProperties, formatAuthor, generateGravatarUrl, hasLogin, isVersionValid, sortByName, sortByTime };
|
package/build/middleware.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const DEFAULT_PLUGIN_UI_THEME = "@verdaccio/ui-theme";
|
|
2
2
|
export declare function loadTheme(config: any): Promise<any>;
|
|
3
|
-
declare const _default: (config: any, auth: any, storage: any, logger: any) => Promise<import(
|
|
3
|
+
declare const _default: (config: any, auth: any, storage: any, logger: any) => Promise<import('express-serve-static-core').Router>;
|
|
4
4
|
export default _default;
|