@verdaccio/hooks 9.0.0-next-9.2 → 9.0.0-next-9.4

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.
@@ -0,0 +1,23 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ exports.__toESM = __toESM;
package/build/index.js CHANGED
@@ -1,25 +1,8 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "handleNotify", {
7
- enumerable: true,
8
- get: function get() {
9
- return _notify.handleNotify;
10
- }
11
- });
12
- Object.defineProperty(exports, "notify", {
13
- enumerable: true,
14
- get: function get() {
15
- return _notify.notify;
16
- }
17
- });
18
- Object.defineProperty(exports, "sendNotification", {
19
- enumerable: true,
20
- get: function get() {
21
- return _notify.sendNotification;
22
- }
23
- });
24
- var _notify = require("./notify");
25
- //# sourceMappingURL=index.js.map
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ const require_notify = require("./notify.js");
6
+ exports.handleNotify = require_notify.handleNotify;
7
+ exports.notify = require_notify.notify;
8
+ exports.sendNotification = require_notify.sendNotification;
@@ -0,0 +1,2 @@
1
+ import { handleNotify, notify, sendNotification } from "./notify.mjs";
2
+ export { handleNotify, notify, sendNotification };
@@ -1,4 +1,4 @@
1
- import type { Method } from 'got-cjs';
1
+ import { Method } from 'got-cjs';
2
2
  export type FetchOptions = {
3
3
  body: string;
4
4
  headers?: {};
@@ -1,127 +1,72 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.notifyRequest = notifyRequest;
7
- exports.verifyMethod = verifyMethod;
8
- var _debug = _interopRequireDefault(require("debug"));
9
- var _gotCjs = _interopRequireDefault(require("got-cjs"));
10
- var _core = require("@verdaccio/core");
11
- var _logger = require("@verdaccio/logger");
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
- function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
14
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
15
- 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; }
16
- 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; }
17
- 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; }
18
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
19
- 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); }
20
- 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); }
21
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
22
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
23
- var debug = (0, _debug["default"])('verdaccio:hooks:request');
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.js");
2
+ let debug = require("debug");
3
+ debug = require_runtime.__toESM(debug);
4
+ let _verdaccio_logger = require("@verdaccio/logger");
5
+ let got_cjs = require("got-cjs");
6
+ got_cjs = require_runtime.__toESM(got_cjs);
7
+ let _verdaccio_core = require("@verdaccio/core");
8
+ //#region src/notify-request.ts
9
+ var debug$1 = (0, debug.default)("verdaccio:hooks:request");
24
10
  function verifyMethod(value) {
25
- var valid = ['GET', 'POST', 'PUT'];
26
- if (typeof value === 'string') {
27
- var upper = value.toUpperCase();
28
- if (valid.includes(upper)) {
29
- return upper;
30
- } else {
31
- _logger.logger.warn({
32
- method: value
33
- }, 'The notification method @{method} is not valid, using default POST method');
34
- }
35
- }
36
- return 'POST';
37
- }
38
- var baseHeaders = {
39
- 'Content-Type': 'application/json'
40
- };
41
- function notifyRequest(_x, _x2) {
42
- return _notifyRequest.apply(this, arguments);
11
+ const valid = [
12
+ "GET",
13
+ "POST",
14
+ "PUT"
15
+ ];
16
+ if (typeof value === "string") {
17
+ const upper = value.toUpperCase();
18
+ if (valid.includes(upper)) return upper;
19
+ else _verdaccio_logger.logger.warn({ method: value }, "The notification method @{method} is not valid, using default POST method");
20
+ }
21
+ return "POST";
43
22
  }
44
- function _notifyRequest() {
45
- _notifyRequest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(url, options) {
46
- var response, method, userHeaders, headers, requestOptions, finalUrl, urlObj, params, body, _t;
47
- return _regenerator().w(function (_context) {
48
- while (1) switch (_context.p = _context.n) {
49
- case 0:
50
- _context.p = 0;
51
- method = verifyMethod(options.method);
52
- debug('uri %o', url);
53
- debug('headers %o', options.headers);
54
- debug('method %o', method);
55
- userHeaders = {};
56
- if (options.headers) {
57
- if (typeof options.headers === 'string') {
58
- userHeaders = JSON.parse(options.headers);
59
- } else if (_typeof(options.headers) === 'object') {
60
- userHeaders = options.headers;
61
- }
62
- }
63
- headers = _objectSpread(_objectSpread({}, baseHeaders), userHeaders);
64
- requestOptions = {
65
- method: method,
66
- headers: headers
67
- };
68
- finalUrl = url;
69
- if (!(method === 'GET')) {
70
- _context.n = 1;
71
- break;
72
- }
73
- debug('using GET with query params');
74
- urlObj = new URL(url);
75
- params = new URLSearchParams(options.body);
76
- params.set('body', options.body);
77
- urlObj.search = params.toString();
78
- finalUrl = urlObj.toString();
79
- debug('final url with search params %o', finalUrl);
80
- _context.n = 3;
81
- break;
82
- case 1:
83
- if (!(options.body !== undefined)) {
84
- _context.n = 2;
85
- break;
86
- }
87
- requestOptions.body = options.body;
88
- _context.n = 3;
89
- break;
90
- case 2:
91
- throw new Error('Notification body is undefined');
92
- case 3:
93
- _context.n = 4;
94
- return (0, _gotCjs["default"])(finalUrl, _objectSpread(_objectSpread({}, requestOptions), {}, {
95
- responseType: 'json'
96
- }));
97
- case 4:
98
- response = _context.v;
99
- _context.n = 5;
100
- return response.body;
101
- case 5:
102
- body = _context.v;
103
- debug('response.status %o', body.statusCode);
104
- if (!(body.statusCode >= _core.HTTP_STATUS.BAD_REQUEST)) {
105
- _context.n = 6;
106
- break;
107
- }
108
- throw new Error(body);
109
- case 6:
110
- _logger.logger.info({
111
- content: options.body
112
- }, 'The notification @{content} has been successfully dispatched');
113
- return _context.a(2, true);
114
- case 7:
115
- _context.p = 7;
116
- _t = _context.v;
117
- debug('request error %o:', _t === null || _t === void 0 ? void 0 : _t.message);
118
- _logger.logger.error({
119
- errorMessage: _t === null || _t === void 0 ? void 0 : _t.message
120
- }, 'notify service has thrown an error: @{errorMessage}');
121
- return _context.a(2, false);
122
- }
123
- }, _callee, null, [[0, 7]]);
124
- }));
125
- return _notifyRequest.apply(this, arguments);
23
+ var baseHeaders = { "Content-Type": "application/json" };
24
+ async function notifyRequest(url, options) {
25
+ let response;
26
+ try {
27
+ const method = verifyMethod(options.method);
28
+ debug$1("uri %o", url);
29
+ debug$1("headers %o", options.headers);
30
+ debug$1("method %o", method);
31
+ let userHeaders = {};
32
+ if (options.headers) {
33
+ if (typeof options.headers === "string") userHeaders = JSON.parse(options.headers);
34
+ else if (typeof options.headers === "object") userHeaders = options.headers;
35
+ }
36
+ const requestOptions = {
37
+ method,
38
+ headers: {
39
+ ...baseHeaders,
40
+ ...userHeaders
41
+ }
42
+ };
43
+ let finalUrl = url;
44
+ if (method === "GET") {
45
+ debug$1("using GET with query params");
46
+ const urlObj = new URL(url);
47
+ const params = new URLSearchParams(options.body);
48
+ params.set("body", options.body);
49
+ urlObj.search = params.toString();
50
+ finalUrl = urlObj.toString();
51
+ debug$1("final url with search params %o", finalUrl);
52
+ } else if (options.body !== void 0) requestOptions.body = options.body;
53
+ else throw new Error("Notification body is undefined");
54
+ response = await (0, got_cjs.default)(finalUrl, {
55
+ ...requestOptions,
56
+ responseType: "json"
57
+ });
58
+ const body = await response.body;
59
+ debug$1("response.status %o", body.statusCode);
60
+ if (body.statusCode >= _verdaccio_core.HTTP_STATUS.BAD_REQUEST) throw new Error(body);
61
+ _verdaccio_logger.logger.info({ content: options.body }, "The notification @{content} has been successfully dispatched");
62
+ return true;
63
+ } catch (err) {
64
+ debug$1("request error %o:", err?.message);
65
+ _verdaccio_logger.logger.error({ errorMessage: err?.message }, "notify service has thrown an error: @{errorMessage}");
66
+ return false;
67
+ }
126
68
  }
