@verdaccio/config 8.1.2 → 8.2.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.
Files changed (61) hide show
  1. package/build/_virtual/_rolldown/runtime.js +23 -0
  2. package/build/address.js +80 -102
  3. package/build/address.js.map +1 -1
  4. package/build/address.mjs +86 -0
  5. package/build/address.mjs.map +1 -0
  6. package/build/agent.js +11 -16
  7. package/build/agent.js.map +1 -1
  8. package/build/agent.mjs +12 -0
  9. package/build/agent.mjs.map +1 -0
  10. package/build/builder.js +128 -131
  11. package/build/builder.js.map +1 -1
  12. package/build/builder.mjs +129 -0
  13. package/build/builder.mjs.map +1 -0
  14. package/build/conf/index.js +10 -11
  15. package/build/conf/index.js.map +1 -1
  16. package/build/conf/index.mjs +12 -0
  17. package/build/conf/index.mjs.map +1 -0
  18. package/build/config-path.js +154 -163
  19. package/build/config-path.js.map +1 -1
  20. package/build/config-path.mjs +171 -0
  21. package/build/config-path.mjs.map +1 -0
  22. package/build/config-utils.js +37 -41
  23. package/build/config-utils.js.map +1 -1
  24. package/build/config-utils.mjs +40 -0
  25. package/build/config-utils.mjs.map +1 -0
  26. package/build/config.js +154 -203
  27. package/build/config.js.map +1 -1
  28. package/build/config.mjs +153 -0
  29. package/build/config.mjs.map +1 -0
  30. package/build/index.js +52 -167
  31. package/build/index.mjs +14 -0
  32. package/build/package-access.js +52 -68
  33. package/build/package-access.js.map +1 -1
  34. package/build/package-access.mjs +52 -0
  35. package/build/package-access.mjs.map +1 -0
  36. package/build/parse.js +83 -100
  37. package/build/parse.js.map +1 -1
  38. package/build/parse.mjs +85 -0
  39. package/build/parse.mjs.map +1 -0
  40. package/build/security.js +15 -22
  41. package/build/security.js.map +1 -1
  42. package/build/security.mjs +16 -0
  43. package/build/security.mjs.map +1 -0
  44. package/build/serverSettings.js +10 -15
  45. package/build/serverSettings.js.map +1 -1
  46. package/build/serverSettings.mjs +12 -0
  47. package/build/serverSettings.mjs.map +1 -0
  48. package/build/token.js +10 -13
  49. package/build/token.js.map +1 -1
  50. package/build/token.mjs +13 -0
  51. package/build/token.mjs.map +1 -0
  52. package/build/uplinks.js +47 -55
  53. package/build/uplinks.js.map +1 -1
  54. package/build/uplinks.mjs +50 -0
  55. package/build/uplinks.mjs.map +1 -0
  56. package/build/user.js +42 -37
  57. package/build/user.js.map +1 -1
  58. package/build/user.mjs +48 -0
  59. package/build/user.mjs.map +1 -0
  60. package/package.json +43 -30
  61. package/build/index.js.map +0 -1
