@verdaccio/hooks 8.0.6 → 8.1.1

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 type { Method } from 'got';
2
2
  export type FetchOptions = {
3
3
  body: string;
4
4
  headers?: {};
@@ -1,127 +1,73 @@
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');
24
- 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';
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 _verdaccio_core = require("@verdaccio/core");
6
+ //#region src/notify-request.ts
7
+ var debug$1 = (0, debug.default)("verdaccio:hooks:request");
8
+ var gotInstance;
9
+ function loadGot() {
10
+ gotInstance ??= import("got").then((mod) => mod.default);
11
+ return gotInstance;
37
12
  }
38
- var baseHeaders = {
39
- 'Content-Type': 'application/json'
40
- };
41
- function notifyRequest(_x, _x2) {
42
- return _notifyRequest.apply(this, arguments);
13
+ function verifyMethod(value) {
14
+ const valid = [
15
+ "GET",
16
+ "POST",
17
+ "PUT"
18
+ ];
19
+ if (typeof value === "string") {
20
+ const upper = value.toUpperCase();
21
+ if (valid.includes(upper)) return upper;
22
+ else _verdaccio_logger.logger.warn({ method: value }, "The notification method @{method} is not valid, using default POST method");
23
+ }
24
+ return "POST";
43
25
  }
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);
26
+ var baseHeaders = { "Content-Type": "application/json" };
27
+ async function notifyRequest(url, options) {
28
+ try {
29
+ const method = verifyMethod(options.method);
30
+ debug$1("uri %o", url);
31
+ debug$1("headers %o", options.headers);
32
+ debug$1("method %o", method);
33
+ let userHeaders = {};
34
+ if (options.headers) {
35
+ if (typeof options.headers === "string") userHeaders = JSON.parse(options.headers);
36
+ else if (typeof options.headers === "object") userHeaders = options.headers;
37
+ }
38
+ const requestOptions = {
39
+ method,
40
+ headers: {
41
+ ...baseHeaders,
42
+ ...userHeaders
43
+ }
44
+ };
45
+ let finalUrl = url;
46
+ if (method === "GET") {
47
+ debug$1("using GET with query params");
48
+ const urlObj = new URL(url);
49
+ const params = new URLSearchParams(options.body);
50
+ params.set("body", options.body);
51
+ urlObj.search = params.toString();
52
+ finalUrl = urlObj.toString();
53
+ debug$1("final url with search params %o", finalUrl);
54
+ } else if (options.body !== void 0) requestOptions.body = options.body;
55
+ else throw new Error("Notification body is undefined");
56
+ const response = await (await loadGot())(finalUrl, {
57
+ ...requestOptions,
58
+ throwHttpErrors: false
59
+ });
60
+ debug$1("response.status %o", response.statusCode);
61
+ if (response.statusCode >= _verdaccio_core.HTTP_STATUS.BAD_REQUEST) throw new Error(`notification service responded with status code ${response.statusCode}`);
62
+ _verdaccio_logger.logger.info({ content: options.body }, "The notification @{content} has been successfully dispatched");
63
+ return true;
64
+ } catch (err) {
65
+ debug$1("request error %o:", err?.message);
66
+ _verdaccio_logger.logger.error({ errorMessage: err?.message }, "notify service has thrown an error: @{errorMessage}");
67
+ return false;
68
+ }
126
69
  }
70
+ //#endregion
71
+ exports.notifyRequest = notifyRequest;
72
+
127
73
  //# 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,CAAA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SAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"notify-request.js","names":[],"sources":["../src/notify-request.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { Got, Method } from 'got';\n\nimport { HTTP_STATUS } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\n\nconst debug = buildDebug('verdaccio:hooks:request');\n\n// got >=12 is ESM-only; load it lazily through a dynamic import so the\n// CommonJS build can use it as well (import() is available from CJS code on\n// every supported Node.js, unlike require(esm) which needs >=22.12)\nlet gotInstance: Promise<Got> | undefined;\nfunction loadGot(): Promise<Got> {\n gotInstance ??= import('got').then((mod) => mod.default);\n return gotInstance;\n}\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 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: { method: Method; headers: Record<string, any>; body?: string } = {\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 const got = await loadGot();\n // validate the real HTTP status ourselves; the response body is not\n // required to be JSON (e.g. Slack replies with a plain \"ok\")\n const response = await got(finalUrl, {\n ...requestOptions,\n throwHttpErrors: false,\n });\n debug('response.status %o', response.statusCode);\n\n if (response.statusCode >= HTTP_STATUS.BAD_REQUEST) {\n throw new Error(`notification service responded with status code ${response.statusCode}`);\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":";;;;;;AAMA,IAAM,WAAA,GAAA,MAAA,SAAmB,yBAAyB;AAKlD,IAAI;AACJ,SAAS,UAAwB;CAC/B,gBAAgB,OAAO,OAAO,MAAM,QAAQ,IAAI,OAAO;CACvD,OAAO;AACT;AAQA,SAAgB,aAAa,OAAoB;CAC/C,MAAM,QAAkB;EAAC;EAAO;EAAQ;CAAK;CAE7C,IAAI,OAAO,UAAU,UAAU;EAC7B,MAAM,QAAQ,MAAM,YAAY;EAEhC,IAAI,MAAM,SAAS,KAAK,GACtB,OAAO;OAEP,kBAAA,OAAO,KACL,EAAE,QAAQ,MAAM,GAChB,2EACF;CAEJ;CAEA,OAAO;AACT;AAEA,IAAM,cAAc,EAAE,gBAAgB,mBAAmB;AACzD,eAAsB,cAAc,KAAa,SAAyC;CACxF,IAAI;EACF,MAAM,SAAiB,aAAa,QAAQ,MAAM;EAClD,QAAM,UAAU,GAAG;EACnB,QAAM,cAAc,QAAQ,OAAO;EACnC,QAAM,aAAa,MAAM;EAEzB,IAAI,cAAmC,CAAC;EAExC,IAAI,QAAQ;OACN,OAAO,QAAQ,YAAY,UAC7B,cAAc,KAAK,MAAM,QAAQ,OAAO;QACnC,IAAI,OAAO,QAAQ,YAAY,UACpC,cAAc,QAAQ;EAAA;EAK1B,MAAM,iBAAkF;GACtF;GACA,SAAA;IAHgB,GAAG;IAAa,GAAG;GAGnC;EACF;EAEA,IAAI,WAAW;EACf,IAAI,WAAW,OAAO;GACpB,QAAM,6BAA6B;GACnC,MAAM,SAAS,IAAI,IAAI,GAAG;GAC1B,MAAM,SAAS,IAAI,gBAAgB,QAAQ,IAAI;GAC/C,OAAO,IAAI,QAAQ,QAAQ,IAAI;GAC/B,OAAO,SAAS,OAAO,SAAS;GAChC,WAAW,OAAO,SAAS;GAC3B,QAAM,mCAAmC,QAAQ;EACnD,OAAO,IAAI,QAAQ,SAAS,KAAA,GAC1B,eAAe,OAAO,QAAQ;OAE9B,MAAM,IAAI,MAAM,gCAAgC;EAMlD,MAAM,WAAW,OAAM,MAHL,QAAQ,GAGC,UAAU;GACnC,GAAG;GACH,iBAAiB;EACnB,CAAC;EACD,QAAM,sBAAsB,SAAS,UAAU;EAE/C,IAAI,SAAS,cAAc,gBAAA,YAAY,aACrC,MAAM,IAAI,MAAM,mDAAmD,SAAS,YAAY;EAG1F,kBAAA,OAAO,KACL,EAAE,SAAS,QAAQ,KAAK,GACxB,8DACF;EACA,OAAO;CACT,SAAS,KAAU;EACjB,QAAM,qBAAqB,KAAK,OAAO;EACvC,kBAAA,OAAO,MACL,EAAE,cAAc,KAAK,QAAQ,GAC7B,qDACF;EACA,OAAO;CACT;AACF"}
@@ -0,0 +1,71 @@
1
+ import buildDebug from "debug";
2
+ import { logger } from "@verdaccio/logger";
3
+ import { HTTP_STATUS } from "@verdaccio/core";
4
+ //#region src/notify-request.ts
5
+ var debug = buildDebug("verdaccio:hooks:request");
6
+ var gotInstance;
7
+ function loadGot() {
8
+ gotInstance ??= import("got").then((mod) => mod.default);
9
+ return gotInstance;
10
+ }
11
+ function verifyMethod(value) {
12
+ const valid = [
13
+ "GET",
14
+ "POST",
15
+ "PUT"
16
+ ];
17
+ if (typeof value === "string") {
18
+ const upper = value.toUpperCase();
19
+ if (valid.includes(upper)) return upper;
20
+ else logger.warn({ method: value }, "The notification method @{method} is not valid, using default POST method");
21
+ }
22
+ return "POST";
23
+ }
24
+ var baseHeaders = { "Content-Type": "application/json" };
25
+ async function notifyRequest(url, options) {
26
+ try {
27
+ const method = verifyMethod(options.method);
28
+ debug("uri %o", url);
29
+ debug("headers %o", options.headers);
30
+ debug("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("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("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
+ const response = await (await loadGot())(finalUrl, {
55
+ ...requestOptions,
56
+ throwHttpErrors: false
57
+ });
58
+ debug("response.status %o", response.statusCode);
59
+ if (response.statusCode >= HTTP_STATUS.BAD_REQUEST) throw new Error(`notification service responded with status code ${response.statusCode}`);
60
+ logger.info({ content: options.body }, "The notification @{content} has been successfully dispatched");
61
+ return true;
62
+ } catch (err) {
63
+ debug("request error %o:", err?.message);
64
+ logger.error({ errorMessage: err?.message }, "notify service has thrown an error: @{errorMessage}");
65
+ return false;
66
+ }
67
+ }
68
+ //#endregion
69
+ export { notifyRequest };
70
+
71
+ //# 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 { Got, Method } from 'got';\n\nimport { HTTP_STATUS } from '@verdaccio/core';\nimport { logger } from '@verdaccio/logger';\n\nconst debug = buildDebug('verdaccio:hooks:request');\n\n// got >=12 is ESM-only; load it lazily through a dynamic import so the\n// CommonJS build can use it as well (import() is available from CJS code on\n// every supported Node.js, unlike require(esm) which needs >=22.12)\nlet gotInstance: Promise<Got> | undefined;\nfunction loadGot(): Promise<Got> {\n gotInstance ??= import('got').then((mod) => mod.default);\n return gotInstance;\n}\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 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: { method: Method; headers: Record<string, any>; body?: string } = {\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 const got = await loadGot();\n // validate the real HTTP status ourselves; the response body is not\n // required to be JSON (e.g. Slack replies with a plain \"ok\")\n const response = await got(finalUrl, {\n ...requestOptions,\n throwHttpErrors: false,\n });\n debug('response.status %o', response.statusCode);\n\n if (response.statusCode >= HTTP_STATUS.BAD_REQUEST) {\n throw new Error(`notification service responded with status code ${response.statusCode}`);\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":";;;;AAMA,IAAM,QAAQ,WAAW,yBAAyB;AAKlD,IAAI;AACJ,SAAS,UAAwB;CAC/B,gBAAgB,OAAO,OAAO,MAAM,QAAQ,IAAI,OAAO;CACvD,OAAO;AACT;AAQA,SAAgB,aAAa,OAAoB;CAC/C,MAAM,QAAkB;EAAC;EAAO;EAAQ;CAAK;CAE7C,IAAI,OAAO,UAAU,UAAU;EAC7B,MAAM,QAAQ,MAAM,YAAY;EAEhC,IAAI,MAAM,SAAS,KAAK,GACtB,OAAO;OAEP,OAAO,KACL,EAAE,QAAQ,MAAM,GAChB,2EACF;CAEJ;CAEA,OAAO;AACT;AAEA,IAAM,cAAc,EAAE,gBAAgB,mBAAmB;AACzD,eAAsB,cAAc,KAAa,SAAyC;CACxF,IAAI;EACF,MAAM,SAAiB,aAAa,QAAQ,MAAM;EAClD,MAAM,UAAU,GAAG;EACnB,MAAM,cAAc,QAAQ,OAAO;EACnC,MAAM,aAAa,MAAM;EAEzB,IAAI,cAAmC,CAAC;EAExC,IAAI,QAAQ;OACN,OAAO,QAAQ,YAAY,UAC7B,cAAc,KAAK,MAAM,QAAQ,OAAO;QACnC,IAAI,OAAO,QAAQ,YAAY,UACpC,cAAc,QAAQ;EAAA;EAK1B,MAAM,iBAAkF;GACtF;GACA,SAAA;IAHgB,GAAG;IAAa,GAAG;GAGnC;EACF;EAEA,IAAI,WAAW;EACf,IAAI,WAAW,OAAO;GACpB,MAAM,6BAA6B;GACnC,MAAM,SAAS,IAAI,IAAI,GAAG;GAC1B,MAAM,SAAS,IAAI,gBAAgB,QAAQ,IAAI;GAC/C,OAAO,IAAI,QAAQ,QAAQ,IAAI;GAC/B,OAAO,SAAS,OAAO,SAAS;GAChC,WAAW,OAAO,SAAS;GAC3B,MAAM,mCAAmC,QAAQ;EACnD,OAAO,IAAI,QAAQ,SAAS,KAAA,GAC1B,eAAe,OAAO,QAAQ;OAE9B,MAAM,IAAI,MAAM,gCAAgC;EAMlD,MAAM,WAAW,OAAM,MAHL,QAAQ,GAGC,UAAU;GACnC,GAAG;GACH,iBAAiB;EACnB,CAAC;EACD,MAAM,sBAAsB,SAAS,UAAU;EAE/C,IAAI,SAAS,cAAc,YAAY,aACrC,MAAM,IAAI,MAAM,mDAAmD,SAAS,YAAY;EAG1F,OAAO,KACL,EAAE,SAAS,QAAQ,KAAK,GACxB,8DACF;EACA,OAAO;CACT,SAAS,KAAU;EACjB,MAAM,qBAAqB,KAAK,OAAO;EACvC,OAAO,MACL,EAAE,cAAc,KAAK,QAAQ,GAC7B,qDACF;EACA,OAAO;CACT;AACF"}
package/build/notify.js CHANGED
@@ -1,224 +1,111 @@
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
- try {
36
- debug('compile default template handler %o', content);
37
- var template = _handlebars["default"].compile(content);
38
- return resolve(template(metadata));
39
- } catch (error) {
40
- debug('error template handler %o', error === null || error === void 0 ? void 0 : error.message);
41
- _logger.logger.error({
42
- error: error.message
43
- }, 'notification template compilation has failed: @{error}');
44
- reject(error);
45
- }
46
- });
47
- }
48
- function handleNotify(_x, _x2, _x3, _x4, _x5) {
49
- 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
+ });
50
21
  }