69
+ //#endregion
70
+ exports.notifyRequest = notifyRequest;
71
+
127
72
  //# sourceMappingURL=notify-request.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"notify-request.js","names":["_debug","_interopRequireDefault","require","_gotCjs","_core","_logger","e","__esModule","_regenerator","t","r","Symbol","n","iterator","o","toStringTag","i","c","prototype","Generator","u","Object","create","_regeneratorDefine2","f","p","y","G","v","a","d","bind","length","l","TypeError","call","done","value","GeneratorFunction","GeneratorFunctionPrototype","getPrototypeOf","setPrototypeOf","__proto__","displayName","w","m","defineProperty","_regeneratorDefine","_invoke","enumerable","configurable","writable","ownKeys","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","push","apply","_objectSpread","arguments","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","_toPropertyKey","_toPrimitive","_typeof","toPrimitive","String","Number","constructor","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","_next","_throw","debug","buildDebug","verifyMethod","valid","upper","toUpperCase","includes","logger","warn","method","baseHeaders","notifyRequest","_x","_x2","_notifyRequest","_callee","url","options","response","userHeaders","headers","requestOptions","finalUrl","urlObj","params","body","_t","_context","JSON","parse","URL","URLSearchParams","set","search","toString","undefined","Error","got","responseType","statusCode","HTTP_STATUS","BAD_REQUEST","info","content","message","error","errorMessage"],"sources":["../src/notify-request.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { Method } from 'got-cjs';\nimport got from 'got-cjs';\n\nimport { HTTP_STATUS } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\n\nconst debug = buildDebug('verdaccio:hooks:request');\n\nexport type FetchOptions = {\n body: string;\n headers?: {};\n method?: string;\n};\n\nexport function verifyMethod(value: any): Method {\n const valid: Method[] = ['GET', 'POST', 'PUT'];\n\n if (typeof value === 'string') {\n const upper = value.toUpperCase() as Method;\n\n if (valid.includes(upper)) {\n return upper;\n } else {\n logger.warn(\n { method: value },\n 'The notification method @{method} is not valid, using default POST method'\n );\n }\n }\n\n return 'POST';\n}\n\nconst baseHeaders = { 'Content-Type': 'application/json' };\nexport async function notifyRequest(url: string, options: FetchOptions): Promise<boolean> {\n let response;\n try {\n const method: Method = verifyMethod(options.method);\n debug('uri %o', url);\n debug('headers %o', options.headers);\n debug('method %o', method);\n\n let userHeaders: Record<string, any> = {};\n\n if (options.headers) {\n if (typeof options.headers === 'string') {\n userHeaders = JSON.parse(options.headers);\n } else if (typeof options.headers === 'object') {\n userHeaders = options.headers;\n }\n }\n\n const headers = { ...baseHeaders, ...userHeaders };\n const requestOptions: any = {\n method,\n headers,\n };\n\n let finalUrl = url;\n if (method === 'GET') {\n debug('using GET with query params');\n const urlObj = new URL(url);\n const params = new URLSearchParams(options.body);\n params.set('body', options.body);\n urlObj.search = params.toString();\n finalUrl = urlObj.toString();\n debug('final url with search params %o', finalUrl);\n } else if (options.body !== undefined) {\n requestOptions.body = options.body;\n } else {\n throw new Error('Notification body is undefined');\n }\n\n response = await got(finalUrl, {\n ...requestOptions,\n responseType: 'json',\n });\n\n const body = await response.body;\n debug('response.status %o', body.statusCode);\n\n if (body.statusCode >= HTTP_STATUS.BAD_REQUEST) {\n throw new Error(body);\n }\n\n logger.info(\n { content: options.body },\n 'The notification @{content} has been successfully dispatched'\n );\n return true;\n } catch (err: any) {\n debug('request error %o:', err?.message);\n logger.error(\n { errorMessage: err?.message },\n 'notify service has thrown an error: @{errorMessage}'\n );\n return false;\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAA2C,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAAA,SAAAE,aAAA,IAJ3C,uKAAAF,CAAA,EAAAG,CAAA,EAAAC,CAAA,wBAAAC,MAAA,GAAAA,MAAA,OAAAC,CAAA,GAAAF,CAAA,CAAAG,QAAA,kBAAAC,CAAA,GAAAJ,CAAA,CAAAK,WAAA,8BAAAC,EAAAN,CAAA,EAAAE,CAAA,EAAAE,CAAA,EAAAE,CAAA,QAAAC,CAAA,GAAAL,CAAA,IAAAA,CAAA,CAAAM,SAAA,YAAAC,S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List":[]}