@@ -0,0 +1,153 @@
1
+ import { getUserAgent } from "./agent.mjs";
2
+ import { normalisePackageAccess } from "./package-access.mjs";
3
+ import { defaultSecurity } from "./security.mjs";
4
+ import serverSettings_default from "./serverSettings.mjs";
5
+ import { generateRandomSecretKey } from "./token.mjs";
6
+ import { sanityCheckUplinksProps, uplinkSanityCheck } from "./uplinks.mjs";
7
+ import buildDebug from "debug";
8
+ import _ from "lodash";
9
+ import assert from "node:assert";
10
+ import { APP_ERROR, authUtils, cryptoUtils, validationUtils } from "@verdaccio/core";
11
+ //#region src/config.ts
12
+ var strategicConfigProps = ["uplinks", "packages"];
13
+ var allowedEnvConfig = [
14
+ "http_proxy",
15
+ "https_proxy",
16
+ "no_proxy"
17
+ ];
18
+ var debug = buildDebug("verdaccio:config");
19
+ var WEB_TITLE = "Verdaccio";
20
+ var defaultUserRateLimiting = {
21
+ windowMs: 900 * 1e3,
22
+ max: 1e3
23
+ };
24
+ function isNodeVersionGreaterThan21() {
25
+ const [major, minor] = process.versions.node.split(".").map(Number);
26
+ return major > 21 || major === 21 && minor >= 0;
27
+ }
28
+ var TOKEN_VALID_LENGTH = 32;
29
+ /**
30
+ * Coordinates the application configuration
31
+ */
32
+ var Config = class {
33
+ user_agent;
34
+ uplinks;
35
+ packages;
36
+ users;
37
+ auth;
38
+ store;
39
+ server_id;
40
+ configPath;
41
+ /**
42
+ * @deprecated use configPath or config.getConfigPath();
43
+ */
44
+ self_path;
45
+ storage;
46
+ plugins;
47
+ security;
48
+ server;
49
+ configOverrideOptions;
50
+ secret;
51
+ flags;
52
+ userRateLimit;
53
+ constructor(config, configOverrideOptions = { forceMigrateToSecureLegacySignature: true }) {
54
+ const self = this;
55
+ this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;
56
+ if (!config.configPath) {
57
+ config.configPath = config.config_path ?? config.self_path;
58
+ if (!config.configPath) throw new Error("configPath property is required");
59
+ }
60
+ this.configOverrideOptions = configOverrideOptions;
61
+ this.configPath = config.configPath;
62
+ this.self_path = this.configPath;
63
+ debug("config path: %s", this.configPath);
64
+ this.plugins = config.plugins;
65
+ this.security = _.merge(_.merge(defaultSecurity, { api: { migrateToSecureLegacySignature: this.configOverrideOptions.forceMigrateToSecureLegacySignature } }), config.security);
66
+ this.server = {
67
+ ...serverSettings_default,
68
+ ...config.server
69
+ };
70
+ this.flags = {
71
+ searchRemote: config.flags?.searchRemote ?? true,
72
+ changePassword: config.flags?.changePassword ?? false,
73
+ webLogin: config.flags?.webLogin ?? false,
74
+ createUser: config.flags?.createUser ?? false
75
+ };
76
+ this.user_agent = config.user_agent;
77
+ for (const configProp in config) if (self[configProp] == null) self[configProp] = config[configProp];
78
+ if (typeof this.user_agent === "undefined") {
79
+ debug("set default user agent");
80
+ this.user_agent = getUserAgent(false);
81
+ }
82
+ this.userRateLimit = {
83
+ ...defaultUserRateLimiting,
84
+ ...config?.userRateLimit
85
+ };
86
+ assert(validationUtils.isObject(config), APP_ERROR.CONFIG_NOT_VALID);
87
+ strategicConfigProps.forEach(function(x) {
88
+ if (self[x] == null) self[x] = {};
89
+ assert(validationUtils.isObject(self[x]), `CONFIG: bad "${x}" value (object expected)`);
90
+ });
91
+ this.uplinks = sanityCheckUplinksProps(uplinkSanityCheck(this.uplinks));
92
+ this.packages = normalisePackageAccess(self.packages);
93
+ allowedEnvConfig.forEach((envConf) => {
94
+ if (!(envConf in self)) self[envConf] = process.env[envConf] || process.env[envConf.toUpperCase()];
95
+ });
96
+ if (!this.server_id) this.server_id = cryptoUtils.generateRandomHexString(6);
97
+ }
98
+ getMigrateToSecureLegacySignature() {
99
+ return this.security.api.migrateToSecureLegacySignature;
100
+ }
101
+ getConfigPath() {
102
+ return this.configPath;
103
+ }
104
+ /**
105
+ * Check for package spec
106
+ * @param pkgName - package name
107
+ * @returns package access
108
+ * @deprecated use core.authUtils instead
109
+ */
110
+ getMatchedPackagesSpec(pkgName) {
111
+ return authUtils.getMatchedPackagesSpec(pkgName, this.packages);
112
+ }
113
+ /**
114
+ * Verify if the secret complies with the required structure
115
+ * - If the secret is not provided, it will generate a new one
116
+ * - For any Node.js version the new secret will be 32 characters long (to allow compatibility with modern Node.js versions)
117
+ * - If the secret is provided:
118
+ * - If Node.js 22 or higher, the secret must be 32 characters long thus the application will fail on startup
119
+ * - If Node.js 21 or lower, the secret will be used as is but will display a deprecation warning
120
+ * - If the property `security.api.migrateToSecureLegacySignature` is provided and set to true, the secret will be
121
+ * generated with the new signature model
122
+ * @secret external secret key
123
+ */
124
+ checkSecretKey(secret) {
125
+ debug("checking secret key init");
126
+ if (typeof secret === "string" && _.isEmpty(secret) === false) {
127
+ debug("checking secret key length %s", secret.length);
128
+ if (secret.length === TOKEN_VALID_LENGTH) {
129
+ debug("detected valid secret key length %s", secret.length);
130
+ this.secret = secret;
131
+ return this.secret;
132
+ }
133
+ if (this.getMigrateToSecureLegacySignature() === true) {
134
+ this.secret = generateRandomSecretKey();
135
+ debug("rewriting secret key with length %s", this.secret.length);
136
+ return this.secret;
137
+ }
138
+ debug("secret does not comply with the required length, current length %d", secret.length);
139
+ throw new Error(`Invalid storage secret key length, must be 32 characters long but is ${secret.length}.
140
+ The secret length in Node.js 22 or higher must be 32 characters long. Please consider generate a new one.
141
+ Learn more at https://verdaccio.org/docs/configuration/#.verdaccio-db`);
142
+ } else {
143
+ debug("generating a new secret key");
144
+ this.secret = generateRandomSecretKey();
145
+ debug("generated a new secret key length %s", this.secret?.length);
146
+ return this.secret;
147
+ }
148
+ }
149
+ };
150
+ //#endregion
151
+ export { Config, WEB_TITLE, defaultUserRateLimiting, isNodeVersionGreaterThan21 };
152
+
153
+ //# sourceMappingURL=config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport assert from 'node:assert';\n\nimport { APP_ERROR, authUtils, cryptoUtils, validationUtils } from '@verdaccio/core';\nimport type {\n Config as AppConfig,\n AuthConf,\n ConfigYaml,\n FlagsConfig,\n PackageAccess,\n PackageList,\n RateLimit,\n Security,\n ServerSettingsConf,\n} from '@verdaccio/types';\n\nimport { getUserAgent } from './agent';\nimport { normalisePackageAccess } from './package-access';\nimport { defaultSecurity } from './security';\nimport defaultServerSettings from './serverSettings';\nimport { generateRandomSecretKey } from './token';\nimport { sanityCheckUplinksProps, uplinkSanityCheck } from './uplinks';\n\nconst strategicConfigProps = ['uplinks', 'packages'];\nconst allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];\nconst debug = buildDebug('verdaccio:config');\n\nexport const WEB_TITLE = 'Verdaccio';\n\n// we limit max 1000 request per 15 minutes on user endpoints\nexport const defaultUserRateLimiting = {\n windowMs: 15 * 60 * 1000, // 15 minutes\n max: 1000,\n};\n\nexport function isNodeVersionGreaterThan21() {\n const [major, minor] = process.versions.node.split('.').map(Number);\n return major > 21 || (major === 21 && minor >= 0);\n}\n\nconst TOKEN_VALID_LENGTH = 32;\n\n/**\n * Coordinates the application configuration\n */\nclass Config implements AppConfig {\n public user_agent: string | undefined;\n public uplinks: any;\n public packages: PackageList;\n public users: any;\n public auth: AuthConf;\n public store: any;\n public server_id: string;\n public configPath: string;\n /**\n * @deprecated use configPath or config.getConfigPath();\n */\n public self_path: string;\n public storage: string | void;\n\n public plugins: string | void | null;\n public security: Security;\n public server: ServerSettingsConf;\n private configOverrideOptions: { forceMigrateToSecureLegacySignature: boolean };\n // @ts-ignore\n public secret: string;\n public flags: FlagsConfig;\n public userRateLimit: RateLimit;\n public constructor(\n config: ConfigYaml & { config_path: string },\n // forceEnhancedLegacySignature is a property that\n // allows switch a new legacy aes signature token signature\n // for older versions do not want to have this new signature model\n // this property must be false\n configOverrideOptions = { forceMigrateToSecureLegacySignature: true }\n ) {\n const self = this;\n this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;\n if (!config.configPath) {\n // backport self_path for previous to version 6\n // @ts-expect-error\n config.configPath = config.config_path ?? config.self_path;\n if (!config.configPath) {\n throw new Error('configPath property is required');\n }\n }\n this.configOverrideOptions = configOverrideOptions;\n this.configPath = config.configPath;\n this.self_path = this.configPath;\n debug('config path: %s', this.configPath);\n this.plugins = config.plugins;\n this.security = _.merge(\n // override the default security configuration via constructor\n _.merge(defaultSecurity, {\n api: {\n migrateToSecureLegacySignature:\n this.configOverrideOptions.forceMigrateToSecureLegacySignature,\n },\n }),\n config.security\n );\n this.server = { ...defaultServerSettings, ...config.server };\n this.flags = {\n searchRemote: config.flags?.searchRemote ?? true,\n changePassword: config.flags?.changePassword ?? false,\n webLogin: config.flags?.webLogin ?? false,\n createUser: config.flags?.createUser ?? false,\n };\n this.user_agent = config.user_agent;\n\n for (const configProp in config) {\n if (self[configProp] == null) {\n self[configProp] = config[configProp];\n }\n }\n\n if (typeof this.user_agent === 'undefined') {\n // by default user agent is hidden\n debug('set default user agent');\n this.user_agent = getUserAgent(false);\n }\n\n this.userRateLimit = { ...defaultUserRateLimiting, ...config?.userRateLimit };\n\n // some weird shell scripts are valid yaml files parsed as string\n assert(validationUtils.isObject(config), APP_ERROR.CONFIG_NOT_VALID);\n\n // sanity check for strategic config properties\n strategicConfigProps.forEach(function (x): void {\n if (self[x] == null) {\n self[x] = {};\n }\n\n assert(validationUtils.isObject(self[x]), `CONFIG: bad \"${x}\" value (object expected)`);\n });\n\n this.uplinks = sanityCheckUplinksProps(uplinkSanityCheck(this.uplinks));\n this.packages = normalisePackageAccess(self.packages);\n\n // loading these from ENV if aren't in config\n allowedEnvConfig.forEach((envConf): void => {\n if (!(envConf in self)) {\n self[envConf] = process.env[envConf] || process.env[envConf.toUpperCase()];\n }\n });\n\n // unique identifier of self server (or a cluster), used to avoid loops\n // @ts-ignore\n if (!this.server_id) {\n this.server_id = cryptoUtils.generateRandomHexString(6);\n }\n }\n\n public getMigrateToSecureLegacySignature() {\n return this.security.api.migrateToSecureLegacySignature;\n }\n\n public getConfigPath() {\n return this.configPath;\n }\n\n /**\n * Check for package spec\n * @param pkgName - package name\n * @returns package access\n * @deprecated use core.authUtils instead\n */\n public getMatchedPackagesSpec(pkgName: string): PackageAccess | void {\n // TODO: remove this method and replace by library utils\n return authUtils.getMatchedPackagesSpec(pkgName, this.packages);\n }\n\n /**\n * Verify if the secret complies with the required structure\n * - If the secret is not provided, it will generate a new one\n * - For any Node.js version the new secret will be 32 characters long (to allow compatibility with modern Node.js versions)\n * - If the secret is provided:\n * - If Node.js 22 or higher, the secret must be 32 characters long thus the application will fail on startup\n * - If Node.js 21 or lower, the secret will be used as is but will display a deprecation warning\n * - If the property `security.api.migrateToSecureLegacySignature` is provided and set to true, the secret will be\n * generated with the new signature model\n * @secret external secret key\n */\n public checkSecretKey(secret?: string): string {\n debug('checking secret key init');\n if (typeof secret === 'string' && _.isEmpty(secret) === false) {\n debug('checking secret key length %s', secret.length);\n if (secret.length === TOKEN_VALID_LENGTH) {\n debug('detected valid secret key length %s', secret.length);\n this.secret = secret;\n return this.secret;\n }\n // Node.js 22+ removed the legacy AES APIs, so token signing only works\n // with a secret of exactly 32 characters: migrate legacy (64 characters)\n // or manually edited secrets, otherwise fail fast at startup instead of\n // failing later on the first signed token\n if (this.getMigrateToSecureLegacySignature() === true) {\n this.secret = generateRandomSecretKey();\n debug('rewriting secret key with length %s', this.secret.length);\n return this.secret;\n }\n debug('secret does not comply with the required length, current length %d', secret.length);\n throw new Error(\n `Invalid storage secret key length, must be 32 characters long but is ${secret.length}. \n The secret length in Node.js 22 or higher must be 32 characters long. Please consider generate a new one. \n Learn more at https://verdaccio.org/docs/configuration/#.verdaccio-db`\n );\n } else {\n // generate a new a secret key\n // FUTURE: this might be an external secret key, perhaps within config file?\n debug('generating a new secret key');\n this.secret = generateRandomSecretKey();\n debug('generated a new secret key length %s', this.secret?.length);\n\n return this.secret;\n }\n }\n}\n\nexport { Config };\n"],"mappings":";;;;;;;;;;;AAwBA,IAAM,uBAAuB,CAAC,WAAW,UAAU;AACnD,IAAM,mBAAmB;CAAC;CAAc;CAAe;AAAU;AACjE,IAAM,QAAQ,WAAW,kBAAkB;AAE3C,IAAa,YAAY;AAGzB,IAAa,0BAA0B;CACrC,UAAU,MAAU;CACpB,KAAK;AACP;AAEA,SAAgB,6BAA6B;CAC3C,MAAM,CAAC,OAAO,SAAS,QAAQ,SAAS,KAAK,MAAM,GAAG,EAAE,IAAI,MAAM;CAClE,OAAO,QAAQ,MAAO,UAAU,MAAM,SAAS;AACjD;AAEA,IAAM,qBAAqB;;;;AAK3B,IAAM,SAAN,MAAkC;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;;CAIA;CACA;CAEA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA,YACE,QAKA,wBAAwB,EAAE,qCAAqC,KAAK,GACpE;EACA,MAAM,OAAO;EACb,KAAK,UAAU,QAAQ,IAAI,0BAA0B,OAAO;EAC5D,IAAI,CAAC,OAAO,YAAY;GAGtB,OAAO,aAAa,OAAO,eAAe,OAAO;GACjD,IAAI,CAAC,OAAO,YACV,MAAM,IAAI,MAAM,iCAAiC;EAErD;EACA,KAAK,wBAAwB;EAC7B,KAAK,aAAa,OAAO;EACzB,KAAK,YAAY,KAAK;EACtB,MAAM,mBAAmB,KAAK,UAAU;EACxC,KAAK,UAAU,OAAO;EACtB,KAAK,WAAW,EAAE,MAEhB,EAAE,MAAM,iBAAiB,EACvB,KAAK,EACH,gCACE,KAAK,sBAAsB,oCAC/B,EACF,CAAC,GACD,OAAO,QACT;EACA,KAAK,SAAS;GAAE,GAAG;GAAuB,GAAG,OAAO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O,MAAM;GACpD,IAAI,OAAO,WAAW,oBAAoB;IACxC,MAAM,uCAAuC,OAAO,MAAM;IAC1D,KAAK,SAAS;IACd,OAAO,KAAK;GACd;GAKA,IAAI,KAAK,kCAAkC,MAAM,MAAM;IACrD,KAAK,SAAS,wBAAwB;IACtC,MAAM,uCAAuC,KAAK,OAAO,MAAM;IAC/D,OAAO,KAAK;GACd;GACA,MAAM,sEAAsE,OAAO,MAAM;GACzF,MAAM,IAAI,MACR,wEAAwE,OAAO,OAAO;;8EAGxF;EACF,OAAO;GAGL,MAAM,6BAA6B;GACnC,KAAK,SAAS,wBAAwB;GACtC,MAAM,wCAAwC,KAAK,QAAQ,MAAM;GAEjE,OAAO,KAAK;EACd;CACF;AACF"}
package/build/index.js CHANGED
@@ -1,167 +1,52 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- fromJStoYAML: true,
8
- parseConfigFile: true,
9
- getConfigParsed: true,
10
- ConfigBuilder: true,
11
- getDefaultConfig: true
12
- };
13
- Object.defineProperty(exports, "ConfigBuilder", {
14
- enumerable: true,
15
- get: function () {
16
- return _builder.default;
17
- }
18
- });
19
- Object.defineProperty(exports, "fromJStoYAML", {
20
- enumerable: true,
21
- get: function () {
22
- return _parse.fromJStoYAML;
23
- }
24
- });
25
- Object.defineProperty(exports, "getConfigParsed", {
26
- enumerable: true,
27
- get: function () {
28
- return _parse.getConfigParsed;
29
- }
30
- });
31
- Object.defineProperty(exports, "getDefaultConfig", {
32
- enumerable: true,
33
- get: function () {
34
- return _conf.getDefaultConfig;
35
- }
36
- });
37
- Object.defineProperty(exports, "parseConfigFile", {
38
- enumerable: true,
39
- get: function () {
40
- return _parse.parseConfigFile;
41
- }
42
- });
43
- var _config = require("./config");
44
- Object.keys(_config).forEach(function (key) {
45
- if (key === "default" || key === "__esModule") return;
46
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
47
- if (key in exports && exports[key] === _config[key]) return;
48
- Object.defineProperty(exports, key, {
49
- enumerable: true,
50
- get: function () {
51
- return _config[key];
52
- }
53
- });
54
- });
55
- var _configPath = require("./config-path");
56
- Object.keys(_configPath).forEach(function (key) {
57
- if (key === "default" || key === "__esModule") return;
58
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
59
- if (key in exports && exports[key] === _configPath[key]) return;
60
- Object.defineProperty(exports, key, {
61
- enumerable: true,
62
- get: function () {
63
- return _configPath[key];
64
- }
65
- });
66
- });
67
- var _token = require("./token");
68
- Object.keys(_token).forEach(function (key) {
69
- if (key === "default" || key === "__esModule") return;
70
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
71
- if (key in exports && exports[key] === _token[key]) return;
72
- Object.defineProperty(exports, key, {
73
- enumerable: true,
74
- get: function () {
75
- return _token[key];
76
- }
77
- });
78
- });
79
- var _configUtils = require("./config-utils");
80
- Object.keys(_configUtils).forEach(function (key) {
81
- if (key === "default" || key === "__esModule") return;
82
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
83
- if (key in exports && exports[key] === _configUtils[key]) return;
84
- Object.defineProperty(exports, key, {
85
- enumerable: true,
86
- get: function () {
87
- return _configUtils[key];
88
- }
89
- });
90
- });
91
- var _packageAccess = require("./package-access");
92
- Object.keys(_packageAccess).forEach(function (key) {
93
- if (key === "default" || key === "__esModule") return;
94
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
95
- if (key in exports && exports[key] === _packageAccess[key]) return;
96
- Object.defineProperty(exports, key, {
97
- enumerable: true,
98
- get: function () {
99
- return _packageAccess[key];
100
- }
101
- });
102
- });
103
- var _parse = require("./parse");
104
- var _uplinks = require("./uplinks");
105
- Object.keys(_uplinks).forEach(function (key) {
106
- if (key === "default" || key === "__esModule") return;
107
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
108
- if (key in exports && exports[key] === _uplinks[key]) return;
109
- Object.defineProperty(exports, key, {
110
- enumerable: true,
111
- get: function () {
112
- return _uplinks[key];
113
- }
114
- });
115
- });
116
- var _security = require("./security");
117
- Object.keys(_security).forEach(function (key) {
118
- if (key === "default" || key === "__esModule") return;
119
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
120
- if (key in exports && exports[key] === _security[key]) return;
121
- Object.defineProperty(exports, key, {
122
- enumerable: true,
123
- get: function () {
124
- return _security[key];
125
- }
126
- });
127
- });
128
- var _agent = require("./agent");
129
- Object.keys(_agent).forEach(function (key) {
130
- if (key === "default" || key === "__esModule") return;
131
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
132
- if (key in exports && exports[key] === _agent[key]) return;
133
- Object.defineProperty(exports, key, {
134
- enumerable: true,
135
- get: function () {
136
- return _agent[key];
137
- }
138
- });
139
- });
140
- var _user = require("./user");
141
- Object.keys(_user).forEach(function (key) {
142
- if (key === "default" || key === "__esModule") return;
143
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
144
- if (key in exports && exports[key] === _user[key]) return;
145
- Object.defineProperty(exports, key, {
146
- enumerable: true,
147
- get: function () {
148
- return _user[key];
149
- }
150
- });
151
- });
152
- var _builder = _interopRequireDefault(require("./builder"));
153
- var _conf = require("./conf");
154
- var _address = require("./address");
155
- Object.keys(_address).forEach(function (key) {
156
- if (key === "default" || key === "__esModule") return;
157
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
158
- if (key in exports && exports[key] === _address[key]) return;
159
- Object.defineProperty(exports, key, {
160
- enumerable: true,
161
- get: function () {
162
- return _address[key];
163
- }
164
- });
165
- });
166
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
167
- //# sourceMappingURL=index.js.map
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ const require_agent = require("./agent.js");
6
+ const require_package_access = require("./package-access.js");
7
+ const require_security = require("./security.js");
8
+ const require_token = require("./token.js");
9
+ const require_uplinks = require("./uplinks.js");
10
+ const require_config = require("./config.js");
11
+ const require_config_utils = require("./config-utils.js");
12
+ const require_config_path = require("./config-path.js");
13
+ const require_parse = require("./parse.js");
14
+ const require_user = require("./user.js");
15
+ const require_builder = require("./builder.js");
16
+ const require_index = require("./conf/index.js");
17
+ const require_address = require("./address.js");
18
+ exports.Config = require_config.Config;
19
+ exports.ConfigBuilder = require_builder.default;
20
+ exports.DEFAULT_REGISTRY = require_uplinks.DEFAULT_REGISTRY;
21
+ exports.DEFAULT_UPLINK = require_uplinks.DEFAULT_UPLINK;
22
+ exports.PACKAGE_ACCESS = require_package_access.PACKAGE_ACCESS;
23
+ exports.ROLES = require_package_access.ROLES;
24
+ exports.TIME_EXPIRATION_1H = require_security.TIME_EXPIRATION_1H;
25
+ exports.TOKEN_VALID_LENGTH = require_token.TOKEN_VALID_LENGTH;
26
+ exports.WEB_TITLE = require_config.WEB_TITLE;
27
+ exports.createAnonymousRemoteUser = require_user.createAnonymousRemoteUser;
28
+ exports.createRemoteUser = require_user.createRemoteUser;
29
+ exports.defaultLoggedUserRoles = require_user.defaultLoggedUserRoles;
30
+ exports.defaultNonLoggedUserRoles = require_user.defaultNonLoggedUserRoles;
31
+ exports.defaultSecurity = require_security.defaultSecurity;
32
+ exports.defaultUserRateLimiting = require_config.defaultUserRateLimiting;
33
+ exports.fileExists = require_config_utils.fileExists;
34
+ exports.findConfigFile = require_config_path.findConfigFile;
35
+ exports.folderExists = require_config_utils.folderExists;
36
+ exports.fromJStoYAML = require_parse.fromJStoYAML;
37
+ exports.generateRandomSecretKey = require_token.generateRandomSecretKey;
38
+ exports.getConfigParsed = require_parse.getConfigParsed;
39
+ exports.getDefaultConfig = require_index.getDefaultConfig;
40
+ exports.getListenAddress = require_address.getListenAddress;
41
+ exports.getProxiesForPackage = require_uplinks.getProxiesForPackage;
42
+ exports.getUserAgent = require_agent.getUserAgent;
43
+ exports.hasProxyTo = require_uplinks.hasProxyTo;
44
+ exports.isNodeVersionGreaterThan21 = require_config.isNodeVersionGreaterThan21;
45
+ exports.normalisePackageAccess = require_package_access.normalisePackageAccess;
46
+ exports.normalizeUserList = require_package_access.normalizeUserList;
47
+ exports.parseAddress = require_address.parseAddress;
48
+ exports.parseConfigFile = require_parse.parseConfigFile;
49
+ exports.readDefaultConfig = require_config_path.readDefaultConfig;
50
+ exports.sanityCheckNames = require_uplinks.sanityCheckNames;
51
+ exports.sanityCheckUplinksProps = require_uplinks.sanityCheckUplinksProps;
52
+ exports.uplinkSanityCheck = require_uplinks.uplinkSanityCheck;
@@ -0,0 +1,14 @@
1
+ import { getUserAgent } from "./agent.mjs";
2
+ import { PACKAGE_ACCESS, ROLES, normalisePackageAccess, normalizeUserList } from "./package-access.mjs";
3
+ import { TIME_EXPIRATION_1H, defaultSecurity } from "./security.mjs";
4
+ import { TOKEN_VALID_LENGTH, generateRandomSecretKey } from "./token.mjs";
5
+ import { DEFAULT_REGISTRY, DEFAULT_UPLINK, getProxiesForPackage, hasProxyTo, sanityCheckNames, sanityCheckUplinksProps, uplinkSanityCheck } from "./uplinks.mjs";
6
+ import { Config, WEB_TITLE, defaultUserRateLimiting, isNodeVersionGreaterThan21 } from "./config.mjs";
7
+ import { fileExists, folderExists } from "./config-utils.mjs";
8
+ import { findConfigFile, readDefaultConfig } from "./config-path.mjs";
9
+ import { fromJStoYAML, getConfigParsed, parseConfigFile } from "./parse.mjs";
10
+ import { createAnonymousRemoteUser, createRemoteUser, defaultLoggedUserRoles, defaultNonLoggedUserRoles } from "./user.mjs";
11
+ import ConfigBuilder from "./builder.mjs";
12
+ import { getDefaultConfig } from "./conf/index.mjs";
13
+ import { getListenAddress, parseAddress } from "./address.mjs";
14
+ export { Config, ConfigBuilder, DEFAULT_REGISTRY, DEFAULT_UPLINK, PACKAGE_ACCESS, ROLES, TIME_EXPIRATION_1H, TOKEN_VALID_LENGTH, WEB_TITLE, createAnonymousRemoteUser, createRemoteUser, defaultLoggedUserRoles, defaultNonLoggedUserRoles, defaultSecurity, defaultUserRateLimiting, fileExists, findConfigFile, folderExists, fromJStoYAML, generateRandomSecretKey, getConfigParsed, getDefaultConfig, getListenAddress, getProxiesForPackage, getUserAgent, hasProxyTo, isNodeVersionGreaterThan21, normalisePackageAccess, normalizeUserList, parseAddress, parseConfigFile, readDefaultConfig, sanityCheckNames, sanityCheckUplinksProps, uplinkSanityCheck };
@@ -1,75 +1,59 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ROLES = exports.PACKAGE_ACCESS = void 0;
7
- exports.normalisePackageAccess = normalisePackageAccess;
8
- exports.normalizeUserList = normalizeUserList;
9
- var _debug = _interopRequireDefault(require("debug"));
10
- var _lodash = _interopRequireDefault(require("lodash"));
11
- var _nodeAssert = _interopRequireDefault(require("node:assert"));
12
- var _core = require("@verdaccio/core");
13
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- const debug = (0, _debug.default)('verdaccio:config:utils');
15
- // @deprecated use @verdaccio/core:authUtils
16
- const ROLES = exports.ROLES = {
17
- $ALL: '$all',
18
- ALL: 'all',
19
- $AUTH: '$authenticated',
20
- $ANONYMOUS: '$anonymous',
21
- DEPRECATED_ALL: '@all',
22
- DEPRECATED_AUTH: '@authenticated',
23
- DEPRECATED_ANONYMOUS: '@anonymous'
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.js");
2
+ let debug = require("debug");
3
+ debug = require_runtime.__toESM(debug);
4
+ let lodash = require("lodash");
5
+ lodash = require_runtime.__toESM(lodash);
6
+ let node_assert = require("node:assert");
7
+ node_assert = require_runtime.__toESM(node_assert);
8
+ let _verdaccio_core = require("@verdaccio/core");
9
+ //#region src/package-access.ts
10
+ var debug$1 = (0, debug.default)("verdaccio:config:utils");
11
+ var ROLES = {
12
+ $ALL: "$all",
13
+ ALL: "all",
14
+ $AUTH: "$authenticated",
15
+ $ANONYMOUS: "$anonymous",
16
+ DEPRECATED_ALL: "@all",
17
+ DEPRECATED_AUTH: "@authenticated",
18
+ DEPRECATED_ANONYMOUS: "@anonymous"
24
19
  };
25
-
26
- // @deprecated use @verdaccio/core:authUtils
27
- const PACKAGE_ACCESS = exports.PACKAGE_ACCESS = {
28
- SCOPE: '@*/*',
29
- ALL: '**'
20
+ var PACKAGE_ACCESS = {
21
+ SCOPE: "@*/*",
22
+ ALL: "**"
30
23
  };
31
24
  function normalizeUserList(groupsList) {
32
- const result = [];
33
- if (_lodash.default.isNil(groupsList) || _lodash.default.isEmpty(groupsList)) {
34
- return result;
35
- }
36
-
37
- // if it's a string, split it to array
38
- if (_lodash.default.isString(groupsList)) {
39
- const groupsArray = groupsList.split(/\s+/);
40
- result.push(groupsArray);
41
- } else if (Array.isArray(groupsList)) {
42
- result.push(groupsList);
43
- } else {
44
- throw _core.errorUtils.getInternalError('CONFIG: bad package acl (array or string expected): ' + JSON.stringify(groupsList));
45
- }
46
- return _lodash.default.flatten(result);
25
+ const result = [];
26
+ if (lodash.default.isNil(groupsList) || lodash.default.isEmpty(groupsList)) return result;
27
+ if (lodash.default.isString(groupsList)) {
28
+ const groupsArray = groupsList.split(/\s+/);
29
+ result.push(groupsArray);
30
+ } else if (Array.isArray(groupsList)) result.push(groupsList);
31
+ else throw _verdaccio_core.errorUtils.getInternalError("CONFIG: bad package acl (array or string expected): " + JSON.stringify(groupsList));
32
+ return lodash.default.flatten(result);
47
33
  }
48
34
  function normalisePackageAccess(packages) {
49
- const normalizedPkgs = {
50
- ...packages
51
- };
52
- if (_lodash.default.isNil(normalizedPkgs['**'])) {
53
- normalizedPkgs['**'] = {
54
- access: [],
55
- publish: [],
56
- unpublish: [],
57
- proxy: []
58
- };
59
- }
60
- for (const pkg in packages) {
61
- if (Object.prototype.hasOwnProperty.call(packages, pkg)) {
62
- const packageAccess = packages[pkg];
63
- debug('package access %s for %s ', packageAccess, pkg);
64
- const isInvalid = _lodash.default.isObject(packageAccess) && _lodash.default.isArray(packageAccess) === false;
65
- (0, _nodeAssert.default)(isInvalid, `CONFIG: bad "'${pkg}'" package description (object expected)`);
66
- normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);
67
- normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);
68
- normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);
69
- // if unpublish is not defined, we set to false to fallback in publish access
70
- normalizedPkgs[pkg].unpublish = _lodash.default.isUndefined(packageAccess.unpublish) ? false : normalizeUserList(packageAccess.unpublish);
71
- }
72
- }
73
- return normalizedPkgs;
35
+ const normalizedPkgs = { ...packages };
36
+ if (lodash.default.isNil(normalizedPkgs["**"])) normalizedPkgs["**"] = {
37
+ access: [],
38
+ publish: [],
39
+ unpublish: [],
40
+ proxy: []
41
+ };
42
+ for (const pkg in packages) if (Object.prototype.hasOwnProperty.call(packages, pkg)) {
43
+ const packageAccess = packages[pkg];
44
+ debug$1("package access %s for %s ", packageAccess, pkg);
45
+ (0, node_assert.default)(lodash.default.isObject(packageAccess) && lodash.default.isArray(packageAccess) === false, `CONFIG: bad "'${pkg}'" package description (object expected)`);
46
+ normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);
47
+ normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);
48
+ normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);
49
+ normalizedPkgs[pkg].unpublish = lodash.default.isUndefined(packageAccess.unpublish) ? false : normalizeUserList(packageAccess.unpublish);
50
+ }
51
+ return normalizedPkgs;
74
52
  }