51
- function _handleNotify() {
52
- _handleNotify = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(metadata, notifyEntry, remoteUser, publishedPackage, publishType) {
53
- var regex, _notifyEntry$packageP, publishMetadata, content, options, header, _t;
54
- return _regenerator().w(function (_context) {
55
- while (1) switch (_context.p = _context.n) {
56
- case 0:
57
- _context.p = 0;
58
- if (!(metadata.name && notifyEntry.packagePattern)) {
59
- _context.n = 2;
60
- break;
61
- }
62
- debug('checking package pattern %o', notifyEntry.packagePattern);
63
- debug('checking package pattern flags %o', notifyEntry.packagePatternFlags);
64
- regex = new RegExp(notifyEntry.packagePattern, (_notifyEntry$packageP = notifyEntry.packagePatternFlags) !== null && _notifyEntry$packageP !== void 0 ? _notifyEntry$packageP : '');
65
- if (regex.test(metadata.name)) {
66
- _context.n = 1;
67
- break;
68
- }
69
- _logger.logger.debug('Notification exclude does not match %o', metadata.name);
70
- return _context.a(2, false);
71
- case 1:
72
- debug('package pattern matched %o', metadata.name);
73
- case 2:
74
- _context.n = 4;
75
- break;
76
- case 3:
77
- _context.p = 3;
78
- _t = _context.v;
79
- _logger.logger.error('Invalid regex pattern or flags: %o', _t === null || _t === void 0 ? void 0 : _t.message);
80
- return _context.a(2, false);
81
- case 4:
82
- publishMetadata = _objectSpread(_objectSpread(_objectSpread({}, metadata), typeof metadata.publisher === 'undefined' || metadata.publisher === null ? {
83
- // only expose the documented publisher fields, never the full remote
84
- // user object (it may carry the auth token, which must not leak to the
85
- // notification endpoint)
86
- publisher: {
87
- name: remoteUser.name,
88
- groups: remoteUser.groups,
89
- real_groups: remoteUser.real_groups
90
- }
91
- } : {}), {}, {
92
- publishedPackage: publishedPackage,
93
- publishType: publishType
94
- });
95
- debug('template metadata %o', publishMetadata);
96
- _context.n = 5;
97
- return compileTemplate(notifyEntry.content, publishMetadata);
98
- case 5:
99
- content = _context.v;
100
- options = {
101
- body: content
102
- }; // provides fallback support, it's accept an Object {} and Array of {}
103
- if (notifyEntry.headers && Array.isArray(notifyEntry.headers)) {
104
- header = {};
105
- notifyEntry.headers.forEach(function (item) {
106
- if (item && _typeof(item) === 'object') {
107
- Object.assign(header, item);
108
- }
109
- });
110
- options.headers = header;
111
- } else if (Object.is(notifyEntry.headers, notifyEntry.headers)) {
112
- options.headers = notifyEntry.headers;
113
- }
114
- if (notifyEntry.endpoint) {
115
- _context.n = 6;
116
- break;
117
- }
118
- debug('error due endpoint is missing');
119
- throw new Error('missing parameter');
120
- case 6:
121
- return _context.a(2, (0, _notifyRequest.notifyRequest)(notifyEntry.endpoint, _objectSpread({
122
- method: notifyEntry.method
123
- }, options)));
124
- }
125
- }, _callee, null, [[0, 3]]);
126
- }));
127
- return _handleNotify.apply(this, arguments);
22
+ async function handleNotify(metadata, notifyEntry, remoteUser, publishedPackage, publishType) {
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
+ const publishMetadata = {
40
+ ...metadata,
41
+ ...typeof metadata.publisher === "undefined" || metadata.publisher === null ? { publisher: {
42
+ name: remoteUser.name,
43
+ groups: remoteUser.groups,
44
+ real_groups: remoteUser.real_groups
45
+ } } : {},
46
+ publishedPackage,
47
+ publishType
48
+ };
49
+ debug$1("template metadata %o", publishMetadata);
50
+ const options = { body: await compileTemplate(notifyEntry.content, publishMetadata) };
51
+ if (notifyEntry.headers && Array.isArray(notifyEntry.headers)) {
52
+ const header = {};
53
+ notifyEntry.headers.forEach((item) => {
54
+ if (item && typeof item === "object") Object.assign(header, item);
55
+ });
56
+ options.headers = header;
57
+ } else if (Object.is(notifyEntry.headers, notifyEntry.headers)) options.headers = notifyEntry.headers;
58
+ if (!notifyEntry.endpoint) {
59
+ debug$1("error due endpoint is missing");
60
+ throw new Error("missing parameter");
61
+ }
62
+ return require_notify_request.notifyRequest(notifyEntry.endpoint, {
63
+ method: notifyEntry.method,
64
+ ...options
65
+ });
128
66
  }