1
+ {"version":3,"file":"notify-request.js","names":[],"sources":["../src/notify-request.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { Method } from 'got-cjs';\nimport got from 'got-cjs';\n\nimport { HTTP_STATUS } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\n\nconst debug = buildDebug('verdaccio:hooks:request');\n\nexport type FetchOptions = {\n body: string;\n headers?: {};\n method?: string;\n};\n\nexport function verifyMethod(value: any): Method {\n const valid: Method[] = ['GET', 'POST', 'PUT'];\n\n if (typeof value === 'string') {\n const upper = value.toUpperCase() as Method;\n\n if (valid.includes(upper)) {\n return upper;\n } else {\n logger.warn(\n { method: value },\n 'The notification method @{method} is not valid, using default POST method'\n );\n }\n }\n\n return 'POST';\n}\n\nconst baseHeaders = { 'Content-Type': 'application/json' };\nexport async function notifyRequest(url: string, options: FetchOptions): Promise<boolean> {\n let response;\n try {\n const method: Method = verifyMethod(options.method);\n debug('uri %o', url);\n debug('headers %o', options.headers);\n debug('method %o', method);\n\n let userHeaders: Record<string, any> = {};\n\n if (options.headers) {\n if (typeof options.headers === 'string') {\n userHeaders = JSON.parse(options.headers);\n } else if (typeof options.headers === 'object') {\n userHeaders = options.headers;\n }\n }\n\n const headers = { ...baseHeaders, ...userHeaders };\n const requestOptions: any = {\n method,\n headers,\n };\n\n let finalUrl = url;\n if (method === 'GET') {\n debug('using GET with query params');\n const urlObj = new URL(url);\n const params = new URLSearchParams(options.body);\n params.set('body', options.body);\n urlObj.search = params.toString();\n finalUrl = urlObj.toString();\n debug('final url with search params %o', finalUrl);\n } else if (options.body !== undefined) {\n requestOptions.body = options.body;\n } else {\n throw new Error('Notification body is undefined');\n }\n\n response = await got(finalUrl, {\n ...requestOptions,\n responseType: 'json',\n });\n\n const body = await response.body;\n debug('response.status %o', body.statusCode);\n\n if (body.statusCode >= HTTP_STATUS.BAD_REQUEST) {\n throw new Error(body);\n }\n\n logger.info(\n { content: options.body },\n 'The notification @{content} has been successfully dispatched'\n );\n return true;\n } catch (err: any) {\n debug('request error %o:', err?.message);\n logger.error(\n { errorMessage: err?.message },\n 'notify service has thrown an error: @{errorMessage}'\n );\n return false;\n }\n}\n"],"mappings":";;;;;;;;AAOA,IAAM,WAAA,GAAA,MAAA,SAAmB,0BAA0B;AAQnD,SAAgB,aAAa,OAAoB;CAC/C,MAAM,QAAkB;EAAC;EAAO;EAAQ;EAAM;AAE9C,KAAI,OAAO,UAAU,UAAU;EAC7B,MAAM,QAAQ,MAAM,aAAa;AAEjC,MAAI,MAAM,SAAS,MAAM,CACvB,QAAO;MAEP,mBAAA,OAAO,KACL,EAAE,QAAQ,OAAO,EACjB,4EACD;;AAIL,QAAO;;AAGT,IAAM,cAAc,EAAE,gBAAgB,oBAAoB;AAC1D,eAAsB,cAAc,KAAa,SAAyC;CACxF,IAAI;AACJ,KAAI;EACF,MAAM,SAAiB,aAAa,QAAQ,OAAO;AACnD,UAAM,UAAU,IAAI;AACpB,UAAM,cAAc,QAAQ,QAAQ;AACpC,UAAM,aAAa,OAAO;EAE1B,IAAI,cAAmC,EAAE;AAEzC,MAAI,QAAQ;OACN,OAAO,QAAQ,YAAY,SAC7B,eAAc,KAAK,MAAM,QAAQ,QAAQ;YAChC,OAAO,QAAQ,YAAY,SACpC,eAAc,QAAQ;;EAK1B,MAAM,iBAAsB;GAC1B;GACA,SAHc;IAAE,GAAG;IAAa,GAAG;IAAa;GAIjD;EAED,IAAI,WAAW;AACf,MAAI,WAAW,OAAO;AACpB,WAAM,8BAA8B;GACpC,MAAM,SAAS,IAAI,IAAI,IAAI;GAC3B,MAAM,SAAS,IAAI,gBAAgB,QAAQ,KAAK;AAChD,UAAO,IAAI,QAAQ,QAAQ,KAAK;AAChC,UAAO,SAAS,OAAO,UAAU;AACjC,cAAW,OAAO,UAAU;AAC5B,WAAM,mCAAmC,SAAS;aACzC,QAAQ,SAAS,KAAA,EAC1B,gBAAe,OAAO,QAAQ;MAE9B,OAAM,IAAI,MAAM,iCAAiC;AAGnD,aAAW,OAAA,GAAA,QAAA,SAAU,UAAU;GAC7B,GAAG;GACH,cAAc;GACf,CAAC;EAEF,MAAM,OAAO,MAAM,SAAS;AAC5B,UAAM,sBAAsB,KAAK,WAAW;AAE5C,MAAI,KAAK,cAAc,gBAAA,YAAY,YACjC,OAAM,IAAI,MAAM,KAAK;AAGvB,oBAAA,OAAO,KACL,EAAE,SAAS,QAAQ,MAAM,EACzB,+DACD;AACD,SAAO;UACA,KAAU;AACjB,UAAM,qBAAqB,KAAK,QAAQ;AACxC,oBAAA,OAAO,MACL,EAAE,cAAc,KAAK,SAAS,EAC9B,sDACD;AACD,SAAO"}
@@ -0,0 +1,69 @@
1
+ import buildDebug from "debug";
2
+ import { logger } from "@verdaccio/logger";
3
+ import got from "got-cjs";
4
+ import { HTTP_STATUS } from "@verdaccio/core";
5
+ //#region src/notify-request.ts
6
+ var debug = buildDebug("verdaccio:hooks:request");
7
+ function verifyMethod(value) {
8
+ const valid = [
9
+ "GET",
10
+ "POST",
11
+ "PUT"
12
+ ];
13
+ if (typeof value === "string") {
14
+ const upper = value.toUpperCase();
15
+ if (valid.includes(upper)) return upper;
16
+ else logger.warn({ method: value }, "The notification method @{method} is not valid, using default POST method");
17
+ }
18
+ return "POST";
19
+ }
20
+ var baseHeaders = { "Content-Type": "application/json" };
21
+ async function notifyRequest(url, options) {
22
+ let response;
23
+ try {
24
+ const method = verifyMethod(options.method);
25
+ debug("uri %o", url);
26
+ debug("headers %o", options.headers);
27
+ debug("method %o", method);
28
+ let userHeaders = {};
29
+ if (options.headers) {
30
+ if (typeof options.headers === "string") userHeaders = JSON.parse(options.headers);
31
+ else if (typeof options.headers === "object") userHeaders = options.headers;
32
+ }
33
+ const requestOptions = {
34
+ method,
35
+ headers: {
36
+ ...baseHeaders,
37
+ ...userHeaders
38
+ }
39
+ };
40
+ let finalUrl = url;
41
+ if (method === "GET") {
42
+ debug("using GET with query params");
43
+ const urlObj = new URL(url);
44
+ const params = new URLSearchParams(options.body);
45
+ params.set("body", options.body);
46
+ urlObj.search = params.toString();
47
+ finalUrl = urlObj.toString();
48
+ debug("final url with search params %o", finalUrl);
49
+ } else if (options.body !== void 0) requestOptions.body = options.body;
50
+ else throw new Error("Notification body is undefined");
51
+ response = await got(finalUrl, {
52
+ ...requestOptions,
53
+ responseType: "json"
54
+ });
55
+ const body = await response.body;
56
+ debug("response.status %o", body.statusCode);
57
+ if (body.statusCode >= HTTP_STATUS.BAD_REQUEST) throw new Error(body);
58
+ logger.info({ content: options.body }, "The notification @{content} has been successfully dispatched");
59
+ return true;
60
+ } catch (err) {
61
+ debug("request error %o:", err?.message);
62
+ logger.error({ errorMessage: err?.message }, "notify service has thrown an error: @{errorMessage}");
63
+ return false;
64
+ }
65
+ }
66
+ //#endregion
67
+ export { notifyRequest };
68
+
69
+ //# sourceMappingURL=notify-request.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notify-request.mjs","names":[],"sources":["../src/notify-request.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { Method } from 'got-cjs';\nimport got from 'got-cjs';\n\nimport { HTTP_STATUS } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\n\nconst debug = buildDebug('verdaccio:hooks:request');\n\nexport type FetchOptions = {\n body: string;\n headers?: {};\n method?: string;\n};\n\nexport function verifyMethod(value: any): Method {\n const valid: Method[] = ['GET', 'POST', 'PUT'];\n\n if (typeof value === 'string') {\n const upper = value.toUpperCase() as Method;\n\n if (valid.includes(upper)) {\n return upper;\n } else {\n logger.warn(\n { method: value },\n 'The notification method @{method} is not valid, using default POST method'\n );\n }\n }\n\n return 'POST';\n}\n\nconst baseHeaders = { 'Content-Type': 'application/json' };\nexport async function notifyRequest(url: string, options: FetchOptions): Promise<boolean> {\n let response;\n try {\n const method: Method = verifyMethod(options.method);\n debug('uri %o', url);\n debug('headers %o', options.headers);\n debug('method %o', method);\n\n let userHeaders: Record<string, any> = {};\n\n if (options.headers) {\n if (typeof options.headers === 'string') {\n userHeaders = JSON.parse(options.headers);\n } else if (typeof options.headers === 'object') {\n userHeaders = options.headers;\n }\n }\n\n const headers = { ...baseHeaders, ...userHeaders };\n const requestOptions: any = {\n method,\n headers,\n };\n\n let finalUrl = url;\n if (method === 'GET') {\n debug('using GET with query params');\n const urlObj = new URL(url);\n const params = new URLSearchParams(options.body);\n params.set('body', options.body);\n urlObj.search = params.toString();\n finalUrl = urlObj.toString();\n debug('final url with search params %o', finalUrl);\n } else if (options.body !== undefined) {\n requestOptions.body = options.body;\n } else {\n throw new Error('Notification body is undefined');\n }\n\n response = await got(finalUrl, {\n ...requestOptions,\n responseType: 'json',\n });\n\n const body = await response.body;\n debug('response.status %o', body.statusCode);\n\n if (body.statusCode >= HTTP_STATUS.BAD_REQUEST) {\n throw new Error(body);\n }\n\n logger.info(\n { content: options.body },\n 'The notification @{content} has been successfully dispatched'\n );\n return true;\n } catch (err: any) {\n debug('request error %o:', err?.message);\n logger.error(\n { errorMessage: err?.message },\n 'notify service has thrown an error: @{errorMessage}'\n );\n return false;\n }\n}\n"],"mappings":";;;;;AAOA,IAAM,QAAQ,WAAW,0BAA0B;AAQnD,SAAgB,aAAa,OAAoB;CAC/C,MAAM,QAAkB;EAAC;EAAO;EAAQ;EAAM;AAE9C,KAAI,OAAO,UAAU,UAAU;EAC7B,MAAM,QAAQ,MAAM,aAAa;AAEjC,MAAI,MAAM,SAAS,MAAM,CACvB,QAAO;MAEP,QAAO,KACL,EAAE,QAAQ,OAAO,EACjB,4EACD;;AAIL,QAAO;;AAGT,IAAM,cAAc,EAAE,gBAAgB,oBAAoB;AAC1D,eAAsB,cAAc,KAAa,SAAyC;CACxF,IAAI;AACJ,KAAI;EACF,MAAM,SAAiB,aAAa,QAAQ,OAAO;AACnD,QAAM,UAAU,IAAI;AACpB,QAAM,cAAc,QAAQ,QAAQ;AACpC,QAAM,aAAa,OAAO;EAE1B,IAAI,cAAmC,EAAE;AAEzC,MAAI,QAAQ;OACN,OAAO,QAAQ,YAAY,SAC7B,eAAc,KAAK,MAAM,QAAQ,QAAQ;YAChC,OAAO,QAAQ,YAAY,SACpC,eAAc,QAAQ;;EAK1B,MAAM,iBAAsB;GAC1B;GACA,SAHc;IAAE,GAAG;IAAa,GAAG;IAAa;GAIjD;EAED,IAAI,WAAW;AACf,MAAI,WAAW,OAAO;AACpB,SAAM,8BAA8B;GACpC,MAAM,SAAS,IAAI,IAAI,IAAI;GAC3B,MAAM,SAAS,IAAI,gBAAgB,QAAQ,KAAK;AAChD,UAAO,IAAI,QAAQ,QAAQ,KAAK;AAChC,UAAO,SAAS,OAAO,UAAU;AACjC,cAAW,OAAO,UAAU;AAC5B,SAAM,mCAAmC,SAAS;aACzC,QAAQ,SAAS,KAAA,EAC1B,gBAAe,OAAO,QAAQ;MAE9B,OAAM,IAAI,MAAM,iCAAiC;AAGnD,aAAW,MAAM,IAAI,UAAU;GAC7B,GAAG;GACH,cAAc;GACf,CAAC;EAEF,MAAM,OAAO,MAAM,SAAS;AAC5B,QAAM,sBAAsB,KAAK,WAAW;AAE5C,MAAI,KAAK,cAAc,YAAY,YACjC,OAAM,IAAI,MAAM,KAAK;AAGvB,SAAO,KACL,EAAE,SAAS,QAAQ,MAAM,EACzB,+DACD;AACD,SAAO;UACA,KAAU;AACjB,QAAM,qBAAqB,KAAK,QAAQ;AACxC,SAAO,MACL,EAAE,cAAc,KAAK,SAAS,EAC9B,sDACD;AACD,SAAO"}
package/build/notify.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Config, Manifest, Notification, RemoteUser } from '@verdaccio/types';
1
+ import { Config, Manifest, Notification, RemoteUser } from '@verdaccio/types';
2
2
  export declare function compileTemplate(content: any, metadata: any): Promise<unknown>;