53
+ //#endregion
54
+ exports.PACKAGE_ACCESS = PACKAGE_ACCESS;
55
+ exports.ROLES = ROLES;
56
+ exports.normalisePackageAccess = normalisePackageAccess;
57
+ exports.normalizeUserList = normalizeUserList;
58
+
75
59
  //# sourceMappingURL=package-access.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"package-access.js","names":["_debug","_interopRequireDefault","require","_lodash","_nodeAssert","_core","e","__esModule","default","debug","buildDebug","ROLES","exports","$ALL","ALL","$AUTH","$ANONYMOUS","DEPRECATED_ALL","DEPRECATED_AUTH","DEPRECATED_ANONYMOUS","PACKAGE_ACCESS","SCOPE","normalizeUserList","groupsList","result","_","isNil","isEmpty","isString","groupsArray","split","push","Array","isArray","errorUtils","getInternalError","JSON","stringify","flatten","normalisePackageAccess","packages","normalizedPkgs","access","publish","unpublish","proxy","pkg","Object","prototype","hasOwnProperty","call","packageAccess","isInvalid","isObject","assert","isUndefined"],"sources":["../src/package-access.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport assert from 'node:assert';\n\nimport { errorUtils } from '@verdaccio/core';\nimport type { PackageAccess } from '@verdaccio/types';\n\nconst debug = buildDebug('verdaccio:config:utils');\n\nexport interface LegacyPackageList {\n [key: string]: PackageAccess;\n}\n\n// @deprecated use @verdaccio/core:authUtils\nexport const ROLES = {\n $ALL: '$all',\n ALL: 'all',\n $AUTH: '$authenticated',\n $ANONYMOUS: '$anonymous',\n DEPRECATED_ALL: '@all',\n DEPRECATED_AUTH: '@authenticated',\n DEPRECATED_ANONYMOUS: '@anonymous',\n};\n\n// @deprecated use @verdaccio/core:authUtils\nexport const PACKAGE_ACCESS = {\n SCOPE: '@*/*',\n ALL: '**',\n};\n\nexport function normalizeUserList(groupsList: any): any {\n const result: any[] = [];\n if (_.isNil(groupsList) || _.isEmpty(groupsList)) {\n return result;\n }\n\n // if it's a string, split it to array\n if (_.isString(groupsList)) {\n const groupsArray = groupsList.split(/\\s+/);\n\n result.push(groupsArray);\n } else if (Array.isArray(groupsList)) {\n result.push(groupsList);\n } else {\n throw errorUtils.getInternalError(\n 'CONFIG: bad package acl (array or string expected): ' + JSON.stringify(groupsList)\n );\n }\n\n return _.flatten(result);\n}\n\nexport function normalisePackageAccess(packages: LegacyPackageList): LegacyPackageList {\n const normalizedPkgs: LegacyPackageList = { ...packages };\n if (_.isNil(normalizedPkgs['**'])) {\n normalizedPkgs['**'] = {\n access: [],\n publish: [],\n unpublish: [],\n proxy: [],\n };\n }\n\n for (const pkg in packages) {\n if (Object.prototype.hasOwnProperty.call(packages, pkg)) {\n const packageAccess = packages[pkg];\n debug('package access %s for %s ', packageAccess, pkg);\n const isInvalid = _.isObject(packageAccess) && _.isArray(packageAccess) === false;\n assert(isInvalid, `CONFIG: bad \"'${pkg}'\" package description (object expected)`);\n\n normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);\n normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);\n normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);\n // if unpublish is not defined, we set to false to fallback in publish access\n normalizedPkgs[pkg].unpublish = _.isUndefined(packageAccess.unpublish)\n ? false\n : normalizeUserList(packageAccess.unpublish);\n }\n }\n\n return normalizedPkgs;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AAA6C,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAG7C,MAAMG,KAAK,GAAG,IAAAC,cAAU,EAAC,wBAAwB,CAAC;AAMlD;AACO,MAAMC,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAG;EACnBE,IAAI,EAAE,MAAM;EACZC,GAAG,EAAE,KAAK;EACVC,KAAK,EAAE,gBAAgB;EACvBC,UAAU,EAAE,YAAY;EACxBC,cAAc,EAAE,MAAM;EACtBC,eAAe,EAAE,gBAAgB;EACjCC,oBAAoB,EAAE;AACxB,CAAC;;AAED;AACO,MAAMC,cAAc,GAAAR,OAAA,CAAAQ,cAAA,GAAG;EAC5BC,KAAK,EAAE,MAAM;EACbP,GAAG,EAAE;AACP,CAAC;AAEM,SAASQ,iBAAiBA,CAACC,UAAe,EAAO;EACtD,MAAMC,MAAa,GAAG,EAAE;EACxB,IAAIC,eAAC,CAACC,KAAK,CAACH,UAAU,CAA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ACjF,IAAAG,mBAAM,EAACF,SAAS,EAAE,iBAAiBN,GAAG,0CAA0C,CAAC;MAEjFL,cAAc,CAACK,GAAG,CAAC,CAACJ,MAAM,GAAGpB,iBAAiB,CAAC6B,aAAa,CAACT,MAAM,CAAC;MACpED,cAAc,CAACK,GAAG,CAAC,CAACH,OAAO,GAAGrB,iBAAiB,CAAC6B,aAAa,CAACR,OAAO,CAAC;MACtEF,cAAc,CAACK,GAAG,CAAC,CAACD,KAAK,GAAGvB,iBAAiB,CAAC6B,aAAa,CAACN,KAAK,CAAC;MAClE;MACAJ,cAAc,CAACK,GAAG,CAAC,CAACF,SAAS,GAAGnB,eAAC,CAAC8B,WAAW,CAACJ,aAAa,CAACP,SAAS,CAAC,GAClE,KAAK,GACLtB,iBAAiB,CAAC6B,aAAa,CAACP,SAAS,CAAC;IAChD;EACF;EAEA,OAAOH,cAAc;AACvB","ignoreList":[]}