129
67
  function sendNotification(metadata, notify, remoteUser, publishedPackage, publishType) {
130
- return handleNotify(metadata, notify, remoteUser, publishedPackage, publishType);
68
+ return handleNotify(metadata, notify, remoteUser, publishedPackage, publishType);
131
69
  }
132
70
  function isHasNotification(value) {
133
- return value && _typeof(value) === 'object' && 'endpoint' in value && 'content' in value;
71
+ return value && typeof value === "object" && "endpoint" in value && "content" in value;
134
72
  }
135
- function notify(_x6, _x7, _x8, _x9, _x0) {
136
- return _notify.apply(this, arguments);
137
- }
138
- function _notify() {
139
- _notify = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(metadata, config, remoteUser, publishedPackage, publishType) {
140
- var notification, isSingle, response, notificationEntries, results, _t2, _t3;
141
- return _regenerator().w(function (_context2) {
142
- while (1) switch (_context2.p = _context2.n) {
143
- case 0:
144
- debug('init send notification');
145
- notification = config === null || config === void 0 ? void 0 : config.notify;
146
- if (notification) {
147
- _context2.n = 1;
148
- break;
149
- }
150
- debug('no notify configuration detected');
151
- return _context2.a(2, [false]);
152
- case 1:
153
- isSingle = isHasNotification(notification);
154
- debug('is single notify %o', isSingle);
155
- if (!isSingle) {
156
- _context2.n = 5;
157
- break;
158
- }
159
- debug('send single notification');
160
- _context2.p = 2;
161
- _context2.n = 3;
162
- return sendNotification(metadata, config.notify, remoteUser, publishedPackage, publishType);
163
- case 3:
164
- response = _context2.v;
165
- return _context2.a(2, [response]);
166
- case 4:
167
- _context2.p = 4;
168
- _t2 = _context2.v;
169
- debug('error on sending single notification');
170
- return _context2.a(2, [false]);
171
- case 5:
172
- _context2.p = 5;
173
- debug('send multiples notification');
174
- notificationEntries = Object.entries(notification).filter(function (_ref) {
175
- var _ref2 = _slicedToArray(_ref, 2),
176
- item = _ref2[1];
177
- return isHasNotification(item);
178
- });
179
- debug('valid notification entries %o', notificationEntries.length);
180
- if (!(notificationEntries.length === 0)) {
181
- _context2.n = 6;
182
- break;
183
- }
184
- return _context2.a(2, Object.keys(notification).map(function () {
185
- return false;
186
- }));
187
- case 6:
188
- debug('sending %o notifications', notificationEntries.length);
189
- _context2.n = 7;
190
- return Promise.allSettled(notificationEntries.map(function (_ref3) {
191
- var _ref4 = _slicedToArray(_ref3, 2),
192
- item = _ref4[1];
193
- return sendNotification(metadata, item, remoteUser, publishedPackage, publishType);
194
- }))["catch"](function (error) {
195
- _logger.logger.error({
196
- error: error
197
- }, 'notify request has failed: @error');
198
- });
199
- case 7:
200
- results = _context2.v;
201
- if (results) {
202
- _context2.n = 8;
203
- break;
204
- }
205
- return _context2.a(2, []);
206
- case 8:
207
- return _context2.a(2, results.map(function (result) {
208
- return result.status === 'fulfilled' ? result.value : false;
209
- }));
210
- case 9:
211
- _context2.p = 9;
212
- _t3 = _context2.v;
213
- debug('error on sending multiple notification %o', _t3);
214
- return _context2.a(2, Object.keys(notification).map(function () {
215
- return false;
216
- }));
217
- case 10:
218
- return _context2.a(2);
219
- }
220
- }, _callee2, null, [[5, 9], [2, 4]]);
221
- }));
222
- return _notify.apply(this, arguments);
73
+ async function notify(metadata, config, remoteUser, publishedPackage, publishType) {
74
+ debug$1("init send notification");
75
+ const notification = config?.notify;
76
+ if (!notification) {
77
+ debug$1("no notify configuration detected");
78
+ return [false];
79
+ }
80
+ const isSingle = isHasNotification(notification);
81
+ debug$1("is single notify %o", isSingle);
82
+ if (isSingle) {
83
+ debug$1("send single notification");
84
+ try {
85
+ return [await sendNotification(metadata, config.notify, remoteUser, publishedPackage, publishType)];
86
+ } catch {
87
+ debug$1("error on sending single notification");
88
+ return [false];
89
+ }
90
+ } else try {
91
+ debug$1("send multiples notification");
92
+ const notificationEntries = Object.entries(notification).filter(([, item]) => isHasNotification(item));
93
+ debug$1("valid notification entries %o", notificationEntries.length);
94
+ if (notificationEntries.length === 0) return Object.keys(notification).map(() => false);
95
+ debug$1("sending %o notifications", notificationEntries.length);
96
+ const results = await Promise.allSettled(notificationEntries.map(([, item]) => sendNotification(metadata, item, remoteUser, publishedPackage, publishType))).catch((error) => {
97
+ _verdaccio_logger.logger.error({ error }, "notify request has failed: @error");
98
+ });
99
+ if (!results) return [];
100
+ return results.map((result) => result.status === "fulfilled" ? result.value : false);
101
+ } catch (error) {
102
+ debug$1("error on sending multiple notification %o", error);
103
+ return Object.keys(notification).map(() => false);
104
+ }
223
105
  }