3
3
  export declare function handleNotify(metadata: Partial<Manifest>, notifyEntry: any, remoteUser: Partial<RemoteUser>, publishedPackage: string): Promise<boolean>;
4
4
  export declare function sendNotification(metadata: Manifest, notify: Notification, remoteUser: Partial<RemoteUser>, publishedPackage: string): Promise<boolean>;
package/build/notify.js CHANGED
@@ -1,232 +1,112 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.compileTemplate = compileTemplate;
7
- exports.handleNotify = handleNotify;
8
- exports.notify = notify;
9
- exports.sendNotification = sendNotification;
10
- var _debug = _interopRequireDefault(require("debug"));
11
- var _handlebars = _interopRequireDefault(require("handlebars"));
12
- var _logger = require("@verdaccio/logger");
13
- var _notifyRequest = require("./notify-request");
14
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
15
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
16
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
17
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
18
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
19
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
20
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
21
- function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
22
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
23
- 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; }
24
- 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; }
25
- 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; }
26
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
27
- 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); }
28
- 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); }
29
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
30
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
31
- var debug = (0, _debug["default"])('verdaccio:hooks');
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.js");
2
+ const require_notify_request = require("./notify-request.js");
3
+ let debug = require("debug");
4
+ debug = require_runtime.__toESM(debug);
5
+ let handlebars = require("handlebars");
6
+ handlebars = require_runtime.__toESM(handlebars);
7
+ let _verdaccio_logger = require("@verdaccio/logger");
8
+ //#region src/notify.ts
9
+ var debug$1 = (0, debug.default)("verdaccio:hooks");
32
10
  function compileTemplate(content, metadata) {
33
- // FUTURE: multiple handlers
34
- return new Promise(function (resolve, reject) {
35
- var handler;
36
- try {
37
- if (!handler) {
38
- debug('compile default template handler %o', content);
39
- var template = _handlebars["default"].compile(content);
40
- return resolve(template(metadata));
41
- }
42
- } catch (error) {
43
- debug('error template handler %o', error === null || error === void 0 ? void 0 : error.message);
44
- _logger.logger.error({
45
- error: error.message
46
- }, 'notification template compilation has failed: @{error}');
47
- reject(error);
48
- }
49
- });
50
- }
51
- function handleNotify(_x, _x2, _x3, _x4) {
52
- return _handleNotify.apply(this, arguments);
11
+ return new Promise((resolve, reject) => {
12
+ try {
13
+ debug$1("compile default template handler %o", content);
14
+ return resolve(handlebars.default.compile(content)(metadata));
15
+ } catch (error) {
16
+ debug$1("error template handler %o", error?.message);
17
+ _verdaccio_logger.logger.error({ error: error.message }, "notification template compilation has failed: @{error}");
18
+ reject(error);
19
+ }
20
+ });
53
21
  }
54
- function _handleNotify() {
55
- _handleNotify = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(metadata, notifyEntry, remoteUser, publishedPackage) {
56
- var _metadata, _metadata2;
57
- var regex, _notifyEntry$packageP, content, options, header, _t;
58
- return _regenerator().w(function (_context) {
59
- while (1) switch (_context.p = _context.n) {
60
- case 0:
61
- _context.p = 0;
62
- if (!(metadata.name && notifyEntry.packagePattern)) {
63
- _context.n = 2;
64
- break;
65
- }
66
- debug('checking package pattern %o', notifyEntry.packagePattern);
67
- debug('checking package pattern flags %o', notifyEntry.packagePatternFlags);
68
- regex = new RegExp(notifyEntry.packagePattern, (_notifyEntry$packageP = notifyEntry.packagePatternFlags) !== null && _notifyEntry$packageP !== void 0 ? _notifyEntry$packageP : '');
69
- if (regex.test(metadata.name)) {
70
- _context.n = 1;
71
- break;
72
- }
73
- _logger.logger.debug('Notification exclude does not match %o', metadata.name);
74
- return _context.a(2, false);
75
- case 1:
76
- debug('package pattern matched %o', metadata.name);
77
- case 2:
78
- _context.n = 4;
79
- break;
80
- case 3:
81
- _context.p = 3;
82
- _t = _context.v;
83
- _logger.logger.error('Invalid regex pattern or flags: %o', _t === null || _t === void 0 ? void 0 : _t.message);
84
- return _context.a(2, false);
85
- case 4:
86
- if (!(typeof ((_metadata = metadata) === null || _metadata === void 0 ? void 0 : _metadata.publisher) === 'undefined' || ((_metadata2 = metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.publisher) === null)) {
87
- _context.n = 6;
88
- break;
89
- }
90
- // @ts-ignore
91
- metadata = _objectSpread(_objectSpread({}, metadata), {}, {
92
- publishedPackage: publishedPackage,
93
- publisher: {
94
- name: remoteUser.name
95
- }
96
- });
97
- debug('template metadata %o', metadata);
98
- _context.n = 5;
99
- return compileTemplate(notifyEntry.content, metadata);
100
- case 5:
101
- content = _context.v;
102
- case 6:
103
- options = {
104
- body: content
105
- }; // provides fallback support, it's accept an Object {} and Array of {}
106
- if (notifyEntry.headers && Array.isArray(notifyEntry.headers)) {
107
- header = {}; // FIXME: we can simplify this
108
- notifyEntry.headers.map(function (item) {
109
- if (Object.is(item, item)) {
110
- for (var key in item) {
111
- /* eslint no-prototype-builtins: 0 */
112
- if (item.hasOwnProperty(key)) {
113
- header[key] = item[key];
114
- }
115
- }
116
- }
117
- });
118
- options.headers = header;
119
- } else if (Object.is(notifyEntry.headers, notifyEntry.headers)) {
120
- options.headers = notifyEntry.headers;
121
- }
122
- if (notifyEntry.endpoint) {
123
- _context.n = 7;
124
- break;
125
- }
126
- debug('error due endpoint is missing');
127
- throw new Error('missing parameter');
128
- case 7:
129
- return _context.a(2, (0, _notifyRequest.notifyRequest)(notifyEntry.endpoint, _objectSpread({
130
- method: notifyEntry.method
131
- }, options)));
132
- }
133
- }, _callee, null, [[0, 3]]);
134
- }));
135
- return _handleNotify.apply(this, arguments);
22
+ async function handleNotify(metadata, notifyEntry, remoteUser, publishedPackage) {
23
+ let regex;
24
+ try {
25
+ if (metadata.name && notifyEntry.packagePattern) {
26
+ debug$1("checking package pattern %o", notifyEntry.packagePattern);
27
+ debug$1("checking package pattern flags %o", notifyEntry.packagePatternFlags);
28
+ regex = new RegExp(notifyEntry.packagePattern, notifyEntry.packagePatternFlags ?? "");
29
+ if (!regex.test(metadata.name)) {
30
+ _verdaccio_logger.logger.debug("Notification exclude does not match %o", metadata.name);
31
+ return false;
32
+ }
33
+ debug$1("package pattern matched %o", metadata.name);
34
+ }
35
+ } catch (error) {
36
+ _verdaccio_logger.logger.error("Invalid regex pattern or flags: %o", error?.message);
37
+ return false;
38
+ }
39
+ let content;
40
+ if (typeof metadata?.publisher === "undefined" || metadata?.publisher === null) {
41
+ metadata = {
42
+ ...metadata,
43
+ publishedPackage,
44
+ publisher: { name: remoteUser.name }
45
+ };
46
+ debug$1("template metadata %o", metadata);
47
+ content = await compileTemplate(notifyEntry.content, metadata);
48
+ }
49
+ const options = { body: content };
50
+ if (notifyEntry.headers && Array.isArray(notifyEntry.headers)) {
51
+ const header = {};
52
+ notifyEntry.headers.map(function(item) {
53
+ if (Object.is(item, item)) {
54
+ for (const key in item) if (item.hasOwnProperty(key)) header[key] = item[key];
55
+ }
56
+ });
57
+ options.headers = header;
58
+ } else if (Object.is(notifyEntry.headers, notifyEntry.headers)) options.headers = notifyEntry.headers;
59
+ if (!notifyEntry.endpoint) {
60
+ debug$1("error due endpoint is missing");
61
+ throw new Error("missing parameter");
62
+ }
63
+ return require_notify_request.notifyRequest(notifyEntry.endpoint, {
64
+ method: notifyEntry.method,
65
+ ...options
66
+ });
136
67
  }