1
+ {"version":3,"file":"package-access.js","names":[],"sources":["../src/package-access.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport assert from 'node:assert';\n\nimport { errorUtils } from '@verdaccio/core';\nimport type { PackageAccess } from '@verdaccio/types';\n\nconst debug = buildDebug('verdaccio:config:utils');\n\nexport interface LegacyPackageList {\n [key: string]: PackageAccess;\n}\n\n// @deprecated use @verdaccio/core:authUtils\nexport const ROLES = {\n $ALL: '$all',\n ALL: 'all',\n $AUTH: '$authenticated',\n $ANONYMOUS: '$anonymous',\n DEPRECATED_ALL: '@all',\n DEPRECATED_AUTH: '@authenticated',\n DEPRECATED_ANONYMOUS: '@anonymous',\n};\n\n// @deprecated use @verdaccio/core:authUtils\nexport const PACKAGE_ACCESS = {\n SCOPE: '@*/*',\n ALL: '**',\n};\n\nexport function normalizeUserList(groupsList: any): any {\n const result: any[] = [];\n if (_.isNil(groupsList) || _.isEmpty(groupsList)) {\n return result;\n }\n\n // if it's a string, split it to array\n if (_.isString(groupsList)) {\n const groupsArray = groupsList.split(/\\s+/);\n\n result.push(groupsArray);\n } else if (Array.isArray(groupsList)) {\n result.push(groupsList);\n } else {\n throw errorUtils.getInternalError(\n 'CONFIG: bad package acl (array or string expected): ' + JSON.stringify(groupsList)\n );\n }\n\n return _.flatten(result);\n}\n\nexport function normalisePackageAccess(packages: LegacyPackageList): LegacyPackageList {\n const normalizedPkgs: LegacyPackageList = { ...packages };\n if (_.isNil(normalizedPkgs['**'])) {\n normalizedPkgs['**'] = {\n access: [],\n publish: [],\n unpublish: [],\n proxy: [],\n };\n }\n\n for (const pkg in packages) {\n if (Object.prototype.hasOwnProperty.call(packages, pkg)) {\n const packageAccess = packages[pkg];\n debug('package access %s for %s ', packageAccess, pkg);\n const isInvalid = _.isObject(packageAccess) && _.isArray(packageAccess) === false;\n assert(isInvalid, `CONFIG: bad \"'${pkg}'\" package description (object expected)`);\n\n normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);\n normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);\n normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);\n // if unpublish is not defined, we set to false to fallback in publish access\n normalizedPkgs[pkg].unpublish = _.isUndefined(packageAccess.unpublish)\n ? false\n : normalizeUserList(packageAccess.unpublish);\n }\n }\n\n return normalizedPkgs;\n}\n"],"mappings":";;;;;;;;;AAOA,IAAM,WAAA,GAAA,MAAA,SAAmB,wBAAwB;AAOjD,IAAa,QAAQ;CACnB,MAAM;CACN,KAAK;CACL,OAAO;CACP,YAAY;CACZ,gBAAgB;CAChB,iBAAiB;CACjB,sBAAsB;AACxB;AAGA,IAAa,iBAAiB;CAC5B,OAAO;CACP,KAAK;AACP;AAEA,SAAgB,kBAAkB,YAAsB;CACtD,MAAM,SAAgB,CAAC;CACvB,IAAI,OAAA,QAAE,MAAM,UAAU,KAAK,OAAA,QAAE,QAAQ,UAAU,GAC7C,OAAO;CAIT,IAAI,OAAA,QAAE,SAAS,UAAU,GAAG;EAC1B,MAAM,cAAc,WAAW,MAAM,KAAK;EAE1C,OAAO,KAAK,WAAW;CACzB,OAAO,IAAI,MAAM,QAAQ,UAAU,GACjC,OAAO,KAAK,UAAU;MAEtB,MAAM,gBAAA,WAAW,iBACf,yDAAyD,KAAK,UAAU,UAAU,CACpF;CAGF,OAAO,OAAA,QAAE,QAAQ,MAAM;AACzB;AAEA,SAAgB,uBAAuB,UAAgD;CACrF,MAAM,iBAAoC,EAAE,GAAG,SAAS;CACxD,IAAI,OAAA,QAAE,MAAM,eAAe,KAAK,GAC9B,eAAe,QAAQ;EACrB,QAAQ,CAAC;EACT,SAAS,CAAC;EACV,WAAW,CAAC;EACZ,OAAO,CAAC;CACV;CAGF,KAAK,MAAM,OAAO,UAChB,IAAI,OAAO,UAAU,eAAe,KAAK,UAAU,GAAG,GAAG;EACvD,MAAM,gBAAgB,SAAS;EAC/B,QAAM,6BAA6B,eAAe,GAAG;EAErD,CAAA,GAAA,YAAA,SADkB,OAAA,QAAE,SAAS,aAAa,KAAK,OAAA,QAAE,QAAQ,aAAa,MAAM,OAC1D,iBAAiB,IAAI,yCAAyC;EAEhF,eAAe,KAAK,SAAS,kBAAkB,cAAc,MAAM;EACnE,eAAe,KAAK,UAAU,kBAAkB,cAAc,OAAO;EACrE,eAAe,KAAK,QAAQ,kBAAkB,cAAc,KAAK;EAEjE,eAAe,KAAK,YAAY,OAAA,QAAE,YAAY,cAAc,SAAS,IACjE,QACA,kBAAkB,cAAc,SAAS;CAC/C;CAGF,OAAO;AACT"}
@@ -0,0 +1,52 @@
1
+ import buildDebug from "debug";
2
+ import _ from "lodash";
3
+ import assert from "node:assert";
4
+ import { errorUtils } from "@verdaccio/core";
5
+ //#region src/package-access.ts
6
+ var debug = buildDebug("verdaccio:config:utils");
7
+ var ROLES = {
8
+ $ALL: "$all",
9
+ ALL: "all",
10
+ $AUTH: "$authenticated",
11
+ $ANONYMOUS: "$anonymous",
12
+ DEPRECATED_ALL: "@all",
13
+ DEPRECATED_AUTH: "@authenticated",
14
+ DEPRECATED_ANONYMOUS: "@anonymous"
15
+ };
16
+ var PACKAGE_ACCESS = {
17
+ SCOPE: "@*/*",
18
+ ALL: "**"
19
+ };
20
+ function normalizeUserList(groupsList) {
21
+ const result = [];
22
+ if (_.isNil(groupsList) || _.isEmpty(groupsList)) return result;
23
+ if (_.isString(groupsList)) {
24
+ const groupsArray = groupsList.split(/\s+/);
25
+ result.push(groupsArray);
26
+ } else if (Array.isArray(groupsList)) result.push(groupsList);
27
+ else throw errorUtils.getInternalError("CONFIG: bad package acl (array or string expected): " + JSON.stringify(groupsList));
28
+ return _.flatten(result);
29
+ }
30
+ function normalisePackageAccess(packages) {
31
+ const normalizedPkgs = { ...packages };
32
+ if (_.isNil(normalizedPkgs["**"])) normalizedPkgs["**"] = {
33
+ access: [],
34
+ publish: [],
35
+ unpublish: [],
36
+ proxy: []
37
+ };
38
+ for (const pkg in packages) if (Object.prototype.hasOwnProperty.call(packages, pkg)) {
39
+ const packageAccess = packages[pkg];
40
+ debug("package access %s for %s ", packageAccess, pkg);
41
+ assert(_.isObject(packageAccess) && _.isArray(packageAccess) === false, `CONFIG: bad "'${pkg}'" package description (object expected)`);
42
+ normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);
43
+ normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);
44
+ normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);
45
+ normalizedPkgs[pkg].unpublish = _.isUndefined(packageAccess.unpublish) ? false : normalizeUserList(packageAccess.unpublish);
46
+ }
47
+ return normalizedPkgs;
48
+ }
49
+ //#endregion
50
+ export { PACKAGE_ACCESS, ROLES, normalisePackageAccess, normalizeUserList };
51
+
52
+ //# sourceMappingURL=package-access.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-access.mjs","names":[],"sources":["../src/package-access.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport assert from 'node:assert';\n\nimport { errorUtils } from '@verdaccio/core';\nimport type { PackageAccess } from '@verdaccio/types';\n\nconst debug = buildDebug('verdaccio:config:utils');\n\nexport interface LegacyPackageList {\n [key: string]: PackageAccess;\n}\n\n// @deprecated use @verdaccio/core:authUtils\nexport const ROLES = {\n $ALL: '$all',\n ALL: 'all',\n $AUTH: '$authenticated',\n $ANONYMOUS: '$anonymous',\n DEPRECATED_ALL: '@all',\n DEPRECATED_AUTH: '@authenticated',\n DEPRECATED_ANONYMOUS: '@anonymous',\n};\n\n// @deprecated use @verdaccio/core:authUtils\nexport const PACKAGE_ACCESS = {\n SCOPE: '@*/*',\n ALL: '**',\n};\n\nexport function normalizeUserList(groupsList: any): any {\n const result: any[] = [];\n if (_.isNil(groupsList) || _.isEmpty(groupsList)) {\n return result;\n }\n\n // if it's a string, split it to array\n if (_.isString(groupsList)) {\n const groupsArray = groupsList.split(/\\s+/);\n\n result.push(groupsArray);\n } else if (Array.isArray(groupsList)) {\n result.push(groupsList);\n } else {\n throw errorUtils.getInternalError(\n 'CONFIG: bad package acl (array or string expected): ' + JSON.stringify(groupsList)\n );\n }\n\n return _.flatten(result);\n}\n\nexport function normalisePackageAccess(packages: LegacyPackageList): LegacyPackageList {\n const normalizedPkgs: LegacyPackageList = { ...packages };\n if (_.isNil(normalizedPkgs['**'])) {\n normalizedPkgs['**'] = {\n access: [],\n publish: [],\n unpublish: [],\n proxy: [],\n };\n }\n\n for (const pkg in packages) {\n if (Object.prototype.hasOwnProperty.call(packages, pkg)) {\n const packageAccess = packages[pkg];\n debug('package access %s for %s ', packageAccess, pkg);\n const isInvalid = _.isObject(packageAccess) && _.isArray(packageAccess) === false;\n assert(isInvalid, `CONFIG: bad \"'${pkg}'\" package description (object expected)`);\n\n normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);\n normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);\n normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);\n // if unpublish is not defined, we set to false to fallback in publish access\n normalizedPkgs[pkg].unpublish = _.isUndefined(packageAccess.unpublish)\n ? false\n : normalize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