106
+ //#endregion
107
+ exports.handleNotify = handleNotify;
108
+ exports.notify = notify;
109
+ exports.sendNotification = sendNotification;
110
+
224
111
  //# 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","template","Handlebars","compile","error","message","logger","handleNotify","_x","_x2","_x3","_x4","_x5","_handleNotify","_callee","notifyEntry","remoteUser","publishedPackage","publishType","regex","_notifyEntry$packageP","publishMetadata","options","header","_t","_context","packagePattern","packagePatternFlags","RegExp","publisher","groups","real_groups","body","headers","item","assign","is","endpoint","Error","notifyRequest","method","sendNotification","notify","isHasNotification","_x6","_x7","_x8","_x9","_x0","_notify","_callee2","config","notification","isSingle","response","notificationEntries","results","_t2","_t3","_context2","entries","_ref","_ref2","map","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 try {\n debug('compile default template handler %o', content);\n const template: HandlebarsTemplateDelegate = Handlebars.compile(content);\n return resolve(template(metadata));\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 publishType?: 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 const publishMetadata = {\n ...metadata,\n ...(typeof metadata.publisher === 'undefined' || metadata.publisher === null\n ? {\n // only expose the documented publisher fields, never the full remote\n // user object (it may carry the auth token, which must not leak to the\n // notification endpoint)\n publisher: {\n name: remoteUser.name,\n groups: remoteUser.groups,\n real_groups: remoteUser.real_groups,\n },\n }\n : {}),\n publishedPackage,\n publishType,\n };\n debug('template metadata %o', publishMetadata);\n const content = (await compileTemplate(notifyEntry.content, publishMetadata)) as string;\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 notifyEntry.headers.forEach((item): void => {\n if (item && typeof item === 'object') {\n Object.assign(header, item);\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 publishType?: string\n): Promise<boolean> {\n return handleNotify(metadata, notify, remoteUser, publishedPackage, publishType) 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 publishType?: 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 publishType\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, publishType)\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,4BAAAH,CAAA,EAAAM,CAAA,QAAAN,CAAA,2BAAAA,CAAA,SAAAO,iBAAA,CAAAP,CAAA,EAAAM,CAAA,OAAAE,CAAA,MAAAC,QAAA,CAAAC,IAAA,CAAAV,CAAA,EAAAW,KAAA,6BAAAH,CAAA,IAAAR,CAAA,CAAAY,WAAA,KAAAJ,CAAA,GAAAR,CAAA,CAAAY,WAAA,CAAAC,IAAA,aAAAL,CAAA,cAAAA,CAAA,GAAAM,KAAA,CAAAC,IAAA,CAAAf,CAAA,oBAAAQ,CAAA,+CAAAQ,IAAA,CAAAR,CAAA,IAAAD,iBAAA,CAAAP,CAAA,EAAAM,CAAA;AAAA,SAAAC,kBAAAP,CAAA,EAAAM,CAAA,aAAAA,CAAA,IAAAA,CAAA,GAAAN,CAAA,CAAAiB,MAAA,MAAAX,CAAA,GAAAN,CAAA,CAAAiB,MAAA,YAAApB,CAAA,MAAAqB,CAAA,GAAAJ,KAAA,CAAAR,CAAA,GAAAT,CAAA,GAAAS,CAAA,EAAAT,CAAA,IAAAqB,CAAA,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B,MAAM,CAACiC,IAAI,CAACiF,YAAY,CAAC,CAACW,GAAG,CAAC;YAAA,OAAM,KAAK;UAAA,EAAC;QAAA;UAAA,OAAAJ,SAAA,CAAA9I,CAAA;MAAA;IAAA,GAAAqI,QAAA;EAAA,CAGtD;EAAA,OAAAD,OAAA,CAAA1E,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 try {\n debug('compile default template handler %o', content);\n const template: HandlebarsTemplateDelegate = Handlebars.compile(content);\n return resolve(template(metadata));\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 publishType?: 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 const publishMetadata = {\n ...metadata,\n ...(typeof metadata.publisher === 'undefined' || metadata.publisher === null\n ? {\n // only expose the documented publisher fields, never the full remote\n // user object (it may carry the auth token, which must not leak to the\n // notification endpoint)\n publisher: {\n name: remoteUser.name,\n groups: remoteUser.groups,\n real_groups: remoteUser.real_groups,\n },\n }\n : {}),\n publishedPackage,\n publishType,\n };\n debug('template metadata %o', publishMetadata);\n const content = (await compileTemplate(notifyEntry.content, publishMetadata)) as string;\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 notifyEntry.headers.forEach((item): void => {\n if (item && typeof item === 'object') {\n Object.assign(header, item);\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 publishType?: string\n): Promise<boolean> {\n return handleNotify(metadata, notify, remoteUser, publishedPackage, publishType) 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 publishType?: 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 publishType\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, publishType)\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,iBAAiB;AAE1C,SAAgB,gBAAgB,SAAS,UAAU;CAEjD,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,IAAI;GACF,QAAM,uCAAuC,OAAO;GAEpD,OAAO,QADsC,WAAA,QAAW,QAAQ,OACjD,EAAS,QAAQ,CAAC;EACnC,SAAS,OAAY;GACnB,QAAM,8BAA8B,OAAO,OAAO;GAClD,kBAAA,OAAO,MACL,EAAE,OAAO,MAAM,QAAQ,GACvB,wDACF;GACA,OAAO,KAAK;EACd;CACF,CAAC;AACH;AAEA,eAAsB,aACpB,UACA,aACA,YACA,kBACA,aACkB;CAClB,IAAI;CACJ,IAAI;EACF,IAAI,SAAS,QAAQ,YAAY,gBAAgB;GAC/C,QAAM,+BAA+B,YAAY,cAAc;GAC/D,QAAM,qCAAqC,YAAY,mBAAmB;GAC1E,QAAQ,IAAI,OAAO,YAAY,gBAAgB,YAAY,uBAAuB,EAAE;GACpF,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,GAAG;IAC9B,kBAAA,OAAO,MAAM,0CAA0C,SAAS,IAAI;IACpE,OAAO;GACT;GACA,QAAM,8BAA8B,SAAS,IAAI;EACnD;CACF,SAAS,OAAY;EACnB,kBAAA,OAAO,MAAM,sCAAsC,OAAO,OAAO;EACjE,OAAO;CACT;CAEA,MAAM,kBAAkB;EACtB,GAAG;E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ACP,YACA,kBACA,WACF,CACgB;EAClB,QAAQ;GACN,QAAM,sCAAsC;GAC5C,OAAO,CAAC,KAAK;EACf;CACF,OACE,IAAI;EACF,QAAM,6BAA6B;EACnC,MAAM,sBAAsB,OAAO,QAAQ,YAAY,EAAE,QAAQ,GAAG,UAClE,kBAAkB,IAAI,CACxB;EACA,QAAM,iCAAiC,oBAAoB,MAAM;EACjE,IAAI,oBAAoB,WAAW,GAEjC,OAAO,OAAO,KAAK,YAAY,EAAE,UAAU,KAAK;EAElD,QAAM,4BAA4B,oBAAoB,MAAM;EAC5D,MAAM,UAAU,MAAM,QAAQ,WAC5B,oBAAoB,KAAK,GAAG,UAC1B,iBAAiB,UAAU,MAAM,YAAY,kBAAkB,WAAW,CAC5E,CACF,EAAE,OAAO,UAAU;GACjB,kBAAA,OAAO,MAAM,EAAE,MAAM,GAAG,mCAAmC;EAC7D,CAAC;EACD,IAAI,CAAC,SACH,OAAO,CAAC;EAEV,OAAO,QAAQ,KAAK,WAAY,OAAO,WAAW,cAAc,OAAO,QAAQ,KAAM;CACvF,SAAS,OAAO;EACd,QAAM,6CAA6C,KAAK;EACxD,OAAO,OAAO,KAAK,YAAY,EAAE,UAAU,KAAK;CAClD;AAEJ"}