137
68
  function sendNotification(metadata, notify, remoteUser, publishedPackage) {
138
- return handleNotify(metadata, notify, remoteUser, publishedPackage);
69
+ return handleNotify(metadata, notify, remoteUser, publishedPackage);
139
70
  }
140
71
  function isHasNotification(value) {
141
- return value && _typeof(value) === 'object' && 'endpoint' in value && 'content' in value;
72
+ return value && typeof value === "object" && "endpoint" in value && "content" in value;
142
73
  }
143
- function notify(_x5, _x6, _x7, _x8) {
144
- return _notify.apply(this, arguments);
145
- }
146
- function _notify() {
147
- _notify = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(metadata, config, remoteUser, publishedPackage) {
148
- var notification, isSingle, response, notificationEntries, results, _t2, _t3;
149
- return _regenerator().w(function (_context2) {
150
- while (1) switch (_context2.p = _context2.n) {
151
- case 0:
152
- debug('init send notification');
153
- notification = config === null || config === void 0 ? void 0 : config.notify;
154
- if (notification) {
155
- _context2.n = 1;
156
- break;
157
- }
158
- debug('no notify configuration detected');
159
- return _context2.a(2, [false]);
160
- case 1:
161
- isSingle = isHasNotification(notification);
162
- debug('is single notify %o', isSingle);
163
- if (!isSingle) {
164
- _context2.n = 5;
165
- break;
166
- }
167
- debug('send single notification');
168
- _context2.p = 2;
169
- _context2.n = 3;
170
- return sendNotification(metadata, config.notify, remoteUser, publishedPackage);
171
- case 3:
172
- response = _context2.v;
173
- return _context2.a(2, [response]);
174
- case 4:
175
- _context2.p = 4;
176
- _t2 = _context2.v;
177
- debug('error on sending single notification');
178
- return _context2.a(2, [false]);
179
- case 5:
180
- _context2.p = 5;
181
- debug('send multiples notification');
182
- notificationEntries = Object.entries(notification).filter(function (_ref) {
183
- var _ref2 = _slicedToArray(_ref, 2),
184
- item = _ref2[1];
185
- return isHasNotification(item);
186
- });
187
- debug('valid notification entries %o', notificationEntries.length);
188
- if (!(notificationEntries.length === 0)) {
189
- _context2.n = 6;
190
- break;
191
- }
192
- return _context2.a(2, Object.keys(notification).map(function () {
193
- return false;
194
- }));
195
- case 6:
196
- debug('sending %o notifications', notificationEntries.length);
197
- _context2.n = 7;
198
- return Promise.allSettled(notificationEntries.map(function (_ref3) {
199
- var _ref4 = _slicedToArray(_ref3, 2),
200
- item = _ref4[1];
201
- return sendNotification(metadata, item, remoteUser, publishedPackage);
202
- }))["catch"](function (error) {
203
- _logger.logger.error({
204
- error: error
205
- }, 'notify request has failed: @error');
206
- });
207
- case 7:
208
- results = _context2.v;
209
- if (results) {
210
- _context2.n = 8;
211
- break;
212
- }
213
- return _context2.a(2, []);
214
- case 8:
215
- return _context2.a(2, results.map(function (result) {
216
- return result.status === 'fulfilled' ? result.value : false;
217
- }));
218
- case 9:
219
- _context2.p = 9;
220
- _t3 = _context2.v;
221
- debug('error on sending multiple notification %o', _t3);
222
- return _context2.a(2, Object.keys(notification).map(function () {
223
- return false;
224
- }));
225
- case 10:
226
- return _context2.a(2);
227
- }
228
- }, _callee2, null, [[5, 9], [2, 4]]);
229
- }));
230
- return _notify.apply(this, arguments);
74
+ async function notify(metadata, config, remoteUser, publishedPackage) {
75
+ debug$1("init send notification");
76
+ const notification = config?.notify;
77
+ if (!notification) {
78
+ debug$1("no notify configuration detected");
79
+ return [false];
80
+ }
81
+ const isSingle = isHasNotification(notification);
82
+ debug$1("is single notify %o", isSingle);
83
+ if (isSingle) {
84
+ debug$1("send single notification");
85
+ try {
86
+ return [await sendNotification(metadata, config.notify, remoteUser, publishedPackage)];
87
+ } catch {
88
+ debug$1("error on sending single notification");
89
+ return [false];
90
+ }
91
+ } else try {
92
+ debug$1("send multiples notification");
93
+ const notificationEntries = Object.entries(notification).filter(([, item]) => isHasNotification(item));
94
+ debug$1("valid notification entries %o", notificationEntries.length);
95
+ if (notificationEntries.length === 0) return Object.keys(notification).map(() => false);
96
+ debug$1("sending %o notifications", notificationEntries.length);
97
+ const results = await Promise.allSettled(notificationEntries.map(([, item]) => sendNotification(metadata, item, remoteUser, publishedPackage))).catch((error) => {
98
+ _verdaccio_logger.logger.error({ error }, "notify request has failed: @error");
99
+ });
100
+ if (!results) return [];
101
+ return results.map((result) => result.status === "fulfilled" ? result.value : false);
102
+ } catch (error) {
103
+ debug$1("error on sending multiple notification %o", error);
104
+ return Object.keys(notification).map(() => false);
105
+ }
231
106
  }
