@verdaccio/signature 8.0.4 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/_virtual/_rolldown/runtime.js +33 -0
- package/build/_virtual/_rolldown/runtime.mjs +13 -0
- package/build/index.d.ts +2 -2
- package/build/index.js +26 -77
- package/build/index.mjs +6 -0
- package/build/jwt-token.js +35 -61
- package/build/jwt-token.js.map +1 -1
- package/build/jwt-token.mjs +35 -0
- package/build/jwt-token.mjs.map +1 -0
- package/build/signature.js +42 -62
- package/build/signature.js.map +1 -1
- package/build/signature.mjs +45 -0
- package/build/signature.mjs.map +1 -0
- package/build/token.js +22 -34
- package/build/token.js.map +1 -1
- package/build/token.mjs +26 -0
- package/build/token.mjs.map +1 -0
- package/build/types.js +9 -4
- package/build/types.js.map +1 -1
- package/build/types.mjs +7 -0
- package/build/types.mjs.map +1 -0
- package/build/utils.js +21 -28
- package/build/utils.js.map +1 -1
- package/build/utils.mjs +20 -0
- package/build/utils.mjs.map +1 -0
- package/package.json +23 -10
- package/build/index.js.map +0 -1
- package/build/legacy-signature/index.d.ts +0 -21
- package/build/legacy-signature/index.js +0 -65
- package/build/legacy-signature/index.js.map +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
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 __exportAll = (all, no_symbols) => {
|
|
9
|
+
let target = {};
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
|
+
return target;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
19
|
+
key = keys[i];
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
21
|
+
get: ((k) => from[k]).bind(null, key),
|
|
22
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.__exportAll = __exportAll;
|
|
33
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll };
|
package/build/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { aesDecryptDeprecated, aesEncryptDeprecated, generateRandomSecretKeyDeprecated, } from './legacy-signature';
|
|
2
1
|
export { aesDecrypt, aesEncrypt } from './signature';
|
|
3
|
-
export { signPayload, verifyPayload
|
|
2
|
+
export { signPayload, verifyPayload } from './jwt-token';
|
|
3
|
+
export type { SignOptionsSignature, VerifyOptionsSignature } from './jwt-token';
|
|
4
4
|
export * as utils from './utils';
|
|
5
5
|
export * as types from './types';
|
|
6
6
|
export { parseBasicPayload } from './token';
|
package/build/index.js
CHANGED
|
@@ -1,77 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
get: function get() {
|
|
28
|
-
return _legacySignature.aesDecryptDeprecated;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(exports, "aesEncrypt", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function get() {
|
|
34
|
-
return _signature.aesEncrypt;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(exports, "aesEncryptDeprecated", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function get() {
|
|
40
|
-
return _legacySignature.aesEncryptDeprecated;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(exports, "generateRandomSecretKeyDeprecated", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function get() {
|
|
46
|
-
return _legacySignature.generateRandomSecretKeyDeprecated;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(exports, "parseBasicPayload", {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
get: function get() {
|
|
52
|
-
return _token.parseBasicPayload;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(exports, "signPayload", {
|
|
56
|
-
enumerable: true,
|
|
57
|
-
get: function get() {
|
|
58
|
-
return _jwtToken.signPayload;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
exports.utils = exports.types = void 0;
|
|
62
|
-
Object.defineProperty(exports, "verifyPayload", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
get: function get() {
|
|
65
|
-
return _jwtToken.verifyPayload;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
var _legacySignature = require("./legacy-signature");
|
|
69
|
-
var _signature = require("./signature");
|
|
70
|
-
var _jwtToken = require("./jwt-token");
|
|
71
|
-
var _utils = _interopRequireWildcard(require("./utils"));
|
|
72
|
-
exports.utils = _utils;
|
|
73
|
-
var _types = _interopRequireWildcard(require("./types"));
|
|
74
|
-
exports.types = _types;
|
|
75
|
-
var _token = require("./token");
|
|
76
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
77
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
const require_signature = require("./signature.js");
|
|
6
|
+
const require_jwt_token = require("./jwt-token.js");
|
|
7
|
+
const require_utils = require("./utils.js");
|
|
8
|
+
const require_types = require("./types.js");
|
|
9
|
+
const require_token = require("./token.js");
|
|
10
|
+
exports.aesDecrypt = require_signature.aesDecrypt;
|
|
11
|
+
exports.aesEncrypt = require_signature.aesEncrypt;
|
|
12
|
+
exports.parseBasicPayload = require_token.parseBasicPayload;
|
|
13
|
+
exports.signPayload = require_jwt_token.signPayload;
|
|
14
|
+
Object.defineProperty(exports, "types", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function() {
|
|
17
|
+
return require_types.types_exports;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "utils", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return require_utils.utils_exports;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
exports.verifyPayload = require_jwt_token.verifyPayload;
|
package/build/index.mjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { aesDecrypt, aesEncrypt } from "./signature.mjs";
|
|
2
|
+
import { signPayload, verifyPayload } from "./jwt-token.mjs";
|
|
3
|
+
import { utils_exports } from "./utils.mjs";
|
|
4
|
+
import { types_exports } from "./types.mjs";
|
|
5
|
+
import { parseBasicPayload } from "./token.mjs";
|
|
6
|
+
export { aesDecrypt, aesEncrypt, parseBasicPayload, signPayload, types_exports as types, utils_exports as utils, verifyPayload };
|
package/build/jwt-token.js
CHANGED
|
@@ -1,65 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
-
var _jsonwebtoken = _interopRequireDefault(require("jsonwebtoken"));
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
|
-
function _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 }; })(); }
|
|
13
|
-
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); }
|
|
14
|
-
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; }
|
|
15
|
-
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; }
|
|
16
|
-
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; }
|
|
17
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
18
|
-
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); }
|
|
19
|
-
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); }
|
|
20
|
-
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); }); }; }
|
|
21
|
-
var debug = (0, _debug["default"])('verdaccio:auth:token:jwt');
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
let debug = require("debug");
|
|
3
|
+
debug = require_runtime.__toESM(debug);
|
|
4
|
+
let jsonwebtoken = require("jsonwebtoken");
|
|
5
|
+
jsonwebtoken = require_runtime.__toESM(jsonwebtoken);
|
|
6
|
+
//#region src/jwt-token.ts
|
|
7
|
+
var debug$1 = (0, debug.default)("verdaccio:auth:token:jwt");
|
|
22
8
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
function signPayload(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// 1 === 1ms (one millisecond)
|
|
45
|
-
notBefore: '1ms'
|
|
46
|
-
}, options), function (error, token) {
|
|
47
|
-
if (error) {
|
|
48
|
-
debug('error on sign jwt token %s', error.message);
|
|
49
|
-
return reject(error);
|
|
50
|
-
}
|
|
51
|
-
debug('signed jwt token successfully');
|
|
52
|
-
return resolve(token);
|
|
53
|
-
});
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
56
|
-
}, _callee);
|
|
57
|
-
}));
|
|
58
|
-
return _signPayload.apply(this, arguments);
|
|
9
|
+
* Sign the payload and return JWT
|
|
10
|
+
* https://github.com/auth0/node-jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback
|
|
11
|
+
* @param payload
|
|
12
|
+
* @param secretOrPrivateKey
|
|
13
|
+
* @param options
|
|
14
|
+
*/
|
|
15
|
+
async function signPayload(payload, secretOrPrivateKey, options = {}) {
|
|
16
|
+
return new Promise(function(resolve, reject) {
|
|
17
|
+
debug$1("sign jwt token");
|
|
18
|
+
jsonwebtoken.default.sign(payload, secretOrPrivateKey, {
|
|
19
|
+
notBefore: "1ms",
|
|
20
|
+
...options
|
|
21
|
+
}, (error, token) => {
|
|
22
|
+
if (error) {
|
|
23
|
+
debug$1("error on sign jwt token %s", error.message);
|
|
24
|
+
return reject(error);
|
|
25
|
+
}
|
|
26
|
+
debug$1("signed jwt token successfully");
|
|
27
|
+
return resolve(token);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
59
30
|
}
|
|
60
|
-
function verifyPayload(token, secretOrPrivateKey) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return _jsonwebtoken["default"].verify(token, secretOrPrivateKey, options);
|
|
31
|
+
function verifyPayload(token, secretOrPrivateKey, options = {}) {
|
|
32
|
+
debug$1("verifying jwt token");
|
|
33
|
+
return jsonwebtoken.default.verify(token, secretOrPrivateKey, options);
|
|
64
34
|
}
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.signPayload = signPayload;
|
|
37
|
+
exports.verifyPayload = verifyPayload;
|
|
38
|
+
|
|
65
39
|
//# sourceMappingURL=jwt-token.js.map
|
package/build/jwt-token.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-token.js","names":["_debug","_interopRequireDefault","require","_jsonwebtoken","e","__esModule","_typeof","o","Symbol","iterator","constructor","prototype","_regenerator","t","r","n","toStringTag","i","c","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","toPrimitive","String","Number","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","_next","_throw","debug","buildDebug","signPayload","_x","_x2","_signPayload","_callee","payload","secretOrPrivateKey","options","_args","_context","undefined","reject","jwt","sign","notBefore","error","token","message","verifyPayload","verify"],"sources":["../src/jwt-token.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { SignOptions, VerifyOptions } from 'jsonwebtoken';\nimport jwt from 'jsonwebtoken';\n\nimport type { RemoteUser } from '@verdaccio/types';\n\nexport type SignOptionsSignature = SignOptions;\nexport type VerifyOptionsSignature = VerifyOptions;\n\nconst debug = buildDebug('verdaccio:auth:token:jwt');\n/**\n * Sign the payload and return JWT\n * https://github.com/auth0/node-jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback\n * @param payload\n * @param secretOrPrivateKey\n * @param options\n */\nexport async function signPayload(\n payload: RemoteUser,\n secretOrPrivateKey: string,\n options: SignOptionsSignature = {}\n): Promise<string> {\n return new Promise(function (resolve, reject) {\n debug('sign jwt token');\n jwt.sign(\n payload,\n secretOrPrivateKey, // FIXME: upgrade to the latest library and types\n {\n // 1 === 1ms (one millisecond)\n notBefore: '1ms', // Make sure the time will not rollback :)\n ...options,\n },\n (error, token) => {\n if (error) {\n debug('error on sign jwt token %s', error.message);\n return reject(error);\n }\n debug('signed jwt token successfully');\n return resolve(token as string);\n }\n );\n });\n}\n\nexport function verifyPayload(\n token: string,\n secretOrPrivateKey: string,\n options: VerifyOptionsSignature = {}\n): RemoteUser {\n debug('verifying jwt token');\n return jwt.verify(token, secretOrPrivateKey, options) as RemoteUser;\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA+B,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAAA,SAAAE,QAAAC,CAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAF,CAAA,kBAAAA,CAAA,gBAAAA,CAAA,WAAAA,CAAA,yBAAAC,MAAA,IAAAD,CAAA,CAAAG,WAAA,KAAAF,MAAA,IAAAD,CAAA,KAAAC,MAAA,CAAAG,SAAA,qBAAAJ,CAAA,KAAAD,OAAA,CAAAC,CAAA;AAAA,SAAAK,aAAA,IAD/B,uKAAAR,CAAA,EAAAS,CAAA,EAAAC,CAAA,wBAAAN,MAAA,GAAAA,MAAA,OAAAO,CAAA,GAAAD,CAAA,CAAAL,QAAA,kBAAAF,CAAA,GAAAO,CAAA,CAAAE,WAAA,8BAAAC,EAAAH,CAAA,EAAAC,CAAA,EAAAR,CAAA,EAAAU,CAAA,QAAAC,CAAA,GAAAH,CAAA,IAAAA,CAAA,CAAAJ,SAAA,YAAAQ,SAAA,GAAAJ,CAAA,GAAAI,SAAA,EAAAC,CAAA,GAAAC,MAAA,CAAAC,MAAA,CAAAJ,CAAA,CAAAP,SAAA,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["import buildDebug from 'debug';\nimport type { SignOptions, VerifyOptions } from 'jsonwebtoken';\nimport jwt from 'jsonwebtoken';\n\nimport type { RemoteUser } from '@verdaccio/types';\n\nexport type SignOptionsSignature = SignOptions;\nexport type VerifyOptionsSignature = VerifyOptions;\n\nconst debug = buildDebug('verdaccio:auth:token:jwt');\n/**\n * Sign the payload and return JWT\n * https://github.com/auth0/node-jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback\n * @param payload\n * @param secretOrPrivateKey\n * @param options\n */\nexport async function signPayload(\n payload: RemoteUser,\n secretOrPrivateKey: string,\n options: SignOptionsSignature = {}\n): Promise<string> {\n return new Promise(function (resolve, reject) {\n debug('sign jwt token');\n jwt.sign(\n payload,\n secretOrPrivateKey, // FIXME: upgrade to the latest library and types\n {\n // 1 === 1ms (one millisecond)\n notBefore: '1ms', // Make sure the time will not rollback :)\n ...options,\n },\n (error, token) => {\n if (error) {\n debug('error on sign jwt token %s', error.message);\n return reject(error);\n }\n debug('signed jwt token successfully');\n return resolve(token as string);\n }\n );\n });\n}\n\nexport function verifyPayload(\n token: string,\n secretOrPrivateKey: string,\n options: VerifyOptionsSignature = {}\n): RemoteUser {\n debug('verifying jwt token');\n return jwt.verify(token, secretOrPrivateKey, options) as RemoteUser;\n}\n"],"mappings":";;;;;;AASA,IAAM,WAAA,GAAA,MAAA,SAAmB,0BAA0B;;;;;;;;AAQnD,eAAsB,YACpB,SACA,oBACA,UAAgC,CAAC,GAChB;CACjB,OAAO,IAAI,QAAQ,SAAU,SAAS,QAAQ;EAC5C,QAAM,gBAAgB;EACtB,aAAA,QAAI,KACF,SACA,oBACA;GAEE,WAAW;GACX,GAAG;EACL,IACC,OAAO,UAAU;GAChB,IAAI,OAAO;IACT,QAAM,8BAA8B,MAAM,OAAO;IACjD,OAAO,OAAO,KAAK;GACrB;GACA,QAAM,+BAA+B;GACrC,OAAO,QAAQ,KAAe;EAChC,CACF;CACF,CAAC;AACH;AAEA,SAAgB,cACd,OACA,oBACA,UAAkC,CAAC,GACvB;CACZ,QAAM,qBAAqB;CAC3B,OAAO,aAAA,QAAI,OAAO,OAAO,oBAAoB,OAAO;AACtD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import buildDebug from "debug";
|
|
2
|
+
import jwt from "jsonwebtoken";
|
|
3
|
+
//#region src/jwt-token.ts
|
|
4
|
+
var debug = buildDebug("verdaccio:auth:token:jwt");
|
|
5
|
+
/**
|
|
6
|
+
* Sign the payload and return JWT
|
|
7
|
+
* https://github.com/auth0/node-jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback
|
|
8
|
+
* @param payload
|
|
9
|
+
* @param secretOrPrivateKey
|
|
10
|
+
* @param options
|
|
11
|
+
*/
|
|
12
|
+
async function signPayload(payload, secretOrPrivateKey, options = {}) {
|
|
13
|
+
return new Promise(function(resolve, reject) {
|
|
14
|
+
debug("sign jwt token");
|
|
15
|
+
jwt.sign(payload, secretOrPrivateKey, {
|
|
16
|
+
notBefore: "1ms",
|
|
17
|
+
...options
|
|
18
|
+
}, (error, token) => {
|
|
19
|
+
if (error) {
|
|
20
|
+
debug("error on sign jwt token %s", error.message);
|
|
21
|
+
return reject(error);
|
|
22
|
+
}
|
|
23
|
+
debug("signed jwt token successfully");
|
|
24
|
+
return resolve(token);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function verifyPayload(token, secretOrPrivateKey, options = {}) {
|
|
29
|
+
debug("verifying jwt token");
|
|
30
|
+
return jwt.verify(token, secretOrPrivateKey, options);
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { signPayload, verifyPayload };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=jwt-token.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-token.mjs","names":[],"sources":["../src/jwt-token.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { SignOptions, VerifyOptions } from 'jsonwebtoken';\nimport jwt from 'jsonwebtoken';\n\nimport type { RemoteUser } from '@verdaccio/types';\n\nexport type SignOptionsSignature = SignOptions;\nexport type VerifyOptionsSignature = VerifyOptions;\n\nconst debug = buildDebug('verdaccio:auth:token:jwt');\n/**\n * Sign the payload and return JWT\n * https://github.com/auth0/node-jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback\n * @param payload\n * @param secretOrPrivateKey\n * @param options\n */\nexport async function signPayload(\n payload: RemoteUser,\n secretOrPrivateKey: string,\n options: SignOptionsSignature = {}\n): Promise<string> {\n return new Promise(function (resolve, reject) {\n debug('sign jwt token');\n jwt.sign(\n payload,\n secretOrPrivateKey, // FIXME: upgrade to the latest library and types\n {\n // 1 === 1ms (one millisecond)\n notBefore: '1ms', // Make sure the time will not rollback :)\n ...options,\n },\n (error, token) => {\n if (error) {\n debug('error on sign jwt token %s', error.message);\n return reject(error);\n }\n debug('signed jwt token successfully');\n return resolve(token as string);\n }\n );\n });\n}\n\nexport function verifyPayload(\n token: string,\n secretOrPrivateKey: string,\n options: VerifyOptionsSignature = {}\n): RemoteUser {\n debug('verifying jwt token');\n return jwt.verify(token, secretOrPrivateKey, options) as RemoteUser;\n}\n"],"mappings":";;;AASA,IAAM,QAAQ,WAAW,0BAA0B;;;;;;;;AAQnD,eAAsB,YACpB,SACA,oBACA,UAAgC,CAAC,GAChB;CACjB,OAAO,IAAI,QAAQ,SAAU,SAAS,QAAQ;EAC5C,MAAM,gBAAgB;EACtB,IAAI,KACF,SACA,oBACA;GAEE,WAAW;GACX,GAAG;EACL,IACC,OAAO,UAAU;GAChB,IAAI,OAAO;IACT,MAAM,8BAA8B,MAAM,OAAO;IACjD,OAAO,OAAO,KAAK;GACrB;GACA,MAAM,+BAA+B;GACrC,OAAO,QAAQ,KAAe;EAChC,CACF;CACF,CAAC;AACH;AAEA,SAAgB,cACd,OACA,oBACA,UAAkC,CAAC,GACvB;CACZ,MAAM,qBAAqB;CAC3B,OAAO,IAAI,OAAO,OAAO,oBAAoB,OAAO;AACtD"}
|
package/build/signature.js
CHANGED
|
@@ -1,68 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var _config = require("@verdaccio/config");
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
-
var debug = (0, _debug["default"])('verdaccio:auth:token:legacy');
|
|
14
|
-
var defaultAlgorithm = exports.defaultAlgorithm = process.env.VERDACCIO_LEGACY_ALGORITHM || 'aes-256-ctr';
|
|
15
|
-
var inputEncoding = 'utf8';
|
|
16
|
-
var outputEncoding = 'hex';
|
|
17
|
-
// Must be 256 bits (32 characters)
|
|
18
|
-
// https://stackoverflow.com/questions/50963160/invalid-key-length-in-crypto-createcipheriv#50963356
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
let debug = require("debug");
|
|
3
|
+
debug = require_runtime.__toESM(debug);
|
|
4
|
+
let node_crypto = require("node:crypto");
|
|
5
|
+
let _verdaccio_config = require("@verdaccio/config");
|
|
6
|
+
//#region src/signature.ts
|
|
7
|
+
var debug$1 = (0, debug.default)("verdaccio:auth:token:legacy");
|
|
8
|
+
var defaultAlgorithm = process.env.VERDACCIO_LEGACY_ALGORITHM || "aes-256-ctr";
|
|
9
|
+
var inputEncoding = "utf8";
|
|
10
|
+
var outputEncoding = "hex";
|
|
19
11
|
var VERDACCIO_LEGACY_ENCRYPTION_KEY = process.env.VERDACCIO_LEGACY_ENCRYPTION_KEY;
|
|
20
12
|
function aesEncrypt(value, key) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
var cipher = (0, _nodeCrypto.createCipheriv)(defaultAlgorithm, secretKey, iv);
|
|
38
|
-
var encrypted = cipher.update(value, inputEncoding, outputEncoding);
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
encrypted += cipher["final"](outputEncoding);
|
|
41
|
-
var token = "".concat(iv.toString('hex'), ":").concat(encrypted.toString());
|
|
42
|
-
debug('legacy token generated successfully');
|
|
43
|
-
return Buffer.from(token).toString('base64');
|
|
13
|
+
debug$1("aesEncrypt init");
|
|
14
|
+
debug$1("algorithm %o", defaultAlgorithm);
|
|
15
|
+
const iv = (0, node_crypto.randomBytes)(16);
|
|
16
|
+
const secretKey = VERDACCIO_LEGACY_ENCRYPTION_KEY || key;
|
|
17
|
+
const isKeyValid = secretKey?.length === _verdaccio_config.TOKEN_VALID_LENGTH;
|
|
18
|
+
if (isKeyValid === false) throw new Error("Invalid secret key length");
|
|
19
|
+
debug$1("length secret key %o", secretKey?.length);
|
|
20
|
+
debug$1("is valid secret %o", isKeyValid);
|
|
21
|
+
if (!value || !secretKey || !isKeyValid) return;
|
|
22
|
+
const cipher = (0, node_crypto.createCipheriv)(defaultAlgorithm, secretKey, iv);
|
|
23
|
+
let encrypted = cipher.update(value, inputEncoding, outputEncoding);
|
|
24
|
+
encrypted += cipher.final(outputEncoding);
|
|
25
|
+
const token = `${iv.toString("hex")}:${encrypted.toString()}`;
|
|
26
|
+
debug$1("legacy token generated successfully");
|
|
27
|
+
return Buffer.from(token).toString("base64");
|
|
44
28
|
}
|
|
45
29
|
function aesDecrypt(value, key) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// FIXME: fix type here should allow Buffer
|
|
60
|
-
var decrypted = decipher.update(encryptedText, outputEncoding, inputEncoding);
|
|
61
|
-
decrypted += decipher["final"](inputEncoding);
|
|
62
|
-
debug('legacy token payload decrypted successfully');
|
|
63
|
-
return decrypted.toString();
|
|
64
|
-
} catch (_unused) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
30
|
+
try {
|
|
31
|
+
debug$1("aesDecrypt init");
|
|
32
|
+
const textParts = Buffer.from(value, "base64").toString().split(":");
|
|
33
|
+
const IV = Buffer.from(textParts.shift(), outputEncoding);
|
|
34
|
+
const encryptedText = Buffer.from(textParts.join(":"), outputEncoding);
|
|
35
|
+
const decipher = (0, node_crypto.createDecipheriv)(defaultAlgorithm, VERDACCIO_LEGACY_ENCRYPTION_KEY || key, IV);
|
|
36
|
+
let decrypted = decipher.update(encryptedText, outputEncoding, inputEncoding);
|
|
37
|
+
decrypted += decipher.final(inputEncoding);
|
|
38
|
+
debug$1("legacy token payload decrypted successfully");
|
|
39
|
+
return decrypted.toString();
|
|
40
|
+
} catch {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
67
43
|
}
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.aesDecrypt = aesDecrypt;
|
|
46
|
+
exports.aesEncrypt = aesEncrypt;
|
|
47
|
+
|
|
68
48
|
//# sourceMappingURL=signature.js.map
|
package/build/signature.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.js","names":[
|
|
1
|
+
{"version":3,"file":"signature.js","names":[],"sources":["../src/signature.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { BinaryToTextEncoding, CharacterEncoding } from 'node:crypto';\nimport { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto';\n\nimport { TOKEN_VALID_LENGTH } from '@verdaccio/config';\n\nconst debug = buildDebug('verdaccio:auth:token:legacy');\n\nexport const defaultAlgorithm = process.env.VERDACCIO_LEGACY_ALGORITHM || 'aes-256-ctr';\nconst inputEncoding: CharacterEncoding = 'utf8';\nconst outputEncoding: BinaryToTextEncoding = 'hex';\n// Must be 256 bits (32 characters)\n// https://stackoverflow.com/questions/50963160/invalid-key-length-in-crypto-createcipheriv#50963356\nconst VERDACCIO_LEGACY_ENCRYPTION_KEY = process.env.VERDACCIO_LEGACY_ENCRYPTION_KEY;\n\nexport function aesEncrypt(value: string, key: string): string | void {\n debug('aesEncrypt init');\n // https://nodejs.org/api/crypto.html#crypto_crypto_createcipher_algorithm_password_options\n // https://www.grainger.xyz/posts/changing-from-cipher-to-cipheriv\n debug('algorithm %o', defaultAlgorithm);\n // IV must be a buffer of length 16\n const iv = randomBytes(16);\n const secretKey = VERDACCIO_LEGACY_ENCRYPTION_KEY || key;\n\n const isKeyValid = secretKey?.length === TOKEN_VALID_LENGTH;\n if (isKeyValid === false) {\n throw new Error('Invalid secret key length');\n }\n debug('length secret key %o', secretKey?.length);\n debug('is valid secret %o', isKeyValid);\n if (!value || !secretKey || !isKeyValid) {\n return;\n }\n\n const cipher = createCipheriv(defaultAlgorithm, secretKey, iv);\n let encrypted = cipher.update(value, inputEncoding, outputEncoding);\n // @ts-ignore\n encrypted += cipher.final(outputEncoding);\n const token = `${iv.toString('hex')}:${encrypted.toString()}`;\n debug('legacy token generated successfully');\n return Buffer.from(token).toString('base64');\n}\n\nexport function aesDecrypt(value: string, key: string): string | void {\n try {\n debug('aesDecrypt init');\n const buff = Buffer.from(value, 'base64');\n const textParts = buff.toString().split(':');\n\n // extract the IV from the first half of the value\n // @ts-ignore\n const IV = Buffer.from(textParts.shift(), outputEncoding);\n // extract the encrypted text without the IV\n const encryptedText = Buffer.from(textParts.join(':'), outputEncoding);\n const secretKey = VERDACCIO_LEGACY_ENCRYPTION_KEY || key;\n // decipher the string\n const decipher = createDecipheriv(defaultAlgorithm, secretKey, IV);\n // FIXME: fix type here should allow Buffer\n let decrypted = decipher.update(encryptedText as any, outputEncoding, inputEncoding);\n decrypted += decipher.final(inputEncoding);\n debug('legacy token payload decrypted successfully');\n return decrypted.toString();\n } catch {\n return;\n }\n}\n"],"mappings":";;;;;;AAMA,IAAM,WAAA,GAAA,MAAA,SAA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;EACN;CACF;AACF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import buildDebug from "debug";
|
|
2
|
+
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
3
|
+
import { TOKEN_VALID_LENGTH } from "@verdaccio/config";
|
|
4
|
+
//#region src/signature.ts
|
|
5
|
+
var debug = buildDebug("verdaccio:auth:token:legacy");
|
|
6
|
+
var defaultAlgorithm = process.env.VERDACCIO_LEGACY_ALGORITHM || "aes-256-ctr";
|
|
7
|
+
var inputEncoding = "utf8";
|
|
8
|
+
var outputEncoding = "hex";
|
|
9
|
+
var VERDACCIO_LEGACY_ENCRYPTION_KEY = process.env.VERDACCIO_LEGACY_ENCRYPTION_KEY;
|
|
10
|
+
function aesEncrypt(value, key) {
|
|
11
|
+
debug("aesEncrypt init");
|
|
12
|
+
debug("algorithm %o", defaultAlgorithm);
|
|
13
|
+
const iv = randomBytes(16);
|
|
14
|
+
const secretKey = VERDACCIO_LEGACY_ENCRYPTION_KEY || key;
|
|
15
|
+
const isKeyValid = secretKey?.length === TOKEN_VALID_LENGTH;
|
|
16
|
+
if (isKeyValid === false) throw new Error("Invalid secret key length");
|
|
17
|
+
debug("length secret key %o", secretKey?.length);
|
|
18
|
+
debug("is valid secret %o", isKeyValid);
|
|
19
|
+
if (!value || !secretKey || !isKeyValid) return;
|
|
20
|
+
const cipher = createCipheriv(defaultAlgorithm, secretKey, iv);
|
|
21
|
+
let encrypted = cipher.update(value, inputEncoding, outputEncoding);
|
|
22
|
+
encrypted += cipher.final(outputEncoding);
|
|
23
|
+
const token = `${iv.toString("hex")}:${encrypted.toString()}`;
|
|
24
|
+
debug("legacy token generated successfully");
|
|
25
|
+
return Buffer.from(token).toString("base64");
|
|
26
|
+
}
|
|
27
|
+
function aesDecrypt(value, key) {
|
|
28
|
+
try {
|
|
29
|
+
debug("aesDecrypt init");
|
|
30
|
+
const textParts = Buffer.from(value, "base64").toString().split(":");
|
|
31
|
+
const IV = Buffer.from(textParts.shift(), outputEncoding);
|
|
32
|
+
const encryptedText = Buffer.from(textParts.join(":"), outputEncoding);
|
|
33
|
+
const decipher = createDecipheriv(defaultAlgorithm, VERDACCIO_LEGACY_ENCRYPTION_KEY || key, IV);
|
|
34
|
+
let decrypted = decipher.update(encryptedText, outputEncoding, inputEncoding);
|
|
35
|
+
decrypted += decipher.final(inputEncoding);
|
|
36
|
+
debug("legacy token payload decrypted successfully");
|
|
37
|
+
return decrypted.toString();
|
|
38
|
+
} catch {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { aesDecrypt, aesEncrypt };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=signature.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.mjs","names":[],"sources":["../src/signature.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport type { BinaryToTextEncoding, CharacterEncoding } from 'node:crypto';\nimport { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto';\n\nimport { TOKEN_VALID_LENGTH } from '@verdaccio/config';\n\nconst debug = buildDebug('verdaccio:auth:token:legacy');\n\nexport const defaultAlgorithm = process.env.VERDACCIO_LEGACY_ALGORITHM || 'aes-256-ctr';\nconst inputEncoding: CharacterEncoding = 'utf8';\nconst outputEncoding: BinaryToTextEncoding = 'hex';\n// Must be 256 bits (32 characters)\n// https://stackoverflow.com/questions/50963160/invalid-key-length-in-crypto-createcipheriv#50963356\nconst VERDACCIO_LEGACY_ENCRYPTION_KEY = process.env.VERDACCIO_LEGACY_ENCRYPTION_KEY;\n\nexport function aesEncrypt(value: string, key: string): string | void {\n debug('aesEncrypt init');\n // https://nodejs.org/api/crypto.html#crypto_crypto_createcipher_algorithm_password_options\n // https://www.grainger.xyz/posts/changing-from-cipher-to-cipheriv\n debug('algorithm %o', defaultAlgorithm);\n // IV must be a buffer of length 16\n const iv = randomBytes(16);\n const secretKey = VERDACCIO_LEGACY_ENCRYPTION_KEY || key;\n\n const isKeyValid = secretKey?.length === TOKEN_VALID_LENGTH;\n if (isKeyValid === false) {\n throw new Error('Invalid secret key length');\n }\n debug('length secret key %o', secretKey?.length);\n debug('is valid secret %o', isKeyValid);\n if (!value || !secretKey || !isKeyValid) {\n return;\n }\n\n const cipher = createCipheriv(defaultAlgorithm, secretKey, iv);\n let encrypted = cipher.update(value, inputEncoding, outputEncoding);\n // @ts-ignore\n encrypted += cipher.final(outputEncoding);\n const token = `${iv.toString('hex')}:${encrypted.toString()}`;\n debug('legacy token generated successfully');\n return Buffer.from(token).toString('base64');\n}\n\nexport function aesDecrypt(value: string, key: string): string | void {\n try {\n debug('aesDecrypt init');\n const buff = Buffer.from(value, 'base64');\n const textParts = buff.toString().split(':');\n\n // extract the IV from the first half of the value\n // @ts-ignore\n const IV = Buffer.from(textParts.shift(), outputEncoding);\n // extract the encrypted text without the IV\n const encryptedText = Buffer.from(textParts.join(':'), outputEncoding);\n const secretKey = VERDACCIO_LEGACY_ENCRYPTION_KEY || key;\n // decipher the string\n const decipher = createDecipheriv(defaultAlgorithm, secretKey, IV);\n // FIXME: fix type here should allow Buffer\n let decrypted = decipher.update(encryptedText as any, outputEncoding, inputEncoding);\n decrypted += decipher.final(inputEncoding);\n debug('legacy token payload decrypted successfully');\n return decrypted.toString();\n } catch {\n return;\n }\n}\n"],"mappings":";;;;AAMA,IAAM,QAAQ,WAAW,6BAA6B;AAEtD,IAAa,mBAAmB,QAAQ,IAAI,8BAA8B;AAC1E,IAAM,gBAAmC;AACzC,IAAM,iBAAuC;AAG7C,IAAM,kCAAkC,QAAQ,IAAI;AAEpD,SAAgB,WAAW,OAAe,KAA4B;CACpE,MAAM,iBAAiB;CAGvB,MAAM,gBAAgB,gBAAgB;CAEtC,MAAM,KAAK,YAAY,EAAE;CACzB,MAAM,YAAY,mCAAmC;CAErD,MAAM,aAAa,WAAW,WAAW;CACzC,IAAI,eAAe,OACjB,MAAM,IAAI,MAAM,2BAA2B;CAE7C,MAAM,wBAAwB,WAAW,MAAM;CAC/C,MAAM,sBAAsB,UAAU;CACtC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,YAC3B;CAGF,MAAM,SAAS,eAAe,kBAAkB,WAAW,EAAE;CAC7D,IAAI,YAAY,OAAO,OAAO,OAAO,eAAe,cAAc;CAElE,aAAa,OAAO,MAAM,cAAc;CACxC,MAAM,QAAQ,GAAG,GAAG,SAAS,KAAK,EAAE,GAAG,UAAU,SAAS;CAC1D,MAAM,qCAAqC;CAC3C,OAAO,OAAO,KAAK,KAAK,EAAE,SAAS,QAAQ;AAC7C;AAEA,SAAgB,WAAW,OAAe,KAA4B;CACpE,IAAI;EACF,MAAM,iBAAiB;EAEvB,MAAM,YADO,OAAO,KAAK,OAAO,QACd,EAAK,SAAS,EAAE,MAAM,GAAG;EAI3C,MAAM,KAAK,OAAO,KAAK,UAAU,MAAM,GAAG,cAAc;EAExD,MAAM,gBAAgB,OAAO,KAAK,UAAU,KAAK,GAAG,GAAG,cAAc;EAGrE,MAAM,WAAW,iBAAiB,kBAFhB,mCAAmC,KAEU,EAAE;EAEjE,IAAI,YAAY,SAAS,OAAO,eAAsB,gBAAgB,aAAa;EACnF,aAAa,SAAS,MAAM,aAAa;EACzC,MAAM,6CAA6C;EACnD,OAAO,UAAU,SAAS;CAC5B,QAAQ;EACN;CACF;AACF"}
|
package/build/token.js
CHANGED
|
@@ -1,38 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.parseBasicPayload = parseBasicPayload;
|
|
1
|
+
//#region src/token.ts
|
|
7
2
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
*
|
|
4
|
+
* @param credentials
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
12
7
|
function parseBasicPayload(credentials) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var index = credentials.indexOf(':');
|
|
28
|
-
if (index < 0) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
var user = credentials.slice(0, index);
|
|
32
|
-
var password = credentials.slice(index + 1);
|
|
33
|
-
return {
|
|
34
|
-
user: user,
|
|
35
|
-
password: password
|
|
36
|
-
};
|
|
8
|
+
if (credentials.startsWith("{")) try {
|
|
9
|
+
const parsed = JSON.parse(credentials);
|
|
10
|
+
if (typeof parsed.user === "string" && typeof parsed.password === "string") return {
|
|
11
|
+
user: parsed.user,
|
|
12
|
+
password: parsed.password,
|
|
13
|
+
tokenKey: typeof parsed.tokenKey === "string" ? parsed.tokenKey : void 0
|
|
14
|
+
};
|
|
15
|
+
} catch {}
|
|
16
|
+
const index = credentials.indexOf(":");
|
|
17
|
+
if (index < 0) return;
|
|
18
|
+
return {
|
|
19
|
+
user: credentials.slice(0, index),
|
|
20
|
+
password: credentials.slice(index + 1)
|
|
21
|
+
};
|
|
37
22
|
}
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.parseBasicPayload = parseBasicPayload;
|
|
25
|
+
|
|
38
26
|
//# sourceMappingURL=token.js.map
|
package/build/token.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","names":[
|
|
1
|
+
{"version":3,"file":"token.js","names":[],"sources":["../src/token.ts"],"sourcesContent":["import type { BasicPayload } from './types';\n\n/**\n *\n * @param credentials\n * @returns\n */\nexport function parseBasicPayload(credentials: string): BasicPayload {\n if (credentials.startsWith('{')) {\n try {\n const parsed = JSON.parse(credentials);\n\n if (typeof parsed.user === 'string' && typeof parsed.password === 'string') {\n return {\n user: parsed.user,\n password: parsed.password,\n tokenKey: typeof parsed.tokenKey === 'string' ? parsed.tokenKey : undefined,\n };\n }\n } catch {\n // not a JSON payload, fall through to the legacy \"user:password\" parsing\n }\n }\n\n const index = credentials.indexOf(':');\n if (index < 0) {\n return;\n }\n\n const user: string = credentials.slice(0, index);\n const password: string = credentials.slice(index + 1);\n\n return { user, password };\n}\n"],"mappings":";;;;;;AAOA,SAAgB,kBAAkB,aAAmC;CACnE,IAAI,YAAY,WAAW,GAAG,GAC5B,IAAI;EACF,MAAM,SAAS,KAAK,MAAM,WAAW;EAErC,IAAI,OAAO,OAAO,SAAS,YAAY,OAAO,OAAO,aAAa,UAChE,OAAO;GACL,MAAM,OAAO;GACb,UAAU,OAAO;GACjB,UAAU,OAAO,OAAO,aAAa,WAAW,OAAO,WAAW,KAAA;EACpE;CAEJ,QAAQ,CAER;CAGF,MAAM,QAAQ,YAAY,QAAQ,GAAG;CACrC,IAAI,QAAQ,GACV;CAMF,OAAO;EAAE,MAHY,YAAY,MAAM,GAAG,KAGjC;EAAM,UAFU,YAAY,MAAM,QAAQ,CAEpC;CAAS;AAC1B"}
|
package/build/token.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/token.ts
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param credentials
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
function parseBasicPayload(credentials) {
|
|
8
|
+
if (credentials.startsWith("{")) try {
|
|
9
|
+
const parsed = JSON.parse(credentials);
|
|
10
|
+
if (typeof parsed.user === "string" && typeof parsed.password === "string") return {
|
|
11
|
+
user: parsed.user,
|
|
12
|
+
password: parsed.password,
|
|
13
|
+
tokenKey: typeof parsed.tokenKey === "string" ? parsed.tokenKey : void 0
|
|
14
|
+
};
|
|
15
|
+
} catch {}
|
|
16
|
+
const index = credentials.indexOf(":");
|
|
17
|
+
if (index < 0) return;
|
|
18
|
+
return {
|
|
19
|
+
user: credentials.slice(0, index),
|
|
20
|
+
password: credentials.slice(index + 1)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { parseBasicPayload };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=token.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.mjs","names":[],"sources":["../src/token.ts"],"sourcesContent":["import type { BasicPayload } from './types';\n\n/**\n *\n * @param credentials\n * @returns\n */\nexport function parseBasicPayload(credentials: string): BasicPayload {\n if (credentials.startsWith('{')) {\n try {\n const parsed = JSON.parse(credentials);\n\n if (typeof parsed.user === 'string' && typeof parsed.password === 'string') {\n return {\n user: parsed.user,\n password: parsed.password,\n tokenKey: typeof parsed.tokenKey === 'string' ? parsed.tokenKey : undefined,\n };\n }\n } catch {\n // not a JSON payload, fall through to the legacy \"user:password\" parsing\n }\n }\n\n const index = credentials.indexOf(':');\n if (index < 0) {\n return;\n }\n\n const user: string = credentials.slice(0, index);\n const password: string = credentials.slice(index + 1);\n\n return { user, password };\n}\n"],"mappings":";;;;;;AAOA,SAAgB,kBAAkB,aAAmC;CACnE,IAAI,YAAY,WAAW,GAAG,GAC5B,IAAI;EACF,MAAM,SAAS,KAAK,MAAM,WAAW;EAErC,IAAI,OAAO,OAAO,SAAS,YAAY,OAAO,OAAO,aAAa,UAChE,OAAO;GACL,MAAM,OAAO;GACb,UAAU,OAAO;GACjB,UAAU,OAAO,OAAO,aAAa,WAAW,OAAO,WAAW,KAAA;EACpE;CAEJ,QAAQ,CAER;CAGF,MAAM,QAAQ,YAAY,QAAQ,GAAG;CACrC,IAAI,QAAQ,GACV;CAMF,OAAO;EAAE,MAHY,YAAY,MAAM,GAAG,KAGjC;EAAM,UAFU,YAAY,MAAM,QAAQ,CAEpC;CAAS;AAC1B"}
|
package/build/types.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//#region src/types.ts
|
|
2
|
+
var types_exports = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.js").__exportAll({});
|
|
3
|
+
//#endregion
|
|
4
|
+
Object.defineProperty(exports, "types_exports", {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function() {
|
|
7
|
+
return types_exports;
|
|
8
|
+
}
|
|
5
9
|
});
|
|
10
|
+
|
|
6
11
|
//# sourceMappingURL=types.js.map
|
package/build/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["export interface AESPayload {\n user: string;\n password: string;\n tokenKey?: string;\n}\n\nexport type BasicPayload = AESPayload | void;\n"],"mappings":""
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["export interface AESPayload {\n user: string;\n password: string;\n tokenKey?: string;\n}\n\nexport type BasicPayload = AESPayload | void;\n"],"mappings":""}
|
package/build/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["export interface AESPayload {\n user: string;\n password: string;\n tokenKey?: string;\n}\n\nexport type BasicPayload = AESPayload | void;\n"],"mappings":""}
|
package/build/utils.js
CHANGED
|
@@ -1,32 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
let _verdaccio_config = require("@verdaccio/config");
|
|
3
|
+
let _verdaccio_core = require("@verdaccio/core");
|
|
4
|
+
//#region src/utils.ts
|
|
5
|
+
var utils_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
6
|
+
TOKEN_VALID_LENGTH: () => _verdaccio_config.TOKEN_VALID_LENGTH,
|
|
7
|
+
createTarballHash: () => createTarballHash,
|
|
8
|
+
defaultTarballHashAlgorithm: () => defaultTarballHashAlgorithm,
|
|
9
|
+
generateRandomHexString: () => generateRandomHexString,
|
|
10
|
+
generateRandomSecretKey: () => _verdaccio_config.generateRandomSecretKey,
|
|
11
|
+
stringToMD5: () => stringToMD5
|
|
11
12
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
var defaultTarballHashAlgorithm = _verdaccio_core.cryptoUtils.defaultTarballHashAlgorithm;
|
|
14
|
+
var stringToMD5 = _verdaccio_core.cryptoUtils.stringToMD5;
|
|
15
|
+
var createTarballHash = _verdaccio_core.cryptoUtils.createTarballHash;
|
|
16
|
+
var generateRandomHexString = _verdaccio_core.cryptoUtils.generateRandomHexString;
|
|
17
|
+
//#endregion
|
|
18
|
+
Object.defineProperty(exports, "utils_exports", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function() {
|
|
21
|
+
return utils_exports;
|
|
22
|
+
}
|
|
18
23
|
});
|
|
19
|
-
exports.stringToMD5 = void 0;
|
|
20
|
-
var _config = require("@verdaccio/config");
|
|
21
|
-
var _core = require("@verdaccio/core");
|
|
22
|
-
// @deprecated use @verdaccio/core.cryptoUtils instead
|
|
23
|
-
var defaultTarballHashAlgorithm = exports.defaultTarballHashAlgorithm = _core.cryptoUtils.defaultTarballHashAlgorithm;
|
|
24
|
-
// @deprecated use @verdaccio/core.cryptoUtils instead
|
|
25
|
-
var stringToMD5 = exports.stringToMD5 = _core.cryptoUtils.stringToMD5;
|
|
26
|
-
// @deprecated use @verdaccio/core.cryptoUtils instead
|
|
27
|
-
var createTarballHash = exports.createTarballHash = _core.cryptoUtils.createTarballHash;
|
|
28
|
-
// @deprecated use @verdaccio/core.cryptoUtils instead
|
|
29
|
-
var generateRandomHexString = exports.generateRandomHexString = _core.cryptoUtils.generateRandomHexString;
|
|
30
24
|
|
|
31
|
-
// @deprecated use @verdaccio/config instead
|
|
32
25
|
//# sourceMappingURL=utils.js.map
|
package/build/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { TOKEN_VALID_LENGTH, generateRandomSecretKey } from '@verdaccio/config';\nimport { cryptoUtils } from '@verdaccio/core';\n\n// @deprecated use @verdaccio/core.cryptoUtils instead\nexport const defaultTarballHashAlgorithm = cryptoUtils.defaultTarballHashAlgorithm;\n// @deprecated use @verdaccio/core.cryptoUtils instead\nexport const stringToMD5 = cryptoUtils.stringToMD5;\n// @deprecated use @verdaccio/core.cryptoUtils instead\nexport const createTarballHash = cryptoUtils.createTarballHash;\n// @deprecated use @verdaccio/core.cryptoUtils instead\nexport const generateRandomHexString = cryptoUtils.generateRandomHexString;\n\n// @deprecated use @verdaccio/config instead\nexport { TOKEN_VALID_LENGTH, generateRandomSecretKey };\n"],"mappings":";;;;;;;;;;;;AAIA,IAAa,8BAA8B,gBAAA,YAAY;AAEvD,IAAa,cAAc,gBAAA,YAAY;AAEvC,IAAa,oBAAoB,gBAAA,YAAY;AAE7C,IAAa,0BAA0B,gBAAA,YAAY"}
|
package/build/utils.mjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { TOKEN_VALID_LENGTH as TOKEN_VALID_LENGTH$1, generateRandomSecretKey } from "@verdaccio/config";
|
|
3
|
+
import { cryptoUtils } from "@verdaccio/core";
|
|
4
|
+
//#region src/utils.ts
|
|
5
|
+
var utils_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
TOKEN_VALID_LENGTH: () => TOKEN_VALID_LENGTH$1,
|
|
7
|
+
createTarballHash: () => createTarballHash,
|
|
8
|
+
defaultTarballHashAlgorithm: () => defaultTarballHashAlgorithm,
|
|
9
|
+
generateRandomHexString: () => generateRandomHexString,
|
|
10
|
+
generateRandomSecretKey: () => generateRandomSecretKey,
|
|
11
|
+
stringToMD5: () => stringToMD5
|
|
12
|
+
});
|
|
13
|
+
var defaultTarballHashAlgorithm = cryptoUtils.defaultTarballHashAlgorithm;
|
|
14
|
+
var stringToMD5 = cryptoUtils.stringToMD5;
|
|
15
|
+
var createTarballHash = cryptoUtils.createTarballHash;
|
|
16
|
+
var generateRandomHexString = cryptoUtils.generateRandomHexString;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { utils_exports };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { TOKEN_VALID_LENGTH, generateRandomSecretKey } from '@verdaccio/config';\nimport { cryptoUtils } from '@verdaccio/core';\n\n// @deprecated use @verdaccio/core.cryptoUtils instead\nexport const defaultTarballHashAlgorithm = cryptoUtils.defaultTarballHashAlgorithm;\n// @deprecated use @verdaccio/core.cryptoUtils instead\nexport const stringToMD5 = cryptoUtils.stringToMD5;\n// @deprecated use @verdaccio/core.cryptoUtils instead\nexport const createTarballHash = cryptoUtils.createTarballHash;\n// @deprecated use @verdaccio/core.cryptoUtils instead\nexport const generateRandomHexString = cryptoUtils.generateRandomHexString;\n\n// @deprecated use @verdaccio/config instead\nexport { TOKEN_VALID_LENGTH, generateRandomSecretKey };\n"],"mappings":";;;;;;;;;;;;AAIA,IAAa,8BAA8B,YAAY;AAEvD,IAAa,cAAc,YAAY;AAEvC,IAAa,oBAAoB,YAAY;AAE7C,IAAa,0BAA0B,YAAY"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/signature",
|
|
3
|
-
"version": "8.0
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "Verdaccio Signature Utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"enterprise",
|
|
@@ -32,27 +32,40 @@
|
|
|
32
32
|
"url": "https://opencollective.com/verdaccio"
|
|
33
33
|
},
|
|
34
34
|
"main": "./build/index.js",
|
|
35
|
-
"
|
|
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/config": "8.
|
|
38
|
-
"@verdaccio/core": "8.
|
|
51
|
+
"@verdaccio/config": "8.2.0",
|
|
52
|
+
"@verdaccio/core": "8.2.0",
|
|
39
53
|
"debug": "4.4.3",
|
|
40
54
|
"jsonwebtoken": "9.0.3"
|
|
41
55
|
},
|
|
42
56
|
"devDependencies": {
|
|
43
|
-
"@verdaccio/types": "13.0.
|
|
57
|
+
"@verdaccio/types": "13.0.5",
|
|
58
|
+
"vite": "8.0.16",
|
|
44
59
|
"vitest": "4.1.2"
|
|
45
60
|
},
|
|
46
61
|
"engines": {
|
|
47
|
-
"node": ">=
|
|
62
|
+
"node": ">=22"
|
|
48
63
|
},
|
|
49
64
|
"scripts": {
|
|
50
65
|
"clean": "rimraf ./build",
|
|
51
66
|
"test": "vitest run",
|
|
52
67
|
"type-check": "tsc --noEmit -p tsconfig.build.json",
|
|
53
|
-
"
|
|
54
|
-
"build
|
|
55
|
-
"watch": "pnpm build:js -- --watch",
|
|
56
|
-
"build": "pnpm run build:js && pnpm run build:types"
|
|
68
|
+
"watch": "vite build --watch",
|
|
69
|
+
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.build.json"
|
|
57
70
|
}
|
|
58
71
|
}
|
package/build/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_legacySignature","require","_signature","_jwtToken","_utils","_interopRequireWildcard","exports","utils","_types","types","_token","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor"],"sources":["../src/index.ts"],"sourcesContent":["export {\n aesDecryptDeprecated,\n aesEncryptDeprecated,\n generateRandomSecretKeyDeprecated,\n} from './legacy-signature';\n\nexport { aesDecrypt, aesEncrypt } from './signature';\nexport {\n signPayload,\n verifyPayload,\n SignOptionsSignature,\n VerifyOptionsSignature,\n} from './jwt-token';\nexport * as utils from './utils';\nexport * as types from './types';\nexport { parseBasicPayload } from './token';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAMA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAKqB,IAAAG,MAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAAAK,OAAA,CAAAC,KAAA,GAAAH,MAAA;AAAA,IAAAI,MAAA,GAAAH,uBAAA,CAAAJ,OAAA;AAAAK,OAAA,CAAAG,KAAA,GAAAD,MAAA;AAGrB,IAAAE,MAAA,GAAAT,OAAA;AAA4C,SAAAI,wBAAAM,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAR,uBAAA,YAAAA,wBAAAM,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,mBAAAT,CAAA,iBAAAA,CAAA,gBAAAU,OAAA,CAAAV,CAAA,0BAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,cAAAM,EAAA,IAAAd,CAAA,gBAAAc,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,EAAA,OAAAP,CAAA,IAAAD,CAAA,GAAAW,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAnB,CAAA,EAAAc,EAAA,OAAAP,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAM,EAAA,EAAAP,CAAA,IAAAC,CAAA,CAAAM,EAAA,IAAAd,CAAA,CAAAc,EAAA,WAAAN,CAAA,KAAAR,CAAA,EAAAC,CAAA","ignoreList":[]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
export declare const defaultAlgorithm = "aes192";
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param buf
|
|
6
|
-
* @param secret
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
|
-
export declare function aesEncryptDeprecated(buf: Buffer, secret: string): Buffer;
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @param buf
|
|
13
|
-
* @param secret
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
export declare function aesDecryptDeprecated(buf: Buffer, secret: string): Buffer;
|
|
17
|
-
export declare const TOKEN_VALID_LENGTH_DEPRECATED = 64;
|
|
18
|
-
/**
|
|
19
|
-
* Generate a secret key of 64 characters.
|
|
20
|
-
*/
|
|
21
|
-
export declare function generateRandomSecretKeyDeprecated(): string;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.TOKEN_VALID_LENGTH_DEPRECATED = void 0;
|
|
7
|
-
exports.aesDecryptDeprecated = aesDecryptDeprecated;
|
|
8
|
-
exports.aesEncryptDeprecated = aesEncryptDeprecated;
|
|
9
|
-
exports.defaultAlgorithm = void 0;
|
|
10
|
-
exports.generateRandomSecretKeyDeprecated = generateRandomSecretKeyDeprecated;
|
|
11
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
12
|
-
var _nodeCrypto = require("node:crypto");
|
|
13
|
-
var _core = require("@verdaccio/core");
|
|
14
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
15
|
-
var defaultAlgorithm = exports.defaultAlgorithm = 'aes192';
|
|
16
|
-
var debug = (0, _debug["default"])('verdaccio:auth:token:legacy:deprecated');
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param buf
|
|
21
|
-
* @param secret
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
function aesEncryptDeprecated(buf, secret) {
|
|
25
|
-
debug('aesEncryptDeprecated init');
|
|
26
|
-
debug('algorithm %o', defaultAlgorithm);
|
|
27
|
-
// deprecated (it will be removed in Verdaccio 6), it is a breaking change
|
|
28
|
-
// https://nodejs.org/api/crypto.html#crypto_crypto_createcipher_algorithm_password_options
|
|
29
|
-
// https://www.grainger.xyz/changing-from-cipher-to-cipheriv/
|
|
30
|
-
var c = (0, _nodeCrypto.createCipher)(defaultAlgorithm, secret);
|
|
31
|
-
var b1 = c.update(buf);
|
|
32
|
-
var b2 = c["final"]();
|
|
33
|
-
debug('deprecated legacy token generated successfully');
|
|
34
|
-
return Buffer.concat([b1, b2]);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
* @param buf
|
|
40
|
-
* @param secret
|
|
41
|
-
* @returns
|
|
42
|
-
*/
|
|
43
|
-
function aesDecryptDeprecated(buf, secret) {
|
|
44
|
-
try {
|
|
45
|
-
debug('aesDecryptDeprecated init');
|
|
46
|
-
// https://nodejs.org/api/crypto.html#crypto_crypto_createdecipher_algorithm_password_options
|
|
47
|
-
// https://www.grainger.xyz/changing-from-cipher-to-cipheriv/
|
|
48
|
-
var c = (0, _nodeCrypto.createDecipher)(defaultAlgorithm, secret);
|
|
49
|
-
var b1 = c.update(buf);
|
|
50
|
-
var b2 = c["final"]();
|
|
51
|
-
debug('deprecated legacy token payload decrypted successfully');
|
|
52
|
-
return Buffer.concat([b1, b2]);
|
|
53
|
-
} catch (_unused) {
|
|
54
|
-
return Buffer.alloc(0);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
var TOKEN_VALID_LENGTH_DEPRECATED = exports.TOKEN_VALID_LENGTH_DEPRECATED = 64;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Generate a secret key of 64 characters.
|
|
61
|
-
*/
|
|
62
|
-
function generateRandomSecretKeyDeprecated() {
|
|
63
|
-
return _core.cryptoUtils.generateRandomHexString(6);
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_debug","_interopRequireDefault","require","_nodeCrypto","_core","e","__esModule","defaultAlgorithm","exports","debug","buildDebug","aesEncryptDeprecated","buf","secret","c","createCipher","b1","update","b2","Buffer","concat","aesDecryptDeprecated","createDecipher","_unused","alloc","TOKEN_VALID_LENGTH_DEPRECATED","generateRandomSecretKeyDeprecated","cryptoUtils","generateRandomHexString"],"sources":["../../src/legacy-signature/index.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { createCipher, createDecipher } from 'node:crypto';\n\nimport { cryptoUtils } from '@verdaccio/core';\n\nexport const defaultAlgorithm = 'aes192';\n\nconst debug = buildDebug('verdaccio:auth:token:legacy:deprecated');\n\n/**\n *\n * @param buf\n * @param secret\n * @returns\n */\nexport function aesEncryptDeprecated(buf: Buffer, secret: string): Buffer {\n debug('aesEncryptDeprecated init');\n debug('algorithm %o', defaultAlgorithm);\n // deprecated (it will be removed in Verdaccio 6), it is a breaking change\n // https://nodejs.org/api/crypto.html#crypto_crypto_createcipher_algorithm_password_options\n // https://www.grainger.xyz/changing-from-cipher-to-cipheriv/\n const c = createCipher(defaultAlgorithm, secret);\n const b1 = c.update(buf);\n const b2 = c.final();\n debug('deprecated legacy token generated successfully');\n return Buffer.concat([b1, b2]);\n}\n\n/**\n *\n * @param buf\n * @param secret\n * @returns\n */\nexport function aesDecryptDeprecated(buf: Buffer, secret: string): Buffer {\n try {\n debug('aesDecryptDeprecated init');\n // https://nodejs.org/api/crypto.html#crypto_crypto_createdecipher_algorithm_password_options\n // https://www.grainger.xyz/changing-from-cipher-to-cipheriv/\n const c = createDecipher(defaultAlgorithm, secret);\n const b1 = c.update(buf);\n const b2 = c.final();\n debug('deprecated legacy token payload decrypted successfully');\n return Buffer.concat([b1, b2]);\n } catch {\n return Buffer.alloc(0);\n }\n}\n\nexport const TOKEN_VALID_LENGTH_DEPRECATED = 64;\n\n/**\n * Generate a secret key of 64 characters.\n */\nexport function generateRandomSecretKeyDeprecated(): string {\n return cryptoUtils.generateRandomHexString(6);\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAA8C,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAEvC,IAAME,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,QAAQ;AAExC,IAAME,KAAK,GAAG,IAAAC,iBAAU,EAAC,wCAAwC,CAAC;;AAElE;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,oBAAoBA,CAACC,GAAW,EAAEC,MAAc,EAAU;EACxEJ,KAAK,CAAC,2BAA2B,CAAC;EAClCA,KAAK,CAAC,cAAc,EAAEF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