@@ -0,0 +1,106 @@
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, publishType) {
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
+ const publishMetadata = {
37
+ ...metadata,
38
+ ...typeof metadata.publisher === "undefined" || metadata.publisher === null ? { publisher: {
39
+ name: remoteUser.name,
40
+ groups: remoteUser.groups,
41
+ real_groups: remoteUser.real_groups
42
+ } } : {},
43
+ publishedPackage,
44
+ publishType
45
+ };
46
+ debug("template metadata %o", publishMetadata);
47
+ const options = { body: await compileTemplate(notifyEntry.content, publishMetadata) };
48
+ if (notifyEntry.headers && Array.isArray(notifyEntry.headers)) {
49
+ const header = {};
50
+ notifyEntry.headers.forEach((item) => {
51
+ if (item && typeof item === "object") Object.assign(header, item);
52
+ });
53
+ options.headers = header;
54
+ } else if (Object.is(notifyEntry.headers, notifyEntry.headers)) options.headers = notifyEntry.headers;
55
+ if (!notifyEntry.endpoint) {
56
+ debug("error due endpoint is missing");
57
+ throw new Error("missing parameter");
58
+ }
59
+ return notifyRequest(notifyEntry.endpoint, {
60
+ method: notifyEntry.method,
61
+ ...options
62
+ });
63
+ }
64
+ function sendNotification(metadata, notify, remoteUser, publishedPackage, publishType) {
65
+ return handleNotify(metadata, notify, remoteUser, publishedPackage, publishType);
66
+ }
67
+ function isHasNotification(value) {
68
+ return value && typeof value === "object" && "endpoint" in value && "content" in value;
69
+ }
70
+ async function notify(metadata, config, remoteUser, publishedPackage, publishType) {
71
+ debug("init send notification");
72
+ const notification = config?.notify;
73
+ if (!notification) {
74
+ debug("no notify configuration detected");
75
+ return [false];
76
+ }
77
+ const isSingle = isHasNotification(notification);
78
+ debug("is single notify %o", isSingle);
79
+ if (isSingle) {
80
+ debug("send single notification");
81
+ try {
82
+ return [await sendNotification(metadata, config.notify, remoteUser, publishedPackage, publishType)];
83
+ } catch {
84
+ debug("error on sending single notification");
85
+ return [false];
86
+ }
87
+ } else try {
88
+ debug("send multiples notification");
89
+ const notificationEntries = Object.entries(notification).filter(([, item]) => isHasNotification(item));
90
+ debug("valid notification entries %o", notificationEntries.length);
91
+ if (notificationEntries.length === 0) return Object.keys(notification).map(() => false);
92
+ debug("sending %o notifications", notificationEntries.length);
93
+ const results = await Promise.allSettled(notificationEntries.map(([, item]) => sendNotification(metadata, item, remoteUser, publishedPackage, publishType))).catch((error) => {
94
+ logger.error({ error }, "notify request has failed: @error");
95
+ });
96
+ if (!results) return [];
97
+ return results.map((result) => result.status === "fulfilled" ? result.value : false);
98
+ } catch (error) {
99
+ debug("error on sending multiple notification %o", error);
100
+ return Object.keys(notification).map(() => false);
101
+ }
102
+ }
103
+ //#endregion
104
+ export { handleNotify, notify, sendNotification };
105
+
106
+ //# 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 try {\n debug('compile default template handler %o', content);\n const template: HandlebarsTemplateDelegate = Handlebars.compile(content);\n return resolve(template(metadata));\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 publishType?: 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 const publishMetadata = {\n ...metadata,\n ...(typeof metadata.publisher === 'undefined' || metadata.publisher === null\n ? {\n // only expose the documented publisher fields, never the full remote\n // user object (it may carry the auth token, which must not leak to the\n // notification endpoint)\n publisher: {\n name: remoteUser.name,\n groups: remoteUser.groups,\n real_groups: remoteUser.real_groups,\n },\n }\n : {}),\n publishedPackage,\n publishType,\n };\n debug('template metadata %o', publishMetadata);\n const content = (await compileTemplate(notifyEntry.content, publishMetadata)) as string;\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 notifyEntry.headers.forEach((item): void => {\n if (item && typeof item === 'object') {\n Object.assign(header, item);\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 publishType?: string\n): Promise<boolean> {\n return handleNotify(metadata, notify, remoteUser, publishedPackage, publishType) 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 publishType?: 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 publishType\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, publishType)\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,iBAAiB;AAE1C,SAAgB,gBAAgB,SAAS,UAAU;CAEjD,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,IAAI;GACF,MAAM,uCAAuC,OAAO;GAEpD,OAAO,QADsC,WAAW,QAAQ,OACjD,EAAS,QAAQ,CAAC;EACnC,SAAS,OAAY;GACnB,MAAM,8BAA8B,OAAO,OAAO;GAClD,OAAO,MACL,EAAE,OAAO,MAAM,QAAQ,GACvB,wDACF;GACA,OAAO,KAAK;EACd;CACF,CAAC;AACH;AAEA,eAAsB,aACpB,UACA,aACA,YACA,kBACA,aACkB;CAClB,I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"name": "@verdaccio/hooks",
3
- "version": "8.0.6",
3
+ "version": "8.1.1",
4
4
  "description": "Verdaccio Hooks",