107
+ //#endregion
108
+ exports.handleNotify = handleNotify;
109
+ exports.notify = notify;
110
+ exports.sendNotification = sendNotification;
111
+
232
112
  //# sourceMappingURL=notify.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"notify.js","names":["_debug","_interopRequireDefault","require","_handlebars","_logger","_notifyRequest","e","__esModule","_slicedToArray","r","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","a","_arrayLikeToArray","t","toString","call","slice","constructor","name","Array","from","test","length","n","l","Symbol","iterator","i","u","f","o","next","Object","done","push","value","isArray","_regenerator","toStringTag","c","prototype","Generator","create","_regeneratorDefine2","p","y","G","v","d","bind","GeneratorFunction","GeneratorFunctionPrototype","getPrototypeOf","setPrototypeOf","__proto__","displayName","w","m","defineProperty","_regeneratorDefine","_invoke","enumerable","configurable","writable","ownKeys","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","apply","_objectSpread","arguments","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","_toPropertyKey","_toPrimitive","_typeof","toPrimitive","String","Number","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","_next","_throw","debug","buildDebug","compileTemplate","content","metadata","reject","handler","template","Handlebars","compile","error","message","logger","handleNotify","_x","_x2","_x3","_x4","_handleNotify","_callee","notifyEntry","remoteUser","publishedPackage","_metadata","_metadata2","regex","_notifyEntry$packageP","options","header","_t","_context","packagePattern","packagePatternFlags","RegExp","publisher","body","headers","map","item","is","key","hasOwnProperty","endpoint","Error","notifyRequest","method","sendNotification","notify","isHasNotification","_x5","_x6","_x7","_x8","_notify","_callee2","config","notification","isSingle","response","notificationEntries","results","_t2","_t3","_context2","entries","_ref","_ref2","allSettled","_ref3","_ref4","result","status"],"sources":["../src/notify.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport Handlebars from 'handlebars';\n\nimport { logger } from '@verdaccio/logger';\nimport type { Config, Manifest, Notification, RemoteUser } from '@verdaccio/types';\n\nimport type { FetchOptions } from './notify-request';\nimport { notifyRequest } from './notify-request';\n\nconst debug = buildDebug('verdaccio:hooks');\n\nexport function compileTemplate(content, metadata) {\n // FUTURE: multiple handlers\n return new Promise((resolve, reject) => {\n let handler;\n try {\n if (!handler) {\n debug('compile default template handler %o', content);\n const template: HandlebarsTemplateDelegate = Handlebars.compile(content);\n return resolve(template(metadata));\n }\n } catch (error: any) {\n debug('error template handler %o', error?.message);\n logger.error(\n { error: error.message },\n 'notification template compilation has failed: @{error}'\n );\n reject(error);\n }\n });\n}\n\nexport async function handleNotify(\n metadata: Partial<Manifest>,\n notifyEntry,\n remoteUser: Partial<RemoteUser>,\n publishedPackage: string\n): Promise<boolean> {\n let regex;\n try {\n if (metadata.name && notifyEntry.packagePattern) {\n debug('checking package pattern %o', notifyEntry.packagePattern);\n debug('checking package pattern flags %o', notifyEntry.packagePatternFlags);\n regex = new RegExp(notifyEntry.packagePattern, notifyEntry.packagePatternFlags ?? '');\n if (!regex.test(metadata.name)) {\n logger.debug('Notification exclude does not match %o', metadata.name);\n return false;\n }\n debug('package pattern matched %o', metadata.name);\n }\n } catch (error: any) {\n logger.error('Invalid regex pattern or flags: %o', error?.message);\n return false;\n }\n\n let content;\n // FIXME: publisher is not part of the expected types metadata\n // @ts-ignore\n if (typeof metadata?.publisher === 'undefined' || metadata?.publisher === null) {\n // @ts-ignore\n metadata = { ...metadata, publishedPackage, publisher: { name: remoteUser.name as string } };\n debug('template metadata %o', metadata);\n content = await compileTemplate(notifyEntry.content, metadata);\n }\n\n const options: FetchOptions = {\n body: content,\n };\n\n // provides fallback support, it's accept an Object {} and Array of {}\n if (notifyEntry.headers && Array.isArray(notifyEntry.headers)) {\n const header = {};\n // FIXME: we can simplify this\n notifyEntry.headers.map(function (item): void {\n if (Object.is(item, item)) {\n for (const key in item) {\n /* eslint no-prototype-builtins: 0 */\n if (item.hasOwnProperty(key)) {\n header[key] = item[key];\n }\n }\n }\n });\n options.headers = header;\n } else if (Object.is(notifyEntry.headers, notifyEntry.headers)) {\n options.headers = notifyEntry.headers;\n }\n\n if (!notifyEntry.endpoint) {\n debug('error due endpoint is missing');\n throw new Error('missing parameter');\n }\n\n return notifyRequest(notifyEntry.endpoint, {\n method: notifyEntry.method,\n ...options,\n });\n}\n\nexport function sendNotification(\n metadata: Manifest,\n notify: Notification,\n remoteUser: Partial<RemoteUser>,\n publishedPackage: string\n): Promise<boolean> {\n return handleNotify(metadata, notify, remoteUser, publishedPackage) as Promise<any>;\n}\n\nfunction isHasNotification(value: any): value is Notification {\n return value && typeof value === 'object' && 'endpoint' in value && 'content' in value;\n}\n\nexport async function notify(\n metadata: Manifest,\n config: Config,\n remoteUser: RemoteUser,\n publishedPackage: string\n): Promise<boolean[]> {\n debug('init send notification');\n const notification = config?.notify;\n if (!notification) {\n debug('no notify configuration detected');\n return [false];\n }\n\n const isSingle = isHasNotification(notification);\n debug('is single notify %o', isSingle);\n if (isSingle) {\n debug('send single notification');\n try {\n const response = await sendNotification(\n metadata,\n config.notify as Notification,\n remoteUser,\n publishedPackage\n );\n return [response];\n } catch {\n debug('error on sending single notification');\n return [false];\n }\n } else {\n try {\n debug('send multiples notification');\n const notificationEntries = Object.entries(notification).filter(([, item]) =>\n isHasNotification(item)\n );\n debug('valid notification entries %o', notificationEntries.length);\n if (notificationEntries.length === 0) {\n // No valid notifications, return false for each entry\n return Object.keys(notification).map(() => false);\n }\n debug('sending %o notifications', notificationEntries.length);\n const results = await Promise.allSettled(\n notificationEntries.map(([, item]) =>\n sendNotification(metadata, item, remoteUser, publishedPackage)\n )\n ).catch((error) => {\n logger.error({ error }, 'notify request has failed: @error');\n });\n if (!results) {\n return [];\n }\n return results.map((result) => (result.status === 'fulfilled' ? result.value : false));\n } catch (error) {\n debug('error on sending multiple notification %o', error);\n return Object.keys(notification).map(() => false);\n }\n }\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAIA,IAAAG,cAAA,GAAAH,OAAA;AAAiD,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAAA,SAAAE,eAAAC,CAAA,EAAAH,CAAA,WAAAI,eAAA,CAAAD,CAAA,KAAAE,qBAAA,CAAAF,CAAA,EAAAH,CAAA,KAAAM,2BAAA,CAAAH,CAAA,EAAAH,CAAA,KAAAO,gBAAA;AAAA,SAAAA,iBAAA,cAAAC,SAAA;AAAA,SAAAF,4B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AA;YAAA,OAC9BvB,gBAAgB,CAAC1C,QAAQ,EAAEkC,IAAI,EAAEjB,UAAU,EAAEC,gBAAgB,CAAC;UAAA,CAChE,CACF,CAAC,SAAM,CAAC,UAACZ,KAAK,EAAK;YACjBE,cAAM,CAACF,KAAK,CAAC;cAAEA,KAAK,EAALA;YAAM,CAAC,EAAE,mCAAmC,CAAC;UAC9D,CAAC,CAAC;QAAA;UANIkD,OAAO,GAAAG,SAAA,CAAAzG,CAAA;UAAA,IAORsG,OAAO;YAAAG,SAAA,CAAAjI,CAAA;YAAA;UAAA;UAAA,OAAAiI,SAAA,CAAA7I,CAAA,IACH,EAAE;QAAA;UAAA,OAAA6I,SAAA,CAAA7I,CAAA,IAEJ0I,OAAO,CAACvB,GAAG,CAAC,UAACiC,MAAM;YAAA,OAAMA,MAAM,CAACC,MAAM,KAAK,WAAW,GAAGD,MAAM,CAAC5H,KAAK,GAAG,KAAK;UAAA,CAAC,CAAC;QAAA;UAAAqH,SAAA,CAAA5G,CAAA;UAAA2G,GAAA,GAAAC,SAAA,CAAAzG,CAAA;UAEtF0C,KAAK,CAAC,2CAA2C,EAAA8D,GAAO,CAAC;UAAC,OAAAC,SAAA,CAAA7I,CAAA,IACnDqB,MAAM,CAACiC,IAAI,CAACgF,YAAY,CAAC,CAACnB,GAAG,CAAC;YAAA,OAAM,KAAK;UAAA,EAAC;QAAA;UAAA,OAAA0B,SAAA,CAAA7I,CAAA;MAAA;IAAA,GAAAoI,QAAA;EAAA,CAGtD;EAAA,OAAAD,OAAA,CAAAzE,KAAA,OAAAE,SAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"notify.js","names":[],"sources":["../src/notify.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport Handlebars from 'handlebars';\n\nimport { logger } from '@verdaccio/logger';\nimport type { Config, Manifest, Notification, RemoteUser } from '@verdaccio/types';\n\nimport type { FetchOptions } from './notify-request';\nimport { notifyRequest } from './notify-request';\n\nconst debug = buildDebug('verdaccio:hooks');\n\nexport function compileTemplate(content, metadata) {\n // FUTURE: multiple handlers\n return new Promise((resolve, reject) => {\n let handler;\n try {\n if (!handler) {\n debug('compile default template handler %o', content);\n const template: HandlebarsTemplateDelegate = Handlebars.compile(content);\n return resolve(template(metadata));\n }\n } catch (error: any) {\n debug('error template handler %o', error?.message);\n logger.error(\n { error: error.message },\n 'notification template compilation has failed: @{error}'\n );\n reject(error);\n }\n });\n}\n\nexport async function handleNotify(\n metadata: Partial<Manifest>,\n notifyEntry,\n remoteUser: Partial<RemoteUser>,\n publishedPackage: string\n): Promise<boolean> {\n let regex;\n try {\n if (metadata.name && notifyEntry.packagePattern) {\n debug('checking package pattern %o', notifyEntry.packagePattern);\n debug('checking package pattern flags %o', notifyEntry.packagePatternFlags);\n regex = new RegExp(notifyEntry.packagePattern, notifyEntry.packagePatternFlags ?? '');\n if (!regex.test(metadata.name)) {\n logger.debug('Notification exclude does not match %o', metadata.name);\n return false;\n }\n debug('package pattern matched %o', metadata.name);\n }\n } catch (error: any) {\n logger.error('Invalid regex pattern or flags: %o', error?.message);\n return false;\n }\n\n let content;\n // FIXME: publisher is not part of the expected types metadata\n // @ts-ignore\n if (typeof metadata?.publisher === 'undefined' || metadata?.publisher === null) {\n // @ts-ignore\n metadata = { ...metadata, publishedPackage, publisher: { name: remoteUser.name as string } };\n debug('template metadata %o', metadata);\n content = await compileTemplate(notifyEntry.content, metadata);\n }\n\n const options: FetchOptions = {\n body: content,\n };\n\n // provides fallback support, it's accept an Object {} and Array of {}\n if (notifyEntry.headers && Array.isArray(notifyEntry.headers)) {\n const header = {};\n // FIXME: we can simplify this\n notifyEntry.headers.map(function (item): void {\n if (Object.is(item, item)) {\n for (const key in item) {\n /* eslint no-prototype-builtins: 0 */\n if (item.hasOwnProperty(key)) {\n header[key] = item[key];\n }\n }\n }\n });\n options.headers = header;\n } else if (Object.is(notifyEntry.headers, notifyEntry.headers)) {\n options.headers = notifyEntry.headers;\n }\n\n if (!notifyEntry.endpoint) {\n debug('error due endpoint is missing');\n throw new Error('missing parameter');\n }\n\n return notifyRequest(notifyEntry.endpoint, {\n method: notifyEntry.method,\n ...options,\n });\n}\n\nexport function sendNotification(\n metadata: Manifest,\n notify: Notification,\n remoteUser: Partial<RemoteUser>,\n publishedPackage: string\n): Promise<boolean> {\n return handleNotify(metadata, notify, remoteUser, publishedPackage) as Promise<any>;\n}\n\nfunction isHasNotification(value: any): value is Notification {\n return value && typeof value === 'object' && 'endpoint' in value && 'content' in value;\n}\n\nexport async function notify(\n metadata: Manifest,\n config: Config,\n remoteUser: RemoteUser,\n publishedPackage: string\n): Promise<boolean[]> {\n debug('init send notification');\n const notification = config?.notify;\n if (!notification) {\n debug('no notify configuration detected');\n return [false];\n }\n\n const isSingle = isHasNotification(notification);\n debug('is single notify %o', isSingle);\n if (isSingle) {\n debug('send single notification');\n try {\n const response = await sendNotification(\n metadata,\n config.notify as Notification,\n remoteUser,\n publishedPackage\n );\n return [response];\n } catch {\n debug('error on sending single notification');\n return [false];\n }\n } else {\n try {\n debug('send multiples notification');\n const notificationEntries = Object.entries(notification).filter(([, item]) =>\n isHasNotification(item)\n );\n debug('valid notification entries %o', notificationEntries.length);\n if (notificationEntries.length === 0) {\n // No valid notifications, return false for each entry\n return Object.keys(notification).map(() => false);\n }\n debug('sending %o notifications', notificationEntries.length);\n const results = await Promise.allSettled(\n notificationEntries.map(([, item]) =>\n sendNotification(metadata, item, remoteUser, publishedPackage)\n )\n ).catch((error) => {\n logger.error({ error }, 'notify request has failed: @error');\n });\n if (!results) {\n return [];\n }\n return results.map((result) => (result.status === 'fulfilled' ? result.value : false));\n } catch (error) {\n debug('error on sending multiple notification %o', error);\n return Object.keys(notification).map(() => false);\n }\n }\n}\n"],"mappings":";;;;;;;;AASA,IAAM,WAAA,GAAA,MAAA,SAAmB,kBAAkB;AAE3C,SAAgB,gBAAgB,SAAS,UAAU;AAEjD,QAAO,IAAI,SAAS,SAAS,WAAW;AAEtC,MAAI;AAEA,WAAM,uCAAuC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AQ,KAAK,WAAY,OAAO,WAAW,cAAc,OAAO,QAAQ,MAAO;UAC/E,OAAO;AACd,UAAM,6CAA6C,MAAM;AACzD,SAAO,OAAO,KAAK,aAAa,CAAC,UAAU,MAAM"}
@@ -0,0 +1,107 @@
1
+ import { notifyRequest } from "./notify-request.mjs";
2
+ import buildDebug from "debug";
3
+ import Handlebars from "handlebars";
4
+ import { logger } from "@verdaccio/logger";
5
+ //#region src/notify.ts
6
+ var debug = buildDebug("verdaccio:hooks");
7
+ function compileTemplate(content, metadata) {
8
+ return new Promise((resolve, reject) => {
9
+ try {
10
+ debug("compile default template handler %o", content);
11
+ return resolve(Handlebars.compile(content)(metadata));
12
+ } catch (error) {
13
+ debug("error template handler %o", error?.message);
14
+ logger.error({ error: error.message }, "notification template compilation has failed: @{error}");
15
+ reject(error);
16
+ }
17
+ });
18
+ }
19
+ async function handleNotify(metadata, notifyEntry, remoteUser, publishedPackage) {
20
+ let regex;
21
+ try {
22
+ if (metadata.name && notifyEntry.packagePattern) {
23
+ debug("checking package pattern %o", notifyEntry.packagePattern);
24
+ debug("checking package pattern flags %o", notifyEntry.packagePatternFlags);
25
+ regex = new RegExp(notifyEntry.packagePattern, notifyEntry.packagePatternFlags ?? "");
26
+ if (!regex.test(metadata.name)) {
27
+ logger.debug("Notification exclude does not match %o", metadata.name);
28
+ return false;
29
+ }
30
+ debug("package pattern matched %o", metadata.name);
31
+ }
32
+ } catch (error) {
33
+ logger.error("Invalid regex pattern or flags: %o", error?.message);
34
+ return false;
35
+ }
36
+ let content;
37
+ if (typeof metadata?.publisher === "undefined" || metadata?.publisher === null) {
38
+ metadata = {
39
+ ...metadata,
40
+ publishedPackage,
41
+ publisher: { name: remoteUser.name }
42
+ };
43
+ debug("template metadata %o", metadata);
44
+ content = await compileTemplate(notifyEntry.content, metadata);
45
+ }
46
+ const options = { body: content };
47
+ if (notifyEntry.headers && Array.isArray(notifyEntry.headers)) {
48
+ const header = {};
49
+ notifyEntry.headers.map(function(item) {
50
+ if (Object.is(item, item)) {
51
+ for (const key in item) if (item.hasOwnProperty(key)) header[key] = item[key];
52
+ }
53
+ });
54
+ options.headers = header;
55
+ } else if (Object.is(notifyEntry.headers, notifyEntry.headers)) options.headers = notifyEntry.headers;
56
+ if (!notifyEntry.endpoint) {
57
+ debug("error due endpoint is missing");
58
+ throw new Error("missing parameter");
59
+ }
60
+ return notifyRequest(notifyEntry.endpoint, {
61
+ method: notifyEntry.method,
62
+ ...options
63
+ });
64
+ }
65
+ function sendNotification(metadata, notify, remoteUser, publishedPackage) {
66
+ return handleNotify(metadata, notify, remoteUser, publishedPackage);
67
+ }
68
+ function isHasNotification(value) {
69
+ return value && typeof value === "object" && "endpoint" in value && "content" in value;
70
+ }
71
+ async function notify(metadata, config, remoteUser, publishedPackage) {
72
+ debug("init send notification");
73
+ const notification = config?.notify;
74
+ if (!notification) {
75
+ debug("no notify configuration detected");
76
+ return [false];
77
+ }
78
+ const isSingle = isHasNotification(notification);
79
+ debug("is single notify %o", isSingle);
80
+ if (isSingle) {
81
+ debug("send single notification");
82
+ try {
83
+ return [await sendNotification(metadata, config.notify, remoteUser, publishedPackage)];
84
+ } catch {
85
+ debug("error on sending single notification");
86
+ return [false];
87
+ }
88
+ } else try {
89
+ debug("send multiples notification");
90
+ const notificationEntries = Object.entries(notification).filter(([, item]) => isHasNotification(item));
91
+ debug("valid notification entries %o", notificationEntries.length);
92
+ if (notificationEntries.length === 0) return Object.keys(notification).map(() => false);
93
+ debug("sending %o notifications", notificationEntries.length);
94
+ const results = await Promise.allSettled(notificationEntries.map(([, item]) => sendNotification(metadata, item, remoteUser, publishedPackage))).catch((error) => {
95
+ logger.error({ error }, "notify request has failed: @error");
96
+ });
97
+ if (!results) return [];
98
+ return results.map((result) => result.status === "fulfilled" ? result.value : false);
99
+ } catch (error) {
100
+ debug("error on sending multiple notification %o", error);
101
+ return Object.keys(notification).map(() => false);
102
+ }
103
+ }
104
+ //#endregion
105
+ export { handleNotify, notify, sendNotification };
106
+
107
+ //# sourceMappingURL=notify.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notify.mjs","names":[],"sources":["../src/notify.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport Handlebars from 'handlebars';\n\nimport { logger } from '@verdaccio/logger';\nimport type { Config, Manifest, Notification, RemoteUser } from '@verdaccio/types';\n\nimport type { FetchOptions } from './notify-request';\nimport { notifyRequest } from './notify-request';\n\nconst debug = buildDebug('verdaccio:hooks');\n\nexport function compileTemplate(content, metadata) {\n // FUTURE: multiple handlers\n return new Promise((resolve, reject) => {\n let handler;\n try {\n if (!handler) {\n debug('compile default template handler %o', content);\n const template: HandlebarsTemplateDelegate = Handlebars.compile(content);\n return resolve(template(metadata));\n }\n } catch (error: any) {\n debug('error template handler %o', error?.message);\n logger.error(\n { error: error.message },\n 'notification template compilation has failed: @{error}'\n );\n reject(error);\n }\n });\n}\n\nexport async function handleNotify(\n metadata: Partial<Manifest>,\n notifyEntry,\n remoteUser: Partial<RemoteUser>,\n publishedPackage: string\n): Promise<boolean> {\n let regex;\n try {\n if (metadata.name && notifyEntry.packagePattern) {\n debug('checking package pattern %o', notifyEntry.packagePattern);\n debug('checking package pattern flags %o', notifyEntry.packagePatternFlags);\n regex = new RegExp(notifyEntry.packagePattern, notifyEntry.packagePatternFlags ?? '');\n if (!regex.test(metadata.name)) {\n logger.debug('Notification exclude does not match %o', metadata.name);\n return false;\n }\n debug('package pattern matched %o', metadata.name);\n }\n } catch (error: any) {\n logger.error('Invalid regex pattern or flags: %o', error?.message);\n return false;\n }\n\n let content;\n // FIXME: publisher is not part of the expected types metadata\n // @ts-ignore\n if (typeof metadata?.publisher === 'undefined' || metadata?.publisher === null) {\n // @ts-ignore\n metadata = { ...metadata, publishedPackage, publisher: { name: remoteUser.name as string } };\n debug('template metadata %o', metadata);\n content = await compileTemplate(notifyEntry.content, metadata);\n }\n\n const options: FetchOptions = {\n body: content,\n };\n\n // provides fallback support, it's accept an Object {} and Array of {}\n if (notifyEntry.headers && Array.isArray(notifyEntry.headers)) {\n const header = {};\n // FIXME: we can simplify this\n notifyEntry.headers.map(function (item): void {\n if (Object.is(item, item)) {\n for (const key in item) {\n /* eslint no-prototype-builtins: 0 */\n if (item.hasOwnProperty(key)) {\n header[key] = item[key];\n }\n }\n }\n });\n options.headers = header;\n } else if (Object.is(notifyEntry.headers, notifyEntry.headers)) {\n options.headers = notifyEntry.headers;\n }\n\n if (!notifyEntry.endpoint) {\n debug('error due endpoint is missing');\n throw new Error('missing parameter');\n }\n\n return notifyRequest(notifyEntry.endpoint, {\n method: notifyEntry.method,\n ...options,\n });\n}\n\nexport function sendNotification(\n metadata: Manifest,\n notify: Notification,\n remoteUser: Partial<RemoteUser>,\n publishedPackage: string\n): Promise<boolean> {\n return handleNotify(metadata, notify, remoteUser, publishedPackage) as Promise<any>;\n}\n\nfunction isHasNotification(value: any): value is Notification {\n return value && typeof value === 'object' && 'endpoint' in value && 'content' in value;\n}\n\nexport async function notify(\n metadata: Manifest,\n config: Config,\n remoteUser: RemoteUser,\n publishedPackage: string\n): Promise<boolean[]> {\n debug('init send notification');\n const notification = config?.notify;\n if (!notification) {\n debug('no notify configuration detected');\n return [false];\n }\n\n const isSingle = isHasNotification(notification);\n debug('is single notify %o', isSingle);\n if (isSingle) {\n debug('send single notification');\n try {\n const response = await sendNotification(\n metadata,\n config.notify as Notification,\n remoteUser,\n publishedPackage\n );\n return [response];\n } catch {\n debug('error on sending single notification');\n return [false];\n }\n } else {\n try {\n debug('send multiples notification');\n const notificationEntries = Object.entries(notification).filter(([, item]) =>\n isHasNotification(item)\n );\n debug('valid notification entries %o', notificationEntries.length);\n if (notificationEntries.length === 0) {\n // No valid notifications, return false for each entry\n return Object.keys(notification).map(() => false);\n }\n debug('sending %o notifications', notificationEntries.length);\n const results = await Promise.allSettled(\n notificationEntries.map(([, item]) =>\n sendNotification(metadata, item, remoteUser, publishedPackage)\n )\n ).catch((error) => {\n logger.error({ error }, 'notify request has failed: @error');\n });\n if (!results) {\n return [];\n }\n return results.map((result) => (result.status === 'fulfilled' ? result.value : false));\n } catch (error) {\n debug('error on sending multiple notification %o', error);\n return Object.keys(notification).map(() => false);\n }\n }\n}\n"],"mappings":";;;;;AASA,IAAM,QAAQ,WAAW,kBAAkB;AAE3C,SAAgB,gBAAgB,SAAS,UAAU;AAEjD,QAAO,IAAI,SAAS,SAAS,WAAW;AAEtC,MAAI;AAEA,SAAM,uCAAuC,QAAQ;AAErD,UAAO,QADsC,WAAW,QAAQ,QAAQ,CAChD,SAAS,CAAC;WAE7B,OAAY;AACnB,SAAM,8BAA8B,OAAO,QAAQ;AACnD,UAAO,MACL,EAAE,OAAO,MAAM,SAAS,EACxB,yDACD;AACD,UAAO,MAAM;;GAEf;;AAGJ,eAAsB,aACpB,UACA,aACA,YACA,kBACkB;CAClB,IAAI;AACJ,KAAI;AACF,MAAI,SAAS,QAAQ,YAAY,gBAAgB;AAC/C,SAAM,+BAA+B,YAAY,eAAe;AAChE,SAAM,qCAAqC,YAAY,oBAAoB;AAC3E,WAAQ,IAAI,OAAO,YAAY,gBAAgB,YAAY,uBAAuB,GAAG;AACrF,OAAI,CAAC,MAAM,KAAK,SAAS,KAAK,EAAE;AAC9B,WAAO,MAAM,0CAA0C,SAAS,KAAK;AACrE,WAAO;;AAET,SAAM,8BAA8B,SAAS,KAAK;;UAE7C,OAAY;AACnB,SAAO,MAAM,sCAAsC,OAAO,QAAQ;AAClE,SAAO;;CAGT,IAAI;AAGJ,KAAI,OAAO,UAAU,cAAc,eAAe,UAAU,cAAc,MAAM;AAE9E,aAAW;GAAE,GAAG;GAAU;GAAkB,WAAW,EAAE,MAAM,WAAW,MAAgB;GAAE;AAC5F,QAAM,wBAAwB,SAAS;AACvC,YAAU,MAAM,gBAAgB,YAAY,SAAS,SAAS;;CAGhE,MAAM,UAAwB,EAC5B,MAAM,SACP;AAGD,KAAI,YAAY,WAAW,MAAM,QAAQ,YAAY,QAAQ,EAAE;EAC7D,MAAM,SAAS,EAAE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C7D,MAAM,UAAU,MAAM,QAAQ,WAC5B,oBAAoB,KAAK,GAAG,UAC1B,iBAAiB,UAAU,MAAM,YAAY,iBAAiB,CAC/D,CACF,CAAC,OAAO,UAAU;AACjB,UAAO,MAAM,EAAE,OAAO,EAAE,oCAAoC;IAC5D;AACF,MAAI,CAAC,QACH,QAAO,EAAE;AAEX,SAAO,QAAQ,KAAK,WAAY,OAAO,WAAW,cAAc,OAAO,QAAQ,MAAO;UAC/E,OAAO;AACd,QAAM,6CAA6C,MAAM;AACzD,SAAO,OAAO,KAAK,aAAa,CAAC,UAAU,MAAM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/hooks",
3
- "version": "9.0.0-next-9.2",
3
+ "version": "9.0.0-next-9.4",
4
4
  "description": "Verdaccio Hooks",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -33,16 +33,16 @@