5
5
  "keywords": [
6
6
  "enterprise",
@@ -32,31 +32,44 @@
32
32
  "url": "https://opencollective.com/verdaccio"
33
33
  },
34
34
  "main": "./build/index.js",
35
- "types": "build/index.d.ts",
35
+ "module": "./build/index.mjs",
36
+ "types": "./build/index.d.ts",
37
+ "exports": {
38
+ ".": {
39
+ "import": {
40
+ "types": "./build/index.d.ts",
41
+ "default": "./build/index.mjs"
42
+ },
43
+ "require": {
44
+ "types": "./build/index.d.ts",
45
+ "default": "./build/index.js"
46
+ }
47
+ },
48
+ "./build/*": "./build/*"
49
+ },
36
50
  "dependencies": {
37
- "@verdaccio/core": "8.1.4",
38
- "@verdaccio/logger": "8.0.5",
51
+ "@verdaccio/core": "8.2.0",
52
+ "@verdaccio/logger": "8.1.0",
39
53
  "debug": "4.4.3",
40
- "got-cjs": "12.5.4",
54
+ "got": "15.1.0",
41
55
  "handlebars": "4.7.9"
42
56
  },
43
57
  "devDependencies": {
44
- "@verdaccio/config": "8.1.4",
58
+ "@verdaccio/config": "8.2.0",
45
59
  "@verdaccio/types": "13.0.5",
46
- "nock": "13.5.6",
60
+ "nock": "14.0.16",
61
+ "vite": "8.0.16",
47
62
  "vitest": "4.1.2",
48
- "@verdaccio/test-helper": "4.0.8"
63
+ "@verdaccio/test-helper": "4.1.0"
49
64
  },
50
65
  "engines": {
51
- "node": ">=18"
66
+ "node": ">=22"
52
67
  },
53
68
  "scripts": {
54
69
  "clean": "rimraf ./build",
55
70
  "test": "vitest run",
56
71
  "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"
72
+ "watch": "vite build --watch",
73
+ "build": "vite build && tsc --emitDeclarationOnly -p tsconfig.build.json"
61
74
  }
62
75
  }
@@ -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":[]}