33
33
  "node": ">=24"
34
34
  },
35
35
  "dependencies": {
36
- "@verdaccio/core": "9.0.0-next-9.2",
37
- "@verdaccio/logger": "9.0.0-next-9.2",
36
+ "@verdaccio/core": "9.0.0-next-9.4",
37
+ "@verdaccio/logger": "9.0.0-next-9.4",
38
38
  "debug": "4.4.3",
39
39
  "got-cjs": "12.5.4",
40
40
  "handlebars": "4.7.8"
41
41
  },
42
42
  "devDependencies": {
43
- "@verdaccio/config": "9.0.0-next-9.2",
44
- "@verdaccio/types": "14.0.0-next-9.0",
45
- "@verdaccio/test-helper": "5.0.0-next-9.2",
43
+ "@verdaccio/config": "9.0.0-next-9.4",
44
+ "@verdaccio/types": "14.0.0-next-9.1",
45
+ "@verdaccio/test-helper": "5.0.0-next-9.4",
46
46
  "nock": "13.5.6",
47
47
  "vitest": "3.2.4"
48
48
  },
@@ -50,13 +50,24 @@
50
50
  "type": "opencollective",
51
51
  "url": "https://opencollective.com/verdaccio"
52
52
  },
53
+ "module": "./build/index.mjs",
54
+ "exports": {
55
+ ".": {
56
+ "import": {
57
+ "types": "./build/index.d.ts",
58
+ "default": "./build/index.mjs"
59
+ },
60
+ "require": {
61
+ "types": "./build/index.d.ts",
62
+ "default": "./build/index.js"
63
+ }
64
+ },
65
+ "./build/*": "./build/*"
66
+ },
53
67
  "scripts": {
54
68
  "clean": "rimraf ./build",
55
69
  "test": "vitest run",
56
- "type-check": "tsc --noEmit -p tsconfig.build.json",
57
- "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
58
- "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
59
- "watch": "pnpm build:js -- --watch",
60
- "build": "pnpm run build:js && pnpm run build:types"
70
+ "watch": "vite build --watch",
71
+ "build": "vite build"
61
72
  }
62
73
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["_notify","require"],"sources":["../src/index.ts"],"sourcesContent":["export { handleNotify, notify, sendNotification } from './notify';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA","ignoreList":[]}