@verdaccio/config 9.0.0-next-9.7 → 9.0.0-next-9.8
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/agent.js +3 -4
- package/build/agent.js.map +1 -1
- package/build/agent.mjs +2 -2
- package/build/agent.mjs.map +1 -1
- package/build/builder.js +5 -5
- package/build/builder.js.map +1 -1
- package/build/builder.mjs +1 -1
- package/build/builder.mjs.map +1 -1
- package/build/conf/index.js +2 -1
- package/build/conf/index.js.map +1 -1
- package/build/conf/index.mjs +2 -1
- package/build/conf/index.mjs.map +1 -1
- package/build/config-path.js +4 -4
- package/build/config-path.js.map +1 -1
- package/build/config-path.mjs +4 -3
- package/build/config-path.mjs.map +1 -1
- package/build/config.js +3 -4
- package/build/config.js.map +1 -1
- package/build/config.mjs +3 -3
- package/build/config.mjs.map +1 -1
- package/build/package-access.js +7 -8
- package/build/package-access.js.map +1 -1
- package/build/package-access.mjs +7 -7
- package/build/package-access.mjs.map +1 -1
- package/build/parse.js +2 -2
- package/build/parse.js.map +1 -1
- package/build/parse.mjs +1 -1
- package/build/parse.mjs.map +1 -1
- package/build/uplinks.js +6 -7
- package/build/uplinks.js.map +1 -1
- package/build/uplinks.mjs +6 -6
- package/build/uplinks.mjs.map +1 -1
- package/package.json +4 -3
package/build/agent.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
let
|
|
3
|
-
lodash = require_runtime.__toESM(lodash);
|
|
1
|
+
require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
let lodash_es = require("lodash-es");
|
|
4
3
|
//#region src/agent.ts
|
|
5
4
|
function getUserAgent(customUserAgent, version, name) {
|
|
6
5
|
if (customUserAgent === true) return `${name}/${version}`;
|
|
7
|
-
else if (
|
|
6
|
+
else if (typeof customUserAgent === "string" && (0, lodash_es.isEmpty)(customUserAgent) === false) return customUserAgent;
|
|
8
7
|
else if (customUserAgent === false) return "hidden";
|
|
9
8
|
return `${name}/${version}`;
|
|
10
9
|
}
|
package/build/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","names":[],"sources":["../src/agent.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"agent.js","names":[],"sources":["../src/agent.ts"],"sourcesContent":["import { isEmpty } from 'lodash-es';\n\nexport function getUserAgent(\n customUserAgent?: boolean | string,\n version?: string,\n name?: string\n): string {\n if (customUserAgent === true) {\n return `${name}/${version}`;\n } else if (typeof customUserAgent === 'string' && isEmpty(customUserAgent) === false) {\n return customUserAgent;\n } else if (customUserAgent === false) {\n return 'hidden';\n }\n\n return `${name}/${version}`;\n}\n"],"mappings":";;;AAEA,SAAgB,aACd,iBACA,SACA,MACQ;AACR,KAAI,oBAAoB,KACtB,QAAO,GAAG,KAAK,GAAG;UACT,OAAO,oBAAoB,aAAA,GAAA,UAAA,SAAoB,gBAAgB,KAAK,MAC7E,QAAO;UACE,oBAAoB,MAC7B,QAAO;AAGT,QAAO,GAAG,KAAK,GAAG"}
|
package/build/agent.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isEmpty } from "lodash-es";
|
|
2
2
|
//#region src/agent.ts
|
|
3
3
|
function getUserAgent(customUserAgent, version, name) {
|
|
4
4
|
if (customUserAgent === true) return `${name}/${version}`;
|
|
5
|
-
else if (
|
|
5
|
+
else if (typeof customUserAgent === "string" && isEmpty(customUserAgent) === false) return customUserAgent;
|
|
6
6
|
else if (customUserAgent === false) return "hidden";
|
|
7
7
|
return `${name}/${version}`;
|
|
8
8
|
}
|
package/build/agent.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.mjs","names":[],"sources":["../src/agent.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"agent.mjs","names":[],"sources":["../src/agent.ts"],"sourcesContent":["import { isEmpty } from 'lodash-es';\n\nexport function getUserAgent(\n customUserAgent?: boolean | string,\n version?: string,\n name?: string\n): string {\n if (customUserAgent === true) {\n return `${name}/${version}`;\n } else if (typeof customUserAgent === 'string' && isEmpty(customUserAgent) === false) {\n return customUserAgent;\n } else if (customUserAgent === false) {\n return 'hidden';\n }\n\n return `${name}/${version}`;\n}\n"],"mappings":";;AAEA,SAAgB,aACd,iBACA,SACA,MACQ;AACR,KAAI,oBAAoB,KACtB,QAAO,GAAG,KAAK,GAAG;UACT,OAAO,oBAAoB,YAAY,QAAQ,gBAAgB,KAAK,MAC7E,QAAO;UACE,oBAAoB,MAC7B,QAAO;AAGT,QAAO,GAAG,KAAK,GAAG"}
|
package/build/builder.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require("./_virtual/_rolldown/runtime.js");
|
|
2
2
|
const require_parse = require("./parse.js");
|
|
3
3
|
require("./index.js");
|
|
4
|
-
let
|
|
4
|
+
let lodash_es = require("lodash-es");
|
|
5
5
|
//#region src/builder.ts
|
|
6
6
|
/**
|
|
7
7
|
* Helper configuration builder constructor, used to build the configuration for testing or
|
|
@@ -10,7 +10,7 @@ let lodash = require("lodash");
|
|
|
10
10
|
var ConfigBuilder = class ConfigBuilder {
|
|
11
11
|
config;
|
|
12
12
|
constructor(config) {
|
|
13
|
-
this.config = (0,
|
|
13
|
+
this.config = (0, lodash_es.merge)(config, {
|
|
14
14
|
uplinks: {},
|
|
15
15
|
packages: {},
|
|
16
16
|
security: {}
|
|
@@ -28,11 +28,11 @@ var ConfigBuilder = class ConfigBuilder {
|
|
|
28
28
|
return this;
|
|
29
29
|
}
|
|
30
30
|
addSecurity(security) {
|
|
31
|
-
this.config.security = (0,
|
|
31
|
+
this.config.security = (0, lodash_es.merge)(this.config.security, security);
|
|
32
32
|
return this;
|
|
33
33
|
}
|
|
34
34
|
addAuth(auth) {
|
|
35
|
-
this.config.auth = (0,
|
|
35
|
+
this.config.auth = (0, lodash_es.merge)(this.config.auth, auth);
|
|
36
36
|
return this;
|
|
37
37
|
}
|
|
38
38
|
addLogger(log) {
|
|
@@ -40,7 +40,7 @@ var ConfigBuilder = class ConfigBuilder {
|
|
|
40
40
|
return this;
|
|
41
41
|
}
|
|
42
42
|
addServer(server) {
|
|
43
|
-
this.config.server = (0,
|
|
43
|
+
this.config.server = (0, lodash_es.merge)(this.config.server, server);
|
|
44
44
|
return this;
|
|
45
45
|
}
|
|
46
46
|
addStorage(storage) {
|
package/build/builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","names":[],"sources":["../src/builder.ts"],"sourcesContent":["import { merge } from 'lodash';\n\nimport type {\n AuthConf,\n ConfigYaml,\n LoggerConfigItem,\n PackageAccessYaml,\n Security,\n ServerSettingsConf,\n UpLinkConf,\n} from '@verdaccio/types';\n\nimport { fromJStoYAML } from '.';\n\n/**\n * Helper configuration builder constructor, used to build the configuration for testing or\n * programatically creating a configuration.\n */\nexport default class ConfigBuilder {\n private config: ConfigYaml;\n\n public constructor(config?: Partial<ConfigYaml>) {\n this.config = merge(config, { uplinks: {}, packages: {}, security: {} });\n }\n\n public static build(config?: Partial<ConfigYaml>): ConfigBuilder {\n return new ConfigBuilder(config);\n }\n\n public addPackageAccess(pattern: string, pkgAccess: PackageAccessYaml) {\n // @ts-ignore\n this.config.packages[pattern] = pkgAccess;\n return this;\n }\n\n public addUplink(id: string, uplink: UpLinkConf) {\n this.config.uplinks[id] = uplink;\n return this;\n }\n\n public addSecurity(security: Partial<Security>) {\n this.config.security = merge(this.config.security, security);\n return this;\n }\n\n public addAuth(auth: Partial<AuthConf>) {\n this.config.auth = merge(this.config.auth, auth);\n return this;\n }\n\n public addLogger(log: LoggerConfigItem) {\n this.config.log = log;\n return this;\n }\n\n public addServer(server: Partial<ServerSettingsConf>) {\n this.config.server = merge(this.config.server, server);\n return this;\n }\n\n public addStorage(storage: string | object) {\n if (typeof storage === 'string') {\n this.config.storage = storage;\n } else {\n this.config.store = storage;\n }\n return this;\n }\n\n public getConfig(): ConfigYaml {\n return this.config;\n }\n\n public getAsYaml(): string {\n return fromJStoYAML(this.config) as string;\n }\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAqB,gBAArB,MAAqB,cAAc;CACjC;CAEA,YAAmB,QAA8B;AAC/C,OAAK,UAAA,GAAA,
|
|
1
|
+
{"version":3,"file":"builder.js","names":[],"sources":["../src/builder.ts"],"sourcesContent":["import { merge } from 'lodash-es';\n\nimport type {\n AuthConf,\n ConfigYaml,\n LoggerConfigItem,\n PackageAccessYaml,\n Security,\n ServerSettingsConf,\n UpLinkConf,\n} from '@verdaccio/types';\n\nimport { fromJStoYAML } from '.';\n\n/**\n * Helper configuration builder constructor, used to build the configuration for testing or\n * programatically creating a configuration.\n */\nexport default class ConfigBuilder {\n private config: ConfigYaml;\n\n public constructor(config?: Partial<ConfigYaml>) {\n this.config = merge(config, { uplinks: {}, packages: {}, security: {} });\n }\n\n public static build(config?: Partial<ConfigYaml>): ConfigBuilder {\n return new ConfigBuilder(config);\n }\n\n public addPackageAccess(pattern: string, pkgAccess: PackageAccessYaml) {\n // @ts-ignore\n this.config.packages[pattern] = pkgAccess;\n return this;\n }\n\n public addUplink(id: string, uplink: UpLinkConf) {\n this.config.uplinks[id] = uplink;\n return this;\n }\n\n public addSecurity(security: Partial<Security>) {\n this.config.security = merge(this.config.security, security);\n return this;\n }\n\n public addAuth(auth: Partial<AuthConf>) {\n this.config.auth = merge(this.config.auth, auth);\n return this;\n }\n\n public addLogger(log: LoggerConfigItem) {\n this.config.log = log;\n return this;\n }\n\n public addServer(server: Partial<ServerSettingsConf>) {\n this.config.server = merge(this.config.server, server);\n return this;\n }\n\n public addStorage(storage: string | object) {\n if (typeof storage === 'string') {\n this.config.storage = storage;\n } else {\n this.config.store = storage;\n }\n return this;\n }\n\n public getConfig(): ConfigYaml {\n return this.config;\n }\n\n public getAsYaml(): string {\n return fromJStoYAML(this.config) as string;\n }\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAqB,gBAArB,MAAqB,cAAc;CACjC;CAEA,YAAmB,QAA8B;AAC/C,OAAK,UAAA,GAAA,UAAA,OAAe,QAAQ;GAAE,SAAS,EAAE;GAAE,UAAU,EAAE;GAAE,UAAU,EAAE;GAAE,CAAC;;CAG1E,OAAc,MAAM,QAA6C;AAC/D,SAAO,IAAI,cAAc,OAAO;;CAGlC,iBAAwB,SAAiB,WAA8B;AAErE,OAAK,OAAO,SAAS,WAAW;AAChC,SAAO;;CAGT,UAAiB,IAAY,QAAoB;AAC/C,OAAK,OAAO,QAAQ,MAAM;AAC1B,SAAO;;CAGT,YAAmB,UAA6B;AAC9C,OAAK,OAAO,YAAA,GAAA,UAAA,OAAiB,KAAK,OAAO,UAAU,SAAS;AAC5D,SAAO;;CAGT,QAAe,MAAyB;AACtC,OAAK,OAAO,QAAA,GAAA,UAAA,OAAa,KAAK,OAAO,MAAM,KAAK;AAChD,SAAO;;CAGT,UAAiB,KAAuB;AACtC,OAAK,OAAO,MAAM;AAClB,SAAO;;CAGT,UAAiB,QAAqC;AACpD,OAAK,OAAO,UAAA,GAAA,UAAA,OAAe,KAAK,OAAO,QAAQ,OAAO;AACtD,SAAO;;CAGT,WAAkB,SAA0B;AAC1C,MAAI,OAAO,YAAY,SACrB,MAAK,OAAO,UAAU;MAEtB,MAAK,OAAO,QAAQ;AAEtB,SAAO;;CAGT,YAA+B;AAC7B,SAAO,KAAK;;CAGd,YAA2B;AACzB,SAAO,cAAA,aAAa,KAAK,OAAO"}
|
package/build/builder.mjs
CHANGED
package/build/builder.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.mjs","names":[],"sources":["../src/builder.ts"],"sourcesContent":["import { merge } from 'lodash';\n\nimport type {\n AuthConf,\n ConfigYaml,\n LoggerConfigItem,\n PackageAccessYaml,\n Security,\n ServerSettingsConf,\n UpLinkConf,\n} from '@verdaccio/types';\n\nimport { fromJStoYAML } from '.';\n\n/**\n * Helper configuration builder constructor, used to build the configuration for testing or\n * programatically creating a configuration.\n */\nexport default class ConfigBuilder {\n private config: ConfigYaml;\n\n public constructor(config?: Partial<ConfigYaml>) {\n this.config = merge(config, { uplinks: {}, packages: {}, security: {} });\n }\n\n public static build(config?: Partial<ConfigYaml>): ConfigBuilder {\n return new ConfigBuilder(config);\n }\n\n public addPackageAccess(pattern: string, pkgAccess: PackageAccessYaml) {\n // @ts-ignore\n this.config.packages[pattern] = pkgAccess;\n return this;\n }\n\n public addUplink(id: string, uplink: UpLinkConf) {\n this.config.uplinks[id] = uplink;\n return this;\n }\n\n public addSecurity(security: Partial<Security>) {\n this.config.security = merge(this.config.security, security);\n return this;\n }\n\n public addAuth(auth: Partial<AuthConf>) {\n this.config.auth = merge(this.config.auth, auth);\n return this;\n }\n\n public addLogger(log: LoggerConfigItem) {\n this.config.log = log;\n return this;\n }\n\n public addServer(server: Partial<ServerSettingsConf>) {\n this.config.server = merge(this.config.server, server);\n return this;\n }\n\n public addStorage(storage: string | object) {\n if (typeof storage === 'string') {\n this.config.storage = storage;\n } else {\n this.config.store = storage;\n }\n return this;\n }\n\n public getConfig(): ConfigYaml {\n return this.config;\n }\n\n public getAsYaml(): string {\n return fromJStoYAML(this.config) as string;\n }\n}\n"],"mappings":";;;;;;;;AAkBA,IAAqB,gBAArB,MAAqB,cAAc;CACjC;CAEA,YAAmB,QAA8B;AAC/C,OAAK,SAAS,MAAM,QAAQ;GAAE,SAAS,EAAE;GAAE,UAAU,EAAE;GAAE,UAAU,EAAE;GAAE,CAAC;;CAG1E,OAAc,MAAM,QAA6C;AAC/D,SAAO,IAAI,cAAc,OAAO;;CAGlC,iBAAwB,SAAiB,WAA8B;AAErE,OAAK,OAAO,SAAS,WAAW;AAChC,SAAO;;CAGT,UAAiB,IAAY,QAAoB;AAC/C,OAAK,OAAO,QAAQ,MAAM;AAC1B,SAAO;;CAGT,YAAmB,UAA6B;AAC9C,OAAK,OAAO,WAAW,MAAM,KAAK,OAAO,UAAU,SAAS;AAC5D,SAAO;;CAGT,QAAe,MAAyB;AACtC,OAAK,OAAO,OAAO,MAAM,KAAK,OAAO,MAAM,KAAK;AAChD,SAAO;;CAGT,UAAiB,KAAuB;AACtC,OAAK,OAAO,MAAM;AAClB,SAAO;;CAGT,UAAiB,QAAqC;AACpD,OAAK,OAAO,SAAS,MAAM,KAAK,OAAO,QAAQ,OAAO;AACtD,SAAO;;CAGT,WAAkB,SAA0B;AAC1C,MAAI,OAAO,YAAY,SACrB,MAAK,OAAO,UAAU;MAEtB,MAAK,OAAO,QAAQ;AAEtB,SAAO;;CAGT,YAA+B;AAC7B,SAAO,KAAK;;CAGd,YAA2B;AACzB,SAAO,aAAa,KAAK,OAAO"}
|
|
1
|
+
{"version":3,"file":"builder.mjs","names":[],"sources":["../src/builder.ts"],"sourcesContent":["import { merge } from 'lodash-es';\n\nimport type {\n AuthConf,\n ConfigYaml,\n LoggerConfigItem,\n PackageAccessYaml,\n Security,\n ServerSettingsConf,\n UpLinkConf,\n} from '@verdaccio/types';\n\nimport { fromJStoYAML } from '.';\n\n/**\n * Helper configuration builder constructor, used to build the configuration for testing or\n * programatically creating a configuration.\n */\nexport default class ConfigBuilder {\n private config: ConfigYaml;\n\n public constructor(config?: Partial<ConfigYaml>) {\n this.config = merge(config, { uplinks: {}, packages: {}, security: {} });\n }\n\n public static build(config?: Partial<ConfigYaml>): ConfigBuilder {\n return new ConfigBuilder(config);\n }\n\n public addPackageAccess(pattern: string, pkgAccess: PackageAccessYaml) {\n // @ts-ignore\n this.config.packages[pattern] = pkgAccess;\n return this;\n }\n\n public addUplink(id: string, uplink: UpLinkConf) {\n this.config.uplinks[id] = uplink;\n return this;\n }\n\n public addSecurity(security: Partial<Security>) {\n this.config.security = merge(this.config.security, security);\n return this;\n }\n\n public addAuth(auth: Partial<AuthConf>) {\n this.config.auth = merge(this.config.auth, auth);\n return this;\n }\n\n public addLogger(log: LoggerConfigItem) {\n this.config.log = log;\n return this;\n }\n\n public addServer(server: Partial<ServerSettingsConf>) {\n this.config.server = merge(this.config.server, server);\n return this;\n }\n\n public addStorage(storage: string | object) {\n if (typeof storage === 'string') {\n this.config.storage = storage;\n } else {\n this.config.store = storage;\n }\n return this;\n }\n\n public getConfig(): ConfigYaml {\n return this.config;\n }\n\n public getAsYaml(): string {\n return fromJStoYAML(this.config) as string;\n }\n}\n"],"mappings":";;;;;;;;AAkBA,IAAqB,gBAArB,MAAqB,cAAc;CACjC;CAEA,YAAmB,QAA8B;AAC/C,OAAK,SAAS,MAAM,QAAQ;GAAE,SAAS,EAAE;GAAE,UAAU,EAAE;GAAE,UAAU,EAAE;GAAE,CAAC;;CAG1E,OAAc,MAAM,QAA6C;AAC/D,SAAO,IAAI,cAAc,OAAO;;CAGlC,iBAAwB,SAAiB,WAA8B;AAErE,OAAK,OAAO,SAAS,WAAW;AAChC,SAAO;;CAGT,UAAiB,IAAY,QAAoB;AAC/C,OAAK,OAAO,QAAQ,MAAM;AAC1B,SAAO;;CAGT,YAAmB,UAA6B;AAC9C,OAAK,OAAO,WAAW,MAAM,KAAK,OAAO,UAAU,SAAS;AAC5D,SAAO;;CAGT,QAAe,MAAyB;AACtC,OAAK,OAAO,OAAO,MAAM,KAAK,OAAO,MAAM,KAAK;AAChD,SAAO;;CAGT,UAAiB,KAAuB;AACtC,OAAK,OAAO,MAAM;AAClB,SAAO;;CAGT,UAAiB,QAAqC;AACpD,OAAK,OAAO,SAAS,MAAM,KAAK,OAAO,QAAQ,OAAO;AACtD,SAAO;;CAGT,WAAkB,SAA0B;AAC1C,MAAI,OAAO,YAAY,SACrB,MAAK,OAAO,UAAU;MAEtB,MAAK,OAAO,QAAQ;AAEtB,SAAO;;CAGT,YAA+B;AAC7B,SAAO,KAAK;;CAGd,YAA2B;AACzB,SAAO,aAAa,KAAK,OAAO"}
|
package/build/conf/index.js
CHANGED
|
@@ -2,8 +2,9 @@ require("../_virtual/_rolldown/runtime.js");
|
|
|
2
2
|
const require_parse = require("../parse.js");
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
//#region src/conf/index.ts
|
|
5
|
+
var currentDir = typeof __dirname !== "undefined" ? __dirname : {}.dirname;
|
|
5
6
|
function getDefaultConfig(fileName = "default.yaml") {
|
|
6
|
-
return require_parse.parseConfigFile((0, node_path.join)(
|
|
7
|
+
return require_parse.parseConfigFile((0, node_path.join)(currentDir, `./${fileName}`));
|
|
7
8
|
}
|
|
8
9
|
//#endregion
|
|
9
10
|
exports.getDefaultConfig = getDefaultConfig;
|
package/build/conf/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/conf/index.ts"],"sourcesContent":["import { join } from 'node:path';\n\nimport { parseConfigFile } from '../parse';\n\nexport function getDefaultConfig(fileName: string = 'default.yaml') {\n const file = join(
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/conf/index.ts"],"sourcesContent":["import { join } from 'node:path';\n\nimport { parseConfigFile } from '../parse';\n\nconst currentDir = typeof __dirname !== 'undefined' ? __dirname : import.meta.dirname;\n\nexport function getDefaultConfig(fileName: string = 'default.yaml') {\n const file = join(currentDir, `./${fileName}`);\n return parseConfigFile(file);\n}\n"],"mappings":";;;;AAIA,IAAM,aAAa,OAAO,cAAc,cAAc,YAAA,EAAA,CAAwB;AAE9E,SAAgB,iBAAiB,WAAmB,gBAAgB;AAElE,QAAO,cAAA,iBAAA,GAAA,UAAA,MADW,YAAY,KAAK,WAAW,CAClB"}
|
package/build/conf/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { parseConfigFile } from "../parse.mjs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
//#region src/conf/index.ts
|
|
4
|
+
var currentDir = typeof __dirname !== "undefined" ? __dirname : import.meta.dirname;
|
|
4
5
|
function getDefaultConfig(fileName = "default.yaml") {
|
|
5
|
-
return parseConfigFile(join(
|
|
6
|
+
return parseConfigFile(join(currentDir, `./${fileName}`));
|
|
6
7
|
}
|
|
7
8
|
//#endregion
|
|
8
9
|
export { getDefaultConfig };
|
package/build/conf/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/conf/index.ts"],"sourcesContent":["import { join } from 'node:path';\n\nimport { parseConfigFile } from '../parse';\n\nexport function getDefaultConfig(fileName: string = 'default.yaml') {\n const file = join(
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/conf/index.ts"],"sourcesContent":["import { join } from 'node:path';\n\nimport { parseConfigFile } from '../parse';\n\nconst currentDir = typeof __dirname !== 'undefined' ? __dirname : import.meta.dirname;\n\nexport function getDefaultConfig(fileName: string = 'default.yaml') {\n const file = join(currentDir, `./${fileName}`);\n return parseConfigFile(file);\n}\n"],"mappings":";;;AAIA,IAAM,aAAa,OAAO,cAAc,cAAc,YAAY,OAAO,KAAK;AAE9E,SAAgB,iBAAiB,WAAmB,gBAAgB;AAElE,QAAO,gBADM,KAAK,YAAY,KAAK,WAAW,CAClB"}
|
package/build/config-path.js
CHANGED
|
@@ -2,8 +2,7 @@ const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
|
2
2
|
const require_config_utils = require("./config-utils.js");
|
|
3
3
|
let debug = require("debug");
|
|
4
4
|
debug = require_runtime.__toESM(debug);
|
|
5
|
-
let
|
|
6
|
-
lodash = require_runtime.__toESM(lodash);
|
|
5
|
+
let lodash_es = require("lodash-es");
|
|
7
6
|
let node_fs = require("node:fs");
|
|
8
7
|
node_fs = require_runtime.__toESM(node_fs);
|
|
9
8
|
let node_os = require("node:os");
|
|
@@ -32,7 +31,7 @@ function findConfigFile(configPath) {
|
|
|
32
31
|
debug$1("no configuration files can be processed");
|
|
33
32
|
throw new Error("no configuration files can be processed");
|
|
34
33
|
}
|
|
35
|
-
const primaryConf =
|
|
34
|
+
const primaryConf = (0, lodash_es.find)(configPaths, (configLocation) => require_config_utils.fileExists(configLocation.path));
|
|
36
35
|
if (typeof primaryConf !== "undefined") {
|
|
37
36
|
debug$1("at least one primary location detected at %s", primaryConf?.path);
|
|
38
37
|
return primaryConf.path;
|
|
@@ -48,7 +47,8 @@ function createConfigFile(configLocation) {
|
|
|
48
47
|
return configLocation;
|
|
49
48
|
}
|
|
50
49
|
function readDefaultConfig() {
|
|
51
|
-
const
|
|
50
|
+
const currentDir = typeof __dirname !== "undefined" ? __dirname : {}.dirname;
|
|
51
|
+
const pathDefaultConf = node_path.default.resolve(currentDir, "conf/default.yaml");
|
|
52
52
|
try {
|
|
53
53
|
debug$1("the path of default config used from %s", pathDefaultConf);
|
|
54
54
|
node_fs.default.accessSync(pathDefaultConf, node_fs.default.constants.R_OK);
|
package/build/config-path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-path.js","names":[],"sources":["../src/config-path.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport
|
|
1
|
+
{"version":3,"file":"config-path.js","names":[],"sources":["../src/config-path.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { find } from 'lodash-es';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { fileExists, folderExists } from './config-utils';\n\nconst CONFIG_FILE = 'config.yaml';\nconst XDG = 'xdg';\n\nconst pkgJSON = {\n name: 'verdaccio',\n};\n\nexport type SetupDirectory = {\n path: string;\n type: 'xdg' | 'win' | 'win32' | 'def' | 'old';\n};\n\nconst debug = buildDebug('verdaccio:config:config-path');\n\n/**\n * Find and get the first config file that match.\n * @return {String} the config file path\n */\nfunction findConfigFile(configPath?: string): string {\n debug('searching for config file %o', configPath);\n if (typeof configPath !== 'undefined') {\n const configLocation = path.resolve(configPath);\n debug('custom location %s', configLocation);\n return configLocation;\n }\n\n const configPaths: SetupDirectory[] = getConfigPaths();\n debug('%o posible locations found', configPaths.length);\n if (configPaths.length === 0) {\n debug('no configuration files can be processed');\n // this should never happens\n throw new Error('no configuration files can be processed');\n }\n\n // find the first location that already exist\n const primaryConf: SetupDirectory | void = find(configPaths, (configLocation: SetupDirectory) =>\n fileExists(configLocation.path)\n );\n\n if (typeof primaryConf !== 'undefined') {\n debug('at least one primary location detected at %s', primaryConf?.path);\n return primaryConf.path;\n }\n debug('no previous location found, creating a new one');\n debug('generating the first match path location %s', configPaths[0].path);\n return createConfigFile(configPaths[0]).path;\n}\n\nfunction createConfigFile(configLocation: SetupDirectory): SetupDirectory {\n createConfigFolder(configLocation);\n\n const defaultConfig = updateStorageLinks(configLocation, readDefaultConfig());\n\n fs.writeFileSync(configLocation.path, defaultConfig);\n\n return configLocation;\n}\n\nexport function readDefaultConfig(): string {\n const currentDir = typeof __dirname !== 'undefined' ? __dirname : import.meta.dirname;\n const pathDefaultConf: string = path.resolve(currentDir, 'conf/default.yaml');\n try {\n debug('the path of default config used from %s', pathDefaultConf);\n fs.accessSync(pathDefaultConf, fs.constants.R_OK);\n debug('configuration file has enough permissions for reading');\n } catch {\n debug('configuration file does not have enough permissions for reading');\n throw new TypeError('configuration file does not have enough permissions for reading');\n }\n\n return fs.readFileSync(pathDefaultConf, 'utf8');\n}\n\nfunction createConfigFolder(configLocation: SetupDirectory): void {\n const folder = path.dirname(configLocation.path);\n debug(`creating default config file folder at %o`, folder);\n fs.mkdirSync(folder, { recursive: true });\n debug(`folder %o created`, folder);\n}\n\n/**\n * Update the storage links to the new location if it is necessary.\n * @param configLocation\n * @param defaultConfig\n * @returns\n */\nfunction updateStorageLinks(configLocation: SetupDirectory, defaultConfig: string): string {\n debug('checking storage links for %s and type %s', configLocation.path, configLocation.type);\n if (configLocation.type !== XDG) {\n debug(`skip storage override for %s`, configLocation.type);\n return defaultConfig;\n }\n\n // $XDG_DATA_HOME defines the base directory relative to which user specific data\n // files should be stored, If $XDG_DATA_HOME is either not set or empty, a default\n // equal to $HOME/.local/share should be used.\n let dataDir =\n process.env.XDG_DATA_HOME || path.join(process.env.HOME as string, '.local', 'share');\n if (folderExists(dataDir)) {\n debug(`previous storage located`);\n debug(`update storage links to %s`, dataDir);\n dataDir = path.resolve(path.join(dataDir, pkgJSON.name, 'storage'));\n return defaultConfig.replace(/^storage: .\\/storage$/m, `storage: ${dataDir}`);\n }\n debug(`could not find a previous storage location, skip override`);\n return defaultConfig;\n}\n\n/**\n * Return a list of configuration locations by platform.\n * @returns\n */\nfunction getConfigPaths(): SetupDirectory[] {\n const listPaths: (SetupDirectory | void)[] = [\n getXDGDirectory(),\n getWindowsDirectory(),\n getRelativeDefaultDirectory(),\n getOldDirectory(),\n ];\n\n return listPaths.reduce(function (acc, currentValue: SetupDirectory | void): SetupDirectory[] {\n if (typeof currentValue !== 'undefined') {\n debug(\n 'posible directory path generated %s for type %s',\n currentValue?.path,\n currentValue.type\n );\n acc.push(currentValue);\n }\n return acc;\n }, [] as SetupDirectory[]);\n}\n\n/**\n * Get XDG_CONFIG_HOME or HOME location (usually unix)\n *\n * The XDG_CONFIG_HOME environment variable is also part of the XDG Base Directory Specification,\n * which aims to standardize the locations where applications store configuration files and other\n * user-specific data on Unix-like operating systems.\n *\n *\n *\n * https://specifications.freedesktop.org/basedir-spec/latest/\n *\n *\n * @returns\n */\nconst getXDGDirectory = (): SetupDirectory | void => {\n const xDGConfigPath =\n process.env.XDG_CONFIG_HOME || (process.env.HOME && path.join(process.env.HOME, '.config'));\n debug('XDGConfig folder path %s', xDGConfigPath);\n if (xDGConfigPath && folderExists(xDGConfigPath)) {\n debug('XDGConfig folder path %s', xDGConfigPath);\n return {\n path: path.join(xDGConfigPath, pkgJSON.name, CONFIG_FILE),\n type: XDG,\n };\n }\n};\n\n/**\n * Detect windows location, APPDATA\n * usually something like C:\\User\\<Build User>\\AppData\\Local\n * @returns\n */\nconst getWindowsDirectory = (): SetupDirectory | void => {\n if (os.platform() === 'win32' && process.env.APPDATA && folderExists(process.env.APPDATA)) {\n debug('windows appdata folder path %s', process.env.APPDATA);\n return {\n path: path.resolve(path.join(process.env.APPDATA, pkgJSON.name, CONFIG_FILE)),\n type: 'win',\n };\n }\n};\n\n/**\n * Return relative directory, this is the default.\n * It will cretate config in your {currentLocation/verdaccio/config.yaml}\n * @returns\n */\nconst getRelativeDefaultDirectory = (): SetupDirectory => {\n const relativePath = path.resolve(path.join('.', pkgJSON.name, CONFIG_FILE));\n debug('relative folder path %s', relativePath);\n return {\n path: relativePath,\n type: 'def',\n };\n};\n\n/**\n * This should never happens, consider it DEPRECATED\n * @returns\n */\nconst getOldDirectory = (): SetupDirectory => {\n const oldPath = path.resolve(path.join('.', CONFIG_FILE));\n debug('old folder path %s', oldPath);\n return {\n path: oldPath,\n type: 'old',\n };\n};\n\nexport { findConfigFile };\n"],"mappings":";;;;;;;;;;;;AAQA,IAAM,cAAc;AACpB,IAAM,MAAM;AAEZ,IAAM,UAAU,EACd,MAAM,aACP;AAOD,IAAM,WAAA,GAAA,MAAA,SAAmB,+BAA+B;;;;;AAMxD,SAAS,eAAe,YAA6B;AACnD,SAAM,gCAAgC,WAAW;AACjD,KAAI,OAAO,eAAe,aAAa;EACrC,MAAM,iBAAiB,UAAA,QAAK,QAAQ,WAAW;AAC/C,UAAM,sBAAsB,eAAe;AAC3C,SAAO;;CAGT,MAAM,cAAgC,gBAAgB;AACtD,SAAM,8BAA8B,YAAY,OAAO;AACvD,KAAI,YAAY,WAAW,GAAG;AAC5B,UAAM,0CAA0C;AAEhD,QAAM,IAAI,MAAM,0CAA0C;;CAI5D,MAAM,eAAA,GAAA,UAAA,MAA0C,cAAc,mBAC5D,qBAAA,WAAW,eAAe,KAAK,CAChC;AAED,KAAI,OAAO,gBAAgB,aAAa;AACtC,UAAM,gDAAgD,aAAa,KAAK;AACxE,SAAO,YAAY;;AAErB,SAAM,iDAAiD;AACvD,SAAM,gDAAgD,YAAY,GAAG,KAAK;AAC1E,QAAO,iBAAiB,YAAY,GAAG,CAAC;;AAG1C,SAAS,iBAAiB,gBAAgD;AACxE,oBAAmB,eAAe;CAElC,MAAM,gBAAgB,mBAAmB,gBAAgB,mBAAmB,CAAC;AAE7E,SAAA,QAAG,cAAc,eAAe,MAAM,cAAc;AAEpD,QAAO;;AAGT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E,mDACA,cAAc,MACd,aAAa,KACd;AACD,OAAI,KAAK,aAAa;;AAExB,SAAO;IACN,EAAE,CAAqB;;;;;;;;;;;;;;;;AAiB5B,IAAM,wBAA+C;CACnD,MAAM,gBACJ,QAAQ,IAAI,mBAAoB,QAAQ,IAAI,QAAQ,UAAA,QAAK,KAAK,QAAQ,IAAI,MAAM,UAAU;AAC5F,SAAM,4BAA4B,cAAc;AAChD,KAAI,iBAAiB,qBAAA,aAAa,cAAc,EAAE;AAChD,UAAM,4BAA4B,cAAc;AAChD,SAAO;GACL,MAAM,UAAA,QAAK,KAAK,eAAe,QAAQ,MAAM,YAAY;GACzD,MAAM;GACP;;;;;;;;AASL,IAAM,4BAAmD;AACvD,KAAI,QAAA,QAAG,UAAU,KAAK,WAAW,QAAQ,IAAI,WAAW,qBAAA,aAAa,QAAQ,IAAI,QAAQ,EAAE;AACzF,UAAM,kCAAkC,QAAQ,IAAI,QAAQ;AAC5D,SAAO;GACL,MAAM,UAAA,QAAK,QAAQ,UAAA,QAAK,KAAK,QAAQ,IAAI,SAAS,QAAQ,MAAM,YAAY,CAAC;GAC7E,MAAM;GACP;;;;;;;;AASL,IAAM,oCAAoD;CACxD,MAAM,eAAe,UAAA,QAAK,QAAQ,UAAA,QAAK,KAAK,KAAK,QAAQ,MAAM,YAAY,CAAC;AAC5E,SAAM,2BAA2B,aAAa;AAC9C,QAAO;EACL,MAAM;EACN,MAAM;EACP;;;;;;AAOH,IAAM,wBAAwC;CAC5C,MAAM,UAAU,UAAA,QAAK,QAAQ,UAAA,QAAK,KAAK,KAAK,YAAY,CAAC;AACzD,SAAM,sBAAsB,QAAQ;AACpC,QAAO;EACL,MAAM;EACN,MAAM;EACP"}
|
package/build/config-path.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fileExists, folderExists } from "./config-utils.mjs";
|
|
2
2
|
import buildDebug from "debug";
|
|
3
|
-
import
|
|
3
|
+
import { find } from "lodash-es";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
import path from "node:path";
|
|
@@ -26,7 +26,7 @@ function findConfigFile(configPath) {
|
|
|
26
26
|
debug("no configuration files can be processed");
|
|
27
27
|
throw new Error("no configuration files can be processed");
|
|
28
28
|
}
|
|
29
|
-
const primaryConf =
|
|
29
|
+
const primaryConf = find(configPaths, (configLocation) => fileExists(configLocation.path));
|
|
30
30
|
if (typeof primaryConf !== "undefined") {
|
|
31
31
|
debug("at least one primary location detected at %s", primaryConf?.path);
|
|
32
32
|
return primaryConf.path;
|
|
@@ -42,7 +42,8 @@ function createConfigFile(configLocation) {
|
|
|
42
42
|
return configLocation;
|
|
43
43
|
}
|
|
44
44
|
function readDefaultConfig() {
|
|
45
|
-
const
|
|
45
|
+
const currentDir = typeof __dirname !== "undefined" ? __dirname : import.meta.dirname;
|
|
46
|
+
const pathDefaultConf = path.resolve(currentDir, "conf/default.yaml");
|
|
46
47
|
try {
|
|
47
48
|
debug("the path of default config used from %s", pathDefaultConf);
|
|
48
49
|
fs.accessSync(pathDefaultConf, fs.constants.R_OK);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-path.mjs","names":[],"sources":["../src/config-path.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport
|
|
1
|
+
{"version":3,"file":"config-path.mjs","names":[],"sources":["../src/config-path.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { find } from 'lodash-es';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { fileExists, folderExists } from './config-utils';\n\nconst CONFIG_FILE = 'config.yaml';\nconst XDG = 'xdg';\n\nconst pkgJSON = {\n name: 'verdaccio',\n};\n\nexport type SetupDirectory = {\n path: string;\n type: 'xdg' | 'win' | 'win32' | 'def' | 'old';\n};\n\nconst debug = buildDebug('verdaccio:config:config-path');\n\n/**\n * Find and get the first config file that match.\n * @return {String} the config file path\n */\nfunction findConfigFile(configPath?: string): string {\n debug('searching for config file %o', configPath);\n if (typeof configPath !== 'undefined') {\n const configLocation = path.resolve(configPath);\n debug('custom location %s', configLocation);\n return configLocation;\n }\n\n const configPaths: SetupDirectory[] = getConfigPaths();\n debug('%o posible locations found', configPaths.length);\n if (configPaths.length === 0) {\n debug('no configuration files can be processed');\n // this should never happens\n throw new Error('no configuration files can be processed');\n }\n\n // find the first location that already exist\n const primaryConf: SetupDirectory | void = find(configPaths, (configLocation: SetupDirectory) =>\n fileExists(configLocation.path)\n );\n\n if (typeof primaryConf !== 'undefined') {\n debug('at least one primary location detected at %s', primaryConf?.path);\n return primaryConf.path;\n }\n debug('no previous location found, creating a new one');\n debug('generating the first match path location %s', configPaths[0].path);\n return createConfigFile(configPaths[0]).path;\n}\n\nfunction createConfigFile(configLocation: SetupDirectory): SetupDirectory {\n createConfigFolder(configLocation);\n\n const defaultConfig = updateStorageLinks(configLocation, readDefaultConfig());\n\n fs.writeFileSync(configLocation.path, defaultConfig);\n\n return configLocation;\n}\n\nexport function readDefaultConfig(): string {\n const currentDir = typeof __dirname !== 'undefined' ? __dirname : import.meta.dirname;\n const pathDefaultConf: string = path.resolve(currentDir, 'conf/default.yaml');\n try {\n debug('the path of default config used from %s', pathDefaultConf);\n fs.accessSync(pathDefaultConf, fs.constants.R_OK);\n debug('configuration file has enough permissions for reading');\n } catch {\n debug('configuration file does not have enough permissions for reading');\n throw new TypeError('configuration file does not have enough permissions for reading');\n }\n\n return fs.readFileSync(pathDefaultConf, 'utf8');\n}\n\nfunction createConfigFolder(configLocation: SetupDirectory): void {\n const folder = path.dirname(configLocation.path);\n debug(`creating default config file folder at %o`, folder);\n fs.mkdirSync(folder, { recursive: true });\n debug(`folder %o created`, folder);\n}\n\n/**\n * Update the storage links to the new location if it is necessary.\n * @param configLocation\n * @param defaultConfig\n * @returns\n */\nfunction updateStorageLinks(configLocation: SetupDirectory, defaultConfig: string): string {\n debug('checking storage links for %s and type %s', configLocation.path, configLocation.type);\n if (configLocation.type !== XDG) {\n debug(`skip storage override for %s`, configLocation.type);\n return defaultConfig;\n }\n\n // $XDG_DATA_HOME defines the base directory relative to which user specific data\n // files should be stored, If $XDG_DATA_HOME is either not set or empty, a default\n // equal to $HOME/.local/share should be used.\n let dataDir =\n process.env.XDG_DATA_HOME || path.join(process.env.HOME as string, '.local', 'share');\n if (folderExists(dataDir)) {\n debug(`previous storage located`);\n debug(`update storage links to %s`, dataDir);\n dataDir = path.resolve(path.join(dataDir, pkgJSON.name, 'storage'));\n return defaultConfig.replace(/^storage: .\\/storage$/m, `storage: ${dataDir}`);\n }\n debug(`could not find a previous storage location, skip override`);\n return defaultConfig;\n}\n\n/**\n * Return a list of configuration locations by platform.\n * @returns\n */\nfunction getConfigPaths(): SetupDirectory[] {\n const listPaths: (SetupDirectory | void)[] = [\n getXDGDirectory(),\n getWindowsDirectory(),\n getRelativeDefaultDirectory(),\n getOldDirectory(),\n ];\n\n return listPaths.reduce(function (acc, currentValue: SetupDirectory | void): SetupDirectory[] {\n if (typeof currentValue !== 'undefined') {\n debug(\n 'posible directory path generated %s for type %s',\n currentValue?.path,\n currentValue.type\n );\n acc.push(currentValue);\n }\n return acc;\n }, [] as SetupDirectory[]);\n}\n\n/**\n * Get XDG_CONFIG_HOME or HOME location (usually unix)\n *\n * The XDG_CONFIG_HOME environment variable is also part of the XDG Base Directory Specification,\n * which aims to standardize the locations where applications store configuration files and other\n * user-specific data on Unix-like operating systems.\n *\n *\n *\n * https://specifications.freedesktop.org/basedir-spec/latest/\n *\n *\n * @returns\n */\nconst getXDGDirectory = (): SetupDirectory | void => {\n const xDGConfigPath =\n process.env.XDG_CONFIG_HOME || (process.env.HOME && path.join(process.env.HOME, '.config'));\n debug('XDGConfig folder path %s', xDGConfigPath);\n if (xDGConfigPath && folderExists(xDGConfigPath)) {\n debug('XDGConfig folder path %s', xDGConfigPath);\n return {\n path: path.join(xDGConfigPath, pkgJSON.name, CONFIG_FILE),\n type: XDG,\n };\n }\n};\n\n/**\n * Detect windows location, APPDATA\n * usually something like C:\\User\\<Build User>\\AppData\\Local\n * @returns\n */\nconst getWindowsDirectory = (): SetupDirectory | void => {\n if (os.platform() === 'win32' && process.env.APPDATA && folderExists(process.env.APPDATA)) {\n debug('windows appdata folder path %s', process.env.APPDATA);\n return {\n path: path.resolve(path.join(process.env.APPDATA, pkgJSON.name, CONFIG_FILE)),\n type: 'win',\n };\n }\n};\n\n/**\n * Return relative directory, this is the default.\n * It will cretate config in your {currentLocation/verdaccio/config.yaml}\n * @returns\n */\nconst getRelativeDefaultDirectory = (): SetupDirectory => {\n const relativePath = path.resolve(path.join('.', pkgJSON.name, CONFIG_FILE));\n debug('relative folder path %s', relativePath);\n return {\n path: relativePath,\n type: 'def',\n };\n};\n\n/**\n * This should never happens, consider it DEPRECATED\n * @returns\n */\nconst getOldDirectory = (): SetupDirectory => {\n const oldPath = path.resolve(path.join('.', CONFIG_FILE));\n debug('old folder path %s', oldPath);\n return {\n path: oldPath,\n type: 'old',\n };\n};\n\nexport { findConfigFile };\n"],"mappings":";;;;;;;AAQA,IAAM,cAAc;AACpB,IAAM,MAAM;AAEZ,IAAM,UAAU,EACd,MAAM,aACP;AAOD,IAAM,QAAQ,WAAW,+BAA+B;;;;;AAMxD,SAAS,eAAe,YAA6B;AACnD,OAAM,gCAAgC,WAAW;AACjD,KAAI,OAAO,eAAe,aAAa;EACrC,MAAM,iBAAiB,KAAK,QAAQ,WAAW;AAC/C,QAAM,sBAAsB,eAAe;AAC3C,SAAO;;CAGT,MAAM,cAAgC,gBAAgB;AACtD,OAAM,8BAA8B,YAAY,OAAO;AACvD,KAAI,YAAY,WAAW,GAAG;AAC5B,QAAM,0CAA0C;AAEhD,QAAM,IAAI,MAAM,0CAA0C;;CAI5D,MAAM,cAAqC,KAAK,cAAc,mBAC5D,WAAW,eAAe,KAAK,CAChC;AAED,KAAI,OAAO,gBAAgB,aAAa;AACtC,QAAM,gDAAgD,aAAa,KAAK;AACxE,SAAO,YAAY;;AAErB,OAAM,iDAAiD;AACvD,OAAM,gD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("./uplinks.js");
|
|
8
8
|
let debug = require("debug");
|
|
9
9
|
debug = require_runtime.__toESM(debug);
|
|
10
|
-
let
|
|
11
|
-
lodash = require_runtime.__toESM(lodash);
|
|
10
|
+
let lodash_es = require("lodash-es");
|
|
12
11
|
let node_assert = require("node:assert");
|
|
13
12
|
node_assert = require_runtime.__toESM(node_assert);
|
|
14
13
|
let _verdaccio_core = require("@verdaccio/core");
|
|
@@ -60,7 +59,7 @@ var Config = class {
|
|
|
60
59
|
this.self_path = this.configPath;
|
|
61
60
|
debug$1("config path: %s", this.configPath);
|
|
62
61
|
this.plugins = config.plugins;
|
|
63
|
-
this.security =
|
|
62
|
+
this.security = (0, lodash_es.merge)(require_security.defaultSecurity, config.security);
|
|
64
63
|
this.server = {
|
|
65
64
|
...require_serverSettings.default,
|
|
66
65
|
...config.server
|
|
@@ -113,7 +112,7 @@ var Config = class {
|
|
|
113
112
|
*/
|
|
114
113
|
checkSecretKey(secret) {
|
|
115
114
|
debug$1("checking secret key init");
|
|
116
|
-
if (typeof secret === "string" &&
|
|
115
|
+
if (typeof secret === "string" && (0, lodash_es.isEmpty)(secret) === false) {
|
|
117
116
|
debug$1("checking secret key length %s", secret.length);
|
|
118
117
|
if (secret.length !== TOKEN_VALID_LENGTH) throw new Error(`Invalid storage secret key length, must be ${TOKEN_VALID_LENGTH} characters long but is ${secret.length}. Please generate a new one. Learn more at https://verdaccio.org/docs/configuration/#.verdaccio-db`);
|
|
119
118
|
debug$1("detected valid secret key length %s", secret.length);
|
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport
|
|
1
|
+
{"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { isEmpty, merge } from 'lodash-es';\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\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 // @ts-ignore\n public secret: string;\n public flags: FlagsConfig;\n public userRateLimit: RateLimit;\n public constructor(config: ConfigYaml & { config_path: string }) {\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.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(defaultSecurity, config.security);\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 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 * The secret must be exactly 32 characters long for aes-256-ctr encryption.\n * If no secret is provided, a new one will be generated.\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 throw new Error(\n `Invalid storage secret key length, must be ${TOKEN_VALID_LENGTH} characters long but is ${secret.length}. ` +\n `Please generate a new one. Learn more at https://verdaccio.org/docs/configuration/#.verdaccio-db`\n );\n }\n debug('detected valid secret key length %s', secret.length);\n this.secret = secret;\n return this.secret;\n } else {\n debug('generating a new secret key');\n this.secret = generateRandomSecretKey();\n debug('generated a new secret key length %s', this.secret?.length);\n return this.secret;\n }\n }\n}\n\nexport { Config };\n"],"mappings":";;;;;;;;;;;;;;AAwBA,IAAM,uBAAuB,CAAC,WAAW,WAAW;AACpD,IAAM,mBAAmB;CAAC;CAAc;CAAe;CAAW;AAClE,IAAM,WAAA,GAAA,MAAA,SAAmB,mBAAmB;AAE5C,IAAa,YAAY;AAGzB,IAAa,0BAA0B;CACrC,UAAU,MAAU;CACpB,KAAK;CACN;AAED,IAAM,qBAAqB;;;;AAK3B,IAAM,SAAN,MAAkC;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;;CAIA;CACA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA,YAAmB,QAA8C;EAC/D,MAAM,OAAO;AACb,OAAK,UAAU,QAAQ,IAAI,0BAA0B,OAAO;AAC5D,MAAI,CAAC,OAAO,YAAY;AAGtB,UAAO,aAAa,OAAO,eAAe,OAAO;AACjD,OAAI,CAAC,OAAO,WACV,OAAM,IAAI,MAAM,kCAAkC;;AAGtD,OAAK,aAAa,OAAO;AACzB,OAAK,YAAY,KAAK;AACtB,UAAM,mBAAmB,KAAK,WAAW;AACzC,OAAK,UAAU,OAAO;AACtB,OAAK,YAAA,GAAA,UAAA,OAAiB,iBAAA,iBAAiB,OAAO,SAAS;AACvD,OAAK,SAAS;GAAE,GAAG,uBAAA;GAAuB,GAAG,OAAO;GAAQ;AAC5D,OAAK,QAAQ;GACX,cAAc,OAAO,OAAO,gBAAgB;GAC5C,gBAAgB,OAAO,OAAO,kBAAkB;GAChD,UAAU,OAAO,OAAO,YAAY;GACpC,YAAY,OAAO,OAAO,cAAc;GACzC;AACD,OAAK,aAAa,OAAO;AAEzB,OAAK,M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WAAM,8BAA8B;AACpC,QAAK,SAAS,cAAA,yBAAyB;AACvC,WAAM,wCAAwC,KAAK,QAAQ,OAAO;AAClE,UAAO,KAAK"}
|
package/build/config.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import serverSettings_default from "./serverSettings.mjs";
|
|
|
5
5
|
import { generateRandomSecretKey } from "./token.mjs";
|
|
6
6
|
import { sanityCheckUplinksProps, uplinkSanityCheck } from "./uplinks.mjs";
|
|
7
7
|
import buildDebug from "debug";
|
|
8
|
-
import
|
|
8
|
+
import { isEmpty, merge } from "lodash-es";
|
|
9
9
|
import assert from "node:assert";
|
|
10
10
|
import { APP_ERROR, authUtils, cryptoUtils, validationUtils } from "@verdaccio/core";
|
|
11
11
|
//#region src/config.ts
|
|
@@ -56,7 +56,7 @@ var Config = class {
|
|
|
56
56
|
this.self_path = this.configPath;
|
|
57
57
|
debug("config path: %s", this.configPath);
|
|
58
58
|
this.plugins = config.plugins;
|
|
59
|
-
this.security =
|
|
59
|
+
this.security = merge(defaultSecurity, config.security);
|
|
60
60
|
this.server = {
|
|
61
61
|
...serverSettings_default,
|
|
62
62
|
...config.server
|
|
@@ -109,7 +109,7 @@ var Config = class {
|
|
|
109
109
|
*/
|
|
110
110
|
checkSecretKey(secret) {
|
|
111
111
|
debug("checking secret key init");
|
|
112
|
-
if (typeof secret === "string" &&
|
|
112
|
+
if (typeof secret === "string" && isEmpty(secret) === false) {
|
|
113
113
|
debug("checking secret key length %s", secret.length);
|
|
114
114
|
if (secret.length !== TOKEN_VALID_LENGTH) throw new Error(`Invalid storage secret key length, must be ${TOKEN_VALID_LENGTH} characters long but is ${secret.length}. Please generate a new one. Learn more at https://verdaccio.org/docs/configuration/#.verdaccio-db`);
|
|
115
115
|
debug("detected valid secret key length %s", secret.length);
|
package/build/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { isEmpty, merge } from 'lodash-es';\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\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 // @ts-ignore\n public secret: string;\n public flags: FlagsConfig;\n public userRateLimit: RateLimit;\n public constructor(config: ConfigYaml & { config_path: string }) {\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.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(defaultSecurity, config.security);\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 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 * The secret must be exactly 32 characters long for aes-256-ctr encryption.\n * If no secret is provided, a new one will be generated.\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 throw new Error(\n `Invalid storage secret key length, must be ${TOKEN_VALID_LENGTH} characters long but is ${secret.length}. ` +\n `Please generate a new one. Learn more at https://verdaccio.org/docs/configuration/#.verdaccio-db`\n );\n }\n debug('detected valid secret key length %s', secret.length);\n this.secret = secret;\n return this.secret;\n } else {\n debug('generating a new secret key');\n this.secret = generateRandomSecretKey();\n debug('generated a new secret key length %s', this.secret?.length);\n return this.secret;\n }\n }\n}\n\nexport { Config };\n"],"mappings":";;;;;;;;;;;AAwBA,IAAM,uBAAuB,CAAC,WAAW,WAAW;AACpD,IAAM,mBAAmB;CAAC;CAAc;CAAe;CAAW;AAClE,IAAM,QAAQ,WAAW,mBAAmB;AAE5C,IAAa,YAAY;AAGzB,IAAa,0BAA0B;CACrC,UAAU,MAAU;CACpB,KAAK;CACN;AAED,IAAM,qBAAqB;;;;AAK3B,IAAM,SAAN,MAAkC;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;;CAIA;CACA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA,YAAmB,QAA8C;EAC/D,MAAM,OAAO;AACb,OAAK,UAAU,QAAQ,IAAI,0BAA0B,OAAO;AAC5D,MAAI,CAAC,OAAO,YAAY;AAGtB,UAAO,aAAa,OAAO,eAAe,OAAO;AACjD,OAAI,CAAC,OAAO,WACV,OAAM,IAAI,MAAM,kCAAkC;;AAGtD,OAAK,aAAa,OAAO;AACzB,OAAK,YAAY,KAAK;AACtB,QAAM,mBAAmB,KAAK,WAAW;AACzC,OAAK,UAAU,OAAO;AACtB,OAAK,WAAW,MAAM,iBAAiB,OAAO,SAAS;AACvD,OAAK,SAAS;GAAE,GAAG;GAAuB,GAAG,OAAO;GAAQ;AAC5D,OAAK,QAAQ;GACX,cAAc,OAAO,OAAO,gBAAgB;GAC5C,g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AO,KAAK;SACP;AACL,SAAM,8BAA8B;AACpC,QAAK,SAAS,yBAAyB;AACvC,SAAM,wCAAwC,KAAK,QAAQ,OAAO;AAClE,UAAO,KAAK"}
|
package/build/package-access.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
2
|
let debug = require("debug");
|
|
3
3
|
debug = require_runtime.__toESM(debug);
|
|
4
|
-
let
|
|
5
|
-
lodash = require_runtime.__toESM(lodash);
|
|
4
|
+
let lodash_es = require("lodash-es");
|
|
6
5
|
let node_assert = require("node:assert");
|
|
7
6
|
node_assert = require_runtime.__toESM(node_assert);
|
|
8
7
|
let _verdaccio_core = require("@verdaccio/core");
|
|
@@ -23,17 +22,17 @@ var PACKAGE_ACCESS = {
|
|
|
23
22
|
};
|
|
24
23
|
function normalizeUserList(groupsList) {
|
|
25
24
|
const result = [];
|
|
26
|
-
if (
|
|
27
|
-
if (
|
|
25
|
+
if ((0, lodash_es.isNil)(groupsList) || (0, lodash_es.isEmpty)(groupsList)) return result;
|
|
26
|
+
if (typeof groupsList === "string") {
|
|
28
27
|
const groupsArray = groupsList.split(/\s+/);
|
|
29
28
|
result.push(groupsArray);
|
|
30
29
|
} else if (Array.isArray(groupsList)) result.push(groupsList);
|
|
31
30
|
else throw _verdaccio_core.errorUtils.getInternalError("CONFIG: bad package acl (array or string expected): " + JSON.stringify(groupsList));
|
|
32
|
-
return
|
|
31
|
+
return (0, lodash_es.flatten)(result);
|
|
33
32
|
}
|
|
34
33
|
function normalisePackageAccess(packages) {
|
|
35
34
|
const normalizedPkgs = { ...packages };
|
|
36
|
-
if (
|
|
35
|
+
if ((0, lodash_es.isNil)(normalizedPkgs["**"])) normalizedPkgs["**"] = {
|
|
37
36
|
access: [],
|
|
38
37
|
publish: [],
|
|
39
38
|
unpublish: [],
|
|
@@ -42,11 +41,11 @@ function normalisePackageAccess(packages) {
|
|
|
42
41
|
for (const pkg in packages) if (Object.prototype.hasOwnProperty.call(packages, pkg)) {
|
|
43
42
|
const packageAccess = packages[pkg];
|
|
44
43
|
debug$1("package access %s for %s ", packageAccess, pkg);
|
|
45
|
-
(0, node_assert.default)(
|
|
44
|
+
(0, node_assert.default)((0, lodash_es.isObject)(packageAccess) && !Array.isArray(packageAccess), `CONFIG: bad "'${pkg}'" package description (object expected)`);
|
|
46
45
|
normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);
|
|
47
46
|
normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);
|
|
48
47
|
normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);
|
|
49
|
-
normalizedPkgs[pkg].unpublish =
|
|
48
|
+
normalizedPkgs[pkg].unpublish = (0, lodash_es.isUndefined)(packageAccess.unpublish) ? false : normalizeUserList(packageAccess.unpublish);
|
|
50
49
|
}
|
|
51
50
|
return normalizedPkgs;
|
|
52
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-access.js","names":[],"sources":["../src/package-access.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport
|
|
1
|
+
{"version":3,"file":"package-access.js","names":[],"sources":["../src/package-access.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { flatten, isEmpty, isNil, isObject, isUndefined } from 'lodash-es';\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 (typeof groupsList === 'string') {\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) && !Array.isArray(packageAccess);\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,yBAAyB;AAOlD,IAAa,QAAQ;CACnB,MAAM;CACN,KAAK;CACL,OAAO;CACP,YAAY;CACZ,gBAAgB;CAChB,iBAAiB;CACjB,sBAAsB;CACvB;AAGD,IAAa,iBAAiB;CAC5B,OAAO;CACP,KAAK;CACN;AAED,SAAgB,kBAAkB,YAAsB;CACtD,MAAM,SAAgB,EAAE;AACxB,MAAA,GAAA,UAAA,OAAU,WAAW,KAAA,GAAA,UAAA,SAAY,WAAW,CAC1C,QAAO;AAIT,KAAI,OAAO,eAAe,UAAU;EAClC,MAAM,cAAc,WAAW,MAAM,MAAM;AAE3C,SAAO,KAAK,YAAY;YACf,MAAM,QAAQ,WAAW,CAClC,QAAO,KAAK,WAAW;KAEvB,OAAM,gBAAA,WAAW,iBACf,yDAAyD,KAAK,UAAU,WAAW,CACpF;AAGH,SAAA,GAAA,UAAA,SAAe,OAAO;;AAGxB,SAAgB,uBAAuB,UAAgD;CACrF,MAAM,iBAAoC,EAAE,GAAG,UAAU;AACzD,MAAA,GAAA,UAAA,OAAU,eAAe,MAAM,CAC7B,gBAAe,QAAQ;EACrB,QAAQ,EAAE;EACV,SAAS,EAAE;EACX,WAAW,EAAE;EACb,OAAO,EAAE;EACV;AAGH,MAAK,MAAM,OAAO,SAChB,KAAI,OAAO,UAAU,eAAe,KAAK,UAAU,IAAI,EAAE;EACvD,MAAM,gBAAgB,SAAS;AAC/B,UAAM,6BAA6B,eAAe,IAAI;AAEtD,GAAA,GAAA,YAAA,UAAA,GAAA,UAAA,UAD2B,cAAc,IAAI,CAAC,MAAM,QAAQ,cAAc,EACxD,iBAAiB,IAAI,0CAA0C;AAEjF,iBAAe,KAAK,SAAS,kBAAkB,cAAc,OAAO;AACpE,iBAAe,KAAK,UAAU,kBAAkB,cAAc,QAAQ;AACtE,iBAAe,KAAK,QAAQ,kBAAkB,cAAc,MAAM;AAElE,iBAAe,KAAK,aAAA,GAAA,UAAA,aAAwB,cAAc,UAAU,GAChE,QACA,kBAAkB,cAAc,UAAU;;AAIlD,QAAO"}
|
package/build/package-access.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import buildDebug from "debug";
|
|
2
|
-
import
|
|
2
|
+
import { flatten, isEmpty, isNil, isObject, isUndefined } from "lodash-es";
|
|
3
3
|
import assert from "node:assert";
|
|
4
4
|
import { errorUtils } from "@verdaccio/core";
|
|
5
5
|
//#region src/package-access.ts
|
|
@@ -19,17 +19,17 @@ var PACKAGE_ACCESS = {
|
|
|
19
19
|
};
|
|
20
20
|
function normalizeUserList(groupsList) {
|
|
21
21
|
const result = [];
|
|
22
|
-
if (
|
|
23
|
-
if (
|
|
22
|
+
if (isNil(groupsList) || isEmpty(groupsList)) return result;
|
|
23
|
+
if (typeof groupsList === "string") {
|
|
24
24
|
const groupsArray = groupsList.split(/\s+/);
|
|
25
25
|
result.push(groupsArray);
|
|
26
26
|
} else if (Array.isArray(groupsList)) result.push(groupsList);
|
|
27
27
|
else throw errorUtils.getInternalError("CONFIG: bad package acl (array or string expected): " + JSON.stringify(groupsList));
|
|
28
|
-
return
|
|
28
|
+
return flatten(result);
|
|
29
29
|
}
|
|
30
30
|
function normalisePackageAccess(packages) {
|
|
31
31
|
const normalizedPkgs = { ...packages };
|
|
32
|
-
if (
|
|
32
|
+
if (isNil(normalizedPkgs["**"])) normalizedPkgs["**"] = {
|
|
33
33
|
access: [],
|
|
34
34
|
publish: [],
|
|
35
35
|
unpublish: [],
|
|
@@ -38,11 +38,11 @@ function normalisePackageAccess(packages) {
|
|
|
38
38
|
for (const pkg in packages) if (Object.prototype.hasOwnProperty.call(packages, pkg)) {
|
|
39
39
|
const packageAccess = packages[pkg];
|
|
40
40
|
debug("package access %s for %s ", packageAccess, pkg);
|
|
41
|
-
assert(
|
|
41
|
+
assert(isObject(packageAccess) && !Array.isArray(packageAccess), `CONFIG: bad "'${pkg}'" package description (object expected)`);
|
|
42
42
|
normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);
|
|
43
43
|
normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);
|
|
44
44
|
normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);
|
|
45
|
-
normalizedPkgs[pkg].unpublish =
|
|
45
|
+
normalizedPkgs[pkg].unpublish = isUndefined(packageAccess.unpublish) ? false : normalizeUserList(packageAccess.unpublish);
|
|
46
46
|
}
|
|
47
47
|
return normalizedPkgs;
|
|
48
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-access.mjs","names":[],"sources":["../src/package-access.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport
|
|
1
|
+
{"version":3,"file":"package-access.mjs","names":[],"sources":["../src/package-access.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport { flatten, isEmpty, isNil, isObject, isUndefined } from 'lodash-es';\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 (typeof groupsList === 'string') {\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) && !Array.isArray(packageAccess);\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,QAAQ,WAAW,yBAAyB;AAOlD,IAAa,QAAQ;CACnB,MAAM;CACN,KAAK;CACL,OAAO;CACP,YAAY;CACZ,gBAAgB;CAChB,iBAAiB;CACjB,sBAAsB;CACvB;AAGD,IAAa,iBAAiB;CAC5B,OAAO;CACP,KAAK;CACN;AAED,SAAgB,kBAAkB,YAAsB;CACtD,MAAM,SAAgB,EAAE;AACxB,KAAI,MAAM,WAAW,IAAI,QAAQ,WAAW,CAC1C,QAAO;AAIT,KAAI,OAAO,eAAe,UAAU;EAClC,MAAM,cAAc,WAAW,MAAM,MAAM;AAE3C,SAAO,KAAK,YAAY;YACf,MAAM,QAAQ,WAAW,CAClC,QAAO,KAAK,WAAW;KAEvB,OAAM,WAAW,iBACf,yDAAyD,KAAK,UAAU,WAAW,CACpF;AAGH,QAAO,QAAQ,OAAO;;AAGxB,SAAgB,uBAAuB,UAAgD;CACrF,MAAM,iBAAoC,EAAE,GAAG,UAAU;AACzD,KAAI,MAAM,eAAe,MAAM,CAC7B,gBAAe,QAAQ;EACrB,QAAQ,EAAE;EACV,SAAS,EAAE;EACX,WAAW,EAAE;EACb,OAAO,EAAE;EACV;AAGH,MAAK,MAAM,OAAO,SAChB,KAAI,OAAO,UAAU,eAAe,KAAK,UAAU,IAAI,EAAE;EACvD,MAAM,gBAAgB,SAAS;AAC/B,QAAM,6BAA6B,eAAe,IAAI;AAEtD,SADkB,SAAS,cAAc,IAAI,CAAC,MAAM,QAAQ,cAAc,EACxD,iBAAiB,IAAI,0CAA0C;AAEjF,iBAAe,KAAK,SAAS,kBAAkB,cAAc,OAAO;AACpE,iBAAe,KAAK,UAAU,kBAAkB,cAAc,QAAQ;AACtE,iBAAe,KAAK,QAAQ,kBAAkB,cAAc,MAAM;AAElE,iBAAe,KAAK,YAAY,YAAY,cAAc,UAAU,GAChE,QACA,kBAAkB,cAAc,UAAU;;AAIlD,QAAO"}
|
package/build/parse.js
CHANGED
|
@@ -3,7 +3,7 @@ const require_config_utils = require("./config-utils.js");
|
|
|
3
3
|
const require_config_path = require("./config-path.js");
|
|
4
4
|
let debug = require("debug");
|
|
5
5
|
debug = require_runtime.__toESM(debug);
|
|
6
|
-
let
|
|
6
|
+
let lodash_es = require("lodash-es");
|
|
7
7
|
let _verdaccio_core = require("@verdaccio/core");
|
|
8
8
|
let node_fs = require("node:fs");
|
|
9
9
|
node_fs = require_runtime.__toESM(node_fs);
|
|
@@ -44,7 +44,7 @@ function parseConfigFile(configPath) {
|
|
|
44
44
|
}
|
|
45
45
|
function fromJStoYAML(config) {
|
|
46
46
|
debug$1("convert config from JSON to YAML");
|
|
47
|
-
if ((0,
|
|
47
|
+
if ((0, lodash_es.isObject)(config)) return js_yaml.default.dump(config);
|
|
48
48
|
else throw new Error(`config is not a valid object`);
|
|
49
49
|
}
|
|
50
50
|
/**
|
package/build/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","names":[],"sources":["../src/parse.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport YAML from 'js-yaml';\nimport { isObject } from 'lodash';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { API_ERROR, APP_ERROR } from '@verdaccio/core';\nimport type { ConfigYaml } from '@verdaccio/types';\n\nimport { findConfigFile } from './config-path';\nimport { fileExists } from './config-utils';\n\nconst debug = buildDebug('verdaccio:config:parse');\n\n/**\n * Parse a config file from yaml to JSON.\n * @param configPath the absolute path of the configuration file\n */\nexport function parseConfigFile(configPath: string): ConfigYaml & {\n // @deprecated use configPath instead\n config_path: string;\n configPath: string;\n} {\n debug('parse config file %s', configPath);\n if (!fileExists(configPath)) {\n throw new Error(`config file does not exist or not reachable`);\n }\n debug('parsing config file: %o', configPath);\n try {\n if (/\\.ya?ml$/i.test(configPath)) {\n const yamlConfig = YAML.load(fs.readFileSync(configPath, 'utf8'), {\n strict: false,\n }) as ConfigYaml;\n\n return Object.assign({}, yamlConfig, {\n configPath,\n // @deprecated use configPath instead\n config_path: configPath,\n });\n }\n\n const jsonConfig = require(configPath) as ConfigYaml;\n return Object.assign({}, jsonConfig, {\n configPath,\n // @deprecated use configPath instead\n config_path: configPath,\n });\n } catch (e: any) {\n if (e.code !== 'MODULE_NOT_FOUND') {\n debug('config module not found %o error: %o', configPath, e.message);\n throw Error(APP_ERROR.CONFIG_NOT_VALID);\n }\n\n throw e;\n }\n}\n\nexport function fromJStoYAML(config: Partial<ConfigYaml>): string | null {\n debug('convert config from JSON to YAML');\n if (isObject(config)) {\n return YAML.dump(config);\n } else {\n throw new Error(`config is not a valid object`);\n }\n}\n\n/**\n * Parses and returns a configuration object of type `ConfigYaml`.\n *\n * If a string or `undefined` is provided, it is interpreted as a path to a config file\n * (or uses a default location). The config file is then loaded and parsed.\n * If an object is provided, it is assumed to be a pre-parsed configuration.\n * Backward compability: ensures the returned configuration object has a `self_path` property set,\n * either to the config file path or to a property within the object.\n *\n * @param {string | ConfigYaml} [config] - Optional. A path to the configuration file (string),\n * a pre-parsed config object, or `undefined`.\n * @returns {ConfigYaml} The parsed configuration object with a guaranteed `self_path` property.\n * @throws {Error} If the provided config is neither a string, undefined, nor an object.\n */\nexport function getConfigParsed(config?: string | ConfigYaml): ConfigYaml {\n debug('getConfigParsed called with config: %o', typeof config);\n let configurationParsed: ConfigYaml;\n if (config === undefined || typeof config === 'string') {\n debug('using default configuration');\n const configPathLocation = findConfigFile(config);\n configurationParsed = parseConfigFile(configPathLocation);\n\n // @ts-expect-error\n if (!configurationParsed.self_path) {\n debug('self_path not defined, using config path location');\n\n // @ts-expect-error\n configurationParsed.self_path = path.resolve(configPathLocation);\n }\n } else if (typeof config === 'object' && config !== null) {\n configurationParsed = config;\n\n // @ts-expect-error\n if (!configurationParsed.self_path) {\n debug('self_path not defined, using config path location');\n\n // @ts-expect-error\n configurationParsed.self_path = configurationParsed.configPath;\n }\n } else {\n throw new Error(API_ERROR.CONFIG_BAD_FORMAT);\n }\n return configurationParsed;\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,IAAM,WAAA,GAAA,MAAA,SAAmB,yBAAyB;;;;;AAMlD,SAAgB,gBAAgB,YAI9B;AACA,SAAM,wBAAwB,WAAW;AACzC,KAAI,CAAC,qBAAA,WAAW,WAAW,CACzB,OAAM,IAAI,MAAM,8CAA8C;AAEhE,SAAM,2BAA2B,WAAW;AAC5C,KAAI;AACF,MAAI,YAAY,KAAK,WAAW,EAAE;GAChC,MAAM,aAAa,QAAA,QAAK,KAAK,QAAA,QAAG,aAAa,YAAY,OAAO,EAAE,EAChE,QAAQ,OACT,CAAC;AAEF,UAAO,OAAO,OAAO,EAAE,EAAE,YAAY;IACnC;IAEA,aAAa;IACd,CAAC;;EAGJ,MAAM,aAAa,QAAQ,WAAW;AACtC,SAAO,OAAO,OAAO,EAAE,EAAE,YAAY;GACnC;GAEA,aAAa;GACd,CAAC;UACK,GAAQ;AACf,MAAI,EAAE,SAAS,oBAAoB;AACjC,WAAM,wCAAwC,YAAY,EAAE,QAAQ;AACpE,SAAM,MAAM,gBAAA,UAAU,iBAAiB;;AAGzC,QAAM;;;AAIV,SAAgB,aAAa,QAA4C;AACvE,SAAM,mCAAmC;AACzC,MAAA,GAAA,
|
|
1
|
+
{"version":3,"file":"parse.js","names":[],"sources":["../src/parse.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport YAML from 'js-yaml';\nimport { isObject } from 'lodash-es';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { API_ERROR, APP_ERROR } from '@verdaccio/core';\nimport type { ConfigYaml } from '@verdaccio/types';\n\nimport { findConfigFile } from './config-path';\nimport { fileExists } from './config-utils';\n\nconst debug = buildDebug('verdaccio:config:parse');\n\n/**\n * Parse a config file from yaml to JSON.\n * @param configPath the absolute path of the configuration file\n */\nexport function parseConfigFile(configPath: string): ConfigYaml & {\n // @deprecated use configPath instead\n config_path: string;\n configPath: string;\n} {\n debug('parse config file %s', configPath);\n if (!fileExists(configPath)) {\n throw new Error(`config file does not exist or not reachable`);\n }\n debug('parsing config file: %o', configPath);\n try {\n if (/\\.ya?ml$/i.test(configPath)) {\n const yamlConfig = YAML.load(fs.readFileSync(configPath, 'utf8'), {\n strict: false,\n }) as ConfigYaml;\n\n return Object.assign({}, yamlConfig, {\n configPath,\n // @deprecated use configPath instead\n config_path: configPath,\n });\n }\n\n const jsonConfig = require(configPath) as ConfigYaml;\n return Object.assign({}, jsonConfig, {\n configPath,\n // @deprecated use configPath instead\n config_path: configPath,\n });\n } catch (e: any) {\n if (e.code !== 'MODULE_NOT_FOUND') {\n debug('config module not found %o error: %o', configPath, e.message);\n throw Error(APP_ERROR.CONFIG_NOT_VALID);\n }\n\n throw e;\n }\n}\n\nexport function fromJStoYAML(config: Partial<ConfigYaml>): string | null {\n debug('convert config from JSON to YAML');\n if (isObject(config)) {\n return YAML.dump(config);\n } else {\n throw new Error(`config is not a valid object`);\n }\n}\n\n/**\n * Parses and returns a configuration object of type `ConfigYaml`.\n *\n * If a string or `undefined` is provided, it is interpreted as a path to a config file\n * (or uses a default location). The config file is then loaded and parsed.\n * If an object is provided, it is assumed to be a pre-parsed configuration.\n * Backward compability: ensures the returned configuration object has a `self_path` property set,\n * either to the config file path or to a property within the object.\n *\n * @param {string | ConfigYaml} [config] - Optional. A path to the configuration file (string),\n * a pre-parsed config object, or `undefined`.\n * @returns {ConfigYaml} The parsed configuration object with a guaranteed `self_path` property.\n * @throws {Error} If the provided config is neither a string, undefined, nor an object.\n */\nexport function getConfigParsed(config?: string | ConfigYaml): ConfigYaml {\n debug('getConfigParsed called with config: %o', typeof config);\n let configurationParsed: ConfigYaml;\n if (config === undefined || typeof config === 'string') {\n debug('using default configuration');\n const configPathLocation = findConfigFile(config);\n configurationParsed = parseConfigFile(configPathLocation);\n\n // @ts-expect-error\n if (!configurationParsed.self_path) {\n debug('self_path not defined, using config path location');\n\n // @ts-expect-error\n configurationParsed.self_path = path.resolve(configPathLocation);\n }\n } else if (typeof config === 'object' && config !== null) {\n configurationParsed = config;\n\n // @ts-expect-error\n if (!configurationParsed.self_path) {\n debug('self_path not defined, using config path location');\n\n // @ts-expect-error\n configurationParsed.self_path = configurationParsed.configPath;\n }\n } else {\n throw new Error(API_ERROR.CONFIG_BAD_FORMAT);\n }\n return configurationParsed;\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,IAAM,WAAA,GAAA,MAAA,SAAmB,yBAAyB;;;;;AAMlD,SAAgB,gBAAgB,YAI9B;AACA,SAAM,wBAAwB,WAAW;AACzC,KAAI,CAAC,qBAAA,WAAW,WAAW,CACzB,OAAM,IAAI,MAAM,8CAA8C;AAEhE,SAAM,2BAA2B,WAAW;AAC5C,KAAI;AACF,MAAI,YAAY,KAAK,WAAW,EAAE;GAChC,MAAM,aAAa,QAAA,QAAK,KAAK,QAAA,QAAG,aAAa,YAAY,OAAO,EAAE,EAChE,QAAQ,OACT,CAAC;AAEF,UAAO,OAAO,OAAO,EAAE,EAAE,YAAY;IACnC;IAEA,aAAa;IACd,CAAC;;EAGJ,MAAM,aAAa,QAAQ,WAAW;AACtC,SAAO,OAAO,OAAO,EAAE,EAAE,YAAY;GACnC;GAEA,aAAa;GACd,CAAC;UACK,GAAQ;AACf,MAAI,EAAE,SAAS,oBAAoB;AACjC,WAAM,wCAAwC,YAAY,EAAE,QAAQ;AACpE,SAAM,MAAM,gBAAA,UAAU,iBAAiB;;AAGzC,QAAM;;;AAIV,SAAgB,aAAa,QAA4C;AACvE,SAAM,mCAAmC;AACzC,MAAA,GAAA,UAAA,UAAa,OAAO,CAClB,QAAO,QAAA,QAAK,KAAK,OAAO;KAExB,OAAM,IAAI,MAAM,+BAA+B;;;;;;;;;;;;;;;;AAkBnD,SAAgB,gBAAgB,QAA0C;AACxE,SAAM,0CAA0C,OAAO,OAAO;CAC9D,IAAI;AACJ,KAAI,WAAW,KAAA,KAAa,OAAO,WAAW,UAAU;AACtD,UAAM,8BAA8B;EACpC,MAAM,qBAAqB,oBAAA,eAAe,OAAO;AACjD,wBAAsB,gBAAgB,mBAAmB;AAGzD,MAAI,CAAC,oBAAoB,WAAW;AAClC,WAAM,oDAAoD;AAG1D,uBAAoB,YAAY,UAAA,QAAK,QAAQ,mBAAmB;;YAEzD,OAAO,WAAW,YAAY,WAAW,MAAM;AACxD,wBAAsB;AAGtB,MAAI,CAAC,oBAAoB,WAAW;AAClC,WAAM,oDAAoD;AAG1D,uBAAoB,YAAY,oBAAoB;;OAGtD,OAAM,IAAI,MAAM,gBAAA,UAAU,kBAAkB;AAE9C,QAAO"}
|
package/build/parse.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { __require } from "./_virtual/_rolldown/runtime.mjs";
|
|
|
2
2
|
import { fileExists } from "./config-utils.mjs";
|
|
3
3
|
import { findConfigFile } from "./config-path.mjs";
|
|
4
4
|
import buildDebug from "debug";
|
|
5
|
-
import { isObject } from "lodash";
|
|
5
|
+
import { isObject } from "lodash-es";
|
|
6
6
|
import { API_ERROR, APP_ERROR } from "@verdaccio/core";
|
|
7
7
|
import fs from "node:fs";
|
|
8
8
|
import path from "node:path";
|
package/build/parse.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.mjs","names":[],"sources":["../src/parse.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport YAML from 'js-yaml';\nimport { isObject } from 'lodash';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { API_ERROR, APP_ERROR } from '@verdaccio/core';\nimport type { ConfigYaml } from '@verdaccio/types';\n\nimport { findConfigFile } from './config-path';\nimport { fileExists } from './config-utils';\n\nconst debug = buildDebug('verdaccio:config:parse');\n\n/**\n * Parse a config file from yaml to JSON.\n * @param configPath the absolute path of the configuration file\n */\nexport function parseConfigFile(configPath: string): ConfigYaml & {\n // @deprecated use configPath instead\n config_path: string;\n configPath: string;\n} {\n debug('parse config file %s', configPath);\n if (!fileExists(configPath)) {\n throw new Error(`config file does not exist or not reachable`);\n }\n debug('parsing config file: %o', configPath);\n try {\n if (/\\.ya?ml$/i.test(configPath)) {\n const yamlConfig = YAML.load(fs.readFileSync(configPath, 'utf8'), {\n strict: false,\n }) as ConfigYaml;\n\n return Object.assign({}, yamlConfig, {\n configPath,\n // @deprecated use configPath instead\n config_path: configPath,\n });\n }\n\n const jsonConfig = require(configPath) as ConfigYaml;\n return Object.assign({}, jsonConfig, {\n configPath,\n // @deprecated use configPath instead\n config_path: configPath,\n });\n } catch (e: any) {\n if (e.code !== 'MODULE_NOT_FOUND') {\n debug('config module not found %o error: %o', configPath, e.message);\n throw Error(APP_ERROR.CONFIG_NOT_VALID);\n }\n\n throw e;\n }\n}\n\nexport function fromJStoYAML(config: Partial<ConfigYaml>): string | null {\n debug('convert config from JSON to YAML');\n if (isObject(config)) {\n return YAML.dump(config);\n } else {\n throw new Error(`config is not a valid object`);\n }\n}\n\n/**\n * Parses and returns a configuration object of type `ConfigYaml`.\n *\n * If a string or `undefined` is provided, it is interpreted as a path to a config file\n * (or uses a default location). The config file is then loaded and parsed.\n * If an object is provided, it is assumed to be a pre-parsed configuration.\n * Backward compability: ensures the returned configuration object has a `self_path` property set,\n * either to the config file path or to a property within the object.\n *\n * @param {string | ConfigYaml} [config] - Optional. A path to the configuration file (string),\n * a pre-parsed config object, or `undefined`.\n * @returns {ConfigYaml} The parsed configuration object with a guaranteed `self_path` property.\n * @throws {Error} If the provided config is neither a string, undefined, nor an object.\n */\nexport function getConfigParsed(config?: string | ConfigYaml): ConfigYaml {\n debug('getConfigParsed called with config: %o', typeof config);\n let configurationParsed: ConfigYaml;\n if (config === undefined || typeof config === 'string') {\n debug('using default configuration');\n const configPathLocation = findConfigFile(config);\n configurationParsed = parseConfigFile(configPathLocation);\n\n // @ts-expect-error\n if (!configurationParsed.self_path) {\n debug('self_path not defined, using config path location');\n\n // @ts-expect-error\n configurationParsed.self_path = path.resolve(configPathLocation);\n }\n } else if (typeof config === 'object' && config !== null) {\n configurationParsed = config;\n\n // @ts-expect-error\n if (!configurationParsed.self_path) {\n debug('self_path not defined, using config path location');\n\n // @ts-expect-error\n configurationParsed.self_path = configurationParsed.configPath;\n }\n } else {\n throw new Error(API_ERROR.CONFIG_BAD_FORMAT);\n }\n return configurationParsed;\n}\n"],"mappings":";;;;;;;;;;AAYA,IAAM,QAAQ,WAAW,yBAAyB;;;;;AAMlD,SAAgB,gBAAgB,YAI9B;AACA,OAAM,wBAAwB,WAAW;AACzC,KAAI,CAAC,WAAW,WAAW,CACzB,OAAM,IAAI,MAAM,8CAA8C;AAEhE,OAAM,2BAA2B,WAAW;AAC5C,KAAI;AACF,MAAI,YAAY,KAAK,WAAW,EAAE;GAChC,MAAM,aAAa,KAAK,KAAK,GAAG,aAAa,YAAY,OAAO,EAAE,EAChE,QAAQ,OACT,CAAC;AAEF,UAAO,OAAO,OAAO,EAAE,EAAE,YAAY;IACnC;IAEA,aAAa;IACd,CAAC;;EAGJ,MAAM,aAAA,UAAqB,WAAW;AACtC,SAAO,OAAO,OAAO,EAAE,EAAE,YAAY;GACnC;GAEA,aAAa;GACd,CAAC;UACK,GAAQ;AACf,MAAI,EAAE,SAAS,oBAAoB;AACjC,SAAM,wCAAwC,YAAY,EAAE,QAAQ;AACpE,SAAM,MAAM,UAAU,iBAAiB;;AAGzC,QAAM;;;AAIV,SAAgB,aAAa,QAA4C;AACvE,OAAM,mCAAmC;AACzC,KAAI,SAAS,OAAO,CAClB,QAAO,KAAK,KAAK,OAAO;KAExB,OAAM,IAAI,MAAM,+BAA+B;;;;;;;;;;;;;;;;AAkBnD,SAAgB,gBAAgB,QAA0C;AACxE,OAAM,0CAA0C,OAAO,OAAO;CAC9D,IAAI;AACJ,KAAI,WAAW,KAAA,KAAa,OAAO,WAAW,UAAU;AACtD,QAAM,8BAA8B;EACpC,MAAM,qBAAqB,eAAe,OAAO;AACjD,wBAAsB,gBAAgB,mBAAmB;AAGzD,MAAI,CAAC,oBAAoB,WAAW;AAClC,SAAM,oDAAoD;AAG1D,uBAAoB,YAAY,KAAK,QAAQ,mBAAmB;;YAEzD,OAAO,WAAW,YAAY,WAAW,MAAM;AACxD,wBAAsB;AAGtB,MAAI,CAAC,oBAAoB,WAAW;AAClC,SAAM,oDAAoD;AAG1D,uBAAoB,YAAY,oBAAoB;;OAGtD,OAAM,IAAI,MAAM,UAAU,kBAAkB;AAE9C,QAAO"}
|
|
1
|
+
{"version":3,"file":"parse.mjs","names":[],"sources":["../src/parse.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport YAML from 'js-yaml';\nimport { isObject } from 'lodash-es';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { API_ERROR, APP_ERROR } from '@verdaccio/core';\nimport type { ConfigYaml } from '@verdaccio/types';\n\nimport { findConfigFile } from './config-path';\nimport { fileExists } from './config-utils';\n\nconst debug = buildDebug('verdaccio:config:parse');\n\n/**\n * Parse a config file from yaml to JSON.\n * @param configPath the absolute path of the configuration file\n */\nexport function parseConfigFile(configPath: string): ConfigYaml & {\n // @deprecated use configPath instead\n config_path: string;\n configPath: string;\n} {\n debug('parse config file %s', configPath);\n if (!fileExists(configPath)) {\n throw new Error(`config file does not exist or not reachable`);\n }\n debug('parsing config file: %o', configPath);\n try {\n if (/\\.ya?ml$/i.test(configPath)) {\n const yamlConfig = YAML.load(fs.readFileSync(configPath, 'utf8'), {\n strict: false,\n }) as ConfigYaml;\n\n return Object.assign({}, yamlConfig, {\n configPath,\n // @deprecated use configPath instead\n config_path: configPath,\n });\n }\n\n const jsonConfig = require(configPath) as ConfigYaml;\n return Object.assign({}, jsonConfig, {\n configPath,\n // @deprecated use configPath instead\n config_path: configPath,\n });\n } catch (e: any) {\n if (e.code !== 'MODULE_NOT_FOUND') {\n debug('config module not found %o error: %o', configPath, e.message);\n throw Error(APP_ERROR.CONFIG_NOT_VALID);\n }\n\n throw e;\n }\n}\n\nexport function fromJStoYAML(config: Partial<ConfigYaml>): string | null {\n debug('convert config from JSON to YAML');\n if (isObject(config)) {\n return YAML.dump(config);\n } else {\n throw new Error(`config is not a valid object`);\n }\n}\n\n/**\n * Parses and returns a configuration object of type `ConfigYaml`.\n *\n * If a string or `undefined` is provided, it is interpreted as a path to a config file\n * (or uses a default location). The config file is then loaded and parsed.\n * If an object is provided, it is assumed to be a pre-parsed configuration.\n * Backward compability: ensures the returned configuration object has a `self_path` property set,\n * either to the config file path or to a property within the object.\n *\n * @param {string | ConfigYaml} [config] - Optional. A path to the configuration file (string),\n * a pre-parsed config object, or `undefined`.\n * @returns {ConfigYaml} The parsed configuration object with a guaranteed `self_path` property.\n * @throws {Error} If the provided config is neither a string, undefined, nor an object.\n */\nexport function getConfigParsed(config?: string | ConfigYaml): ConfigYaml {\n debug('getConfigParsed called with config: %o', typeof config);\n let configurationParsed: ConfigYaml;\n if (config === undefined || typeof config === 'string') {\n debug('using default configuration');\n const configPathLocation = findConfigFile(config);\n configurationParsed = parseConfigFile(configPathLocation);\n\n // @ts-expect-error\n if (!configurationParsed.self_path) {\n debug('self_path not defined, using config path location');\n\n // @ts-expect-error\n configurationParsed.self_path = path.resolve(configPathLocation);\n }\n } else if (typeof config === 'object' && config !== null) {\n configurationParsed = config;\n\n // @ts-expect-error\n if (!configurationParsed.self_path) {\n debug('self_path not defined, using config path location');\n\n // @ts-expect-error\n configurationParsed.self_path = configurationParsed.configPath;\n }\n } else {\n throw new Error(API_ERROR.CONFIG_BAD_FORMAT);\n }\n return configurationParsed;\n}\n"],"mappings":";;;;;;;;;;AAYA,IAAM,QAAQ,WAAW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AkB;AAE9C,QAAO"}
|
package/build/uplinks.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
-
let
|
|
3
|
-
lodash = require_runtime.__toESM(lodash);
|
|
2
|
+
let lodash_es = require("lodash-es");
|
|
4
3
|
let node_assert = require("node:assert");
|
|
5
4
|
node_assert = require_runtime.__toESM(node_assert);
|
|
6
5
|
let _verdaccio_core = require("@verdaccio/core");
|
|
@@ -15,8 +14,8 @@ var BLACKLIST = {
|
|
|
15
14
|
none: true
|
|
16
15
|
};
|
|
17
16
|
function uplinkSanityCheck(uplinks, users = BLACKLIST) {
|
|
18
|
-
const newUplinks =
|
|
19
|
-
let newUsers =
|
|
17
|
+
const newUplinks = (0, lodash_es.clone)(uplinks);
|
|
18
|
+
let newUsers = (0, lodash_es.clone)(users);
|
|
20
19
|
for (const uplink in newUplinks) if (Object.prototype.hasOwnProperty.call(newUplinks, uplink)) {
|
|
21
20
|
if (typeof newUplinks[uplink].cache === "undefined") newUplinks[uplink].cache = true;
|
|
22
21
|
newUsers = sanityCheckNames(uplink, newUsers);
|
|
@@ -24,10 +23,10 @@ function uplinkSanityCheck(uplinks, users = BLACKLIST) {
|
|
|
24
23
|
return newUplinks;
|
|
25
24
|
}
|
|
26
25
|
function sanityCheckUplinksProps(configUpLinks) {
|
|
27
|
-
const uplinks =
|
|
26
|
+
const uplinks = (0, lodash_es.clone)(configUpLinks);
|
|
28
27
|
for (const uplink in uplinks) if (Object.prototype.hasOwnProperty.call(uplinks, uplink)) {
|
|
29
28
|
(0, node_assert.default)(uplinks[uplink].url, "CONFIG: no url for uplink: " + uplink);
|
|
30
|
-
(0, node_assert.default)(
|
|
29
|
+
(0, node_assert.default)(typeof uplinks[uplink].url === "string", "CONFIG: wrong url format for uplink: " + uplink);
|
|
31
30
|
uplinks[uplink].url = uplinks[uplink].url.replace(/\/$/, "");
|
|
32
31
|
}
|
|
33
32
|
return uplinks;
|
|
@@ -43,7 +42,7 @@ function hasProxyTo(pkg, upLink, packages) {
|
|
|
43
42
|
function sanityCheckNames(item, users) {
|
|
44
43
|
(0, node_assert.default)(item !== "all" && item !== "owner" && item !== "anonymous" && item !== "undefined" && item !== "none", "CONFIG: reserved uplink name: " + item);
|
|
45
44
|
(0, node_assert.default)(!item.match(/\s/), "CONFIG: invalid uplink name: " + item);
|
|
46
|
-
(0, node_assert.default)(
|
|
45
|
+
(0, node_assert.default)((0, lodash_es.isNil)(users[item]), "CONFIG: duplicate uplink name: " + item);
|
|
47
46
|
users[item] = true;
|
|
48
47
|
return users;
|
|
49
48
|
}
|
package/build/uplinks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uplinks.js","names":[],"sources":["../src/uplinks.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"uplinks.js","names":[],"sources":["../src/uplinks.ts"],"sourcesContent":["import { clone, isNil } from 'lodash-es';\nimport assert from 'node:assert';\n\nimport { authUtils } from '@verdaccio/core';\nimport type { PackageList, UpLinksConfList } from '@verdaccio/types';\n\nexport const DEFAULT_REGISTRY = 'https://registry.npmjs.org';\nexport const DEFAULT_UPLINK = 'npmjs';\n\nconst BLACKLIST = {\n all: true,\n anonymous: true,\n undefined: true,\n owner: true,\n none: true,\n};\n\nexport function uplinkSanityCheck(\n uplinks: UpLinksConfList,\n users: any = BLACKLIST\n): UpLinksConfList {\n const newUplinks = clone(uplinks);\n let newUsers = clone(users);\n\n for (const uplink in newUplinks) {\n if (Object.prototype.hasOwnProperty.call(newUplinks, uplink)) {\n if (typeof newUplinks[uplink].cache === 'undefined') {\n newUplinks[uplink].cache = true;\n }\n newUsers = sanityCheckNames(uplink, newUsers);\n }\n }\n\n return newUplinks;\n}\n\nexport function sanityCheckUplinksProps(configUpLinks: UpLinksConfList): UpLinksConfList {\n const uplinks = clone(configUpLinks);\n\n for (const uplink in uplinks) {\n if (Object.prototype.hasOwnProperty.call(uplinks, uplink)) {\n assert(uplinks[uplink].url, 'CONFIG: no url for uplink: ' + uplink);\n assert(\n typeof uplinks[uplink].url === 'string',\n 'CONFIG: wrong url format for uplink: ' + uplink\n );\n uplinks[uplink].url = uplinks[uplink].url.replace(/\\/$/, '');\n }\n }\n\n return uplinks;\n}\n\nexport function getProxiesForPackage(pkg: string, packages: PackageList): string[] {\n const matchedPkg = authUtils.getMatchedPackagesSpec(pkg, packages);\n return matchedPkg?.proxy || [];\n}\n\nexport function hasProxyTo(pkg: string, upLink: string, packages: PackageList): boolean {\n const proxyList = getProxiesForPackage(pkg, packages);\n if (proxyList) {\n return proxyList.some((curr) => upLink === curr);\n }\n\n return false;\n}\n\nexport function sanityCheckNames(item: string, users: any): any {\n assert(\n item !== 'all' &&\n item !== 'owner' &&\n item !== 'anonymous' &&\n item !== 'undefined' &&\n item !== 'none',\n 'CONFIG: reserved uplink name: ' + item\n );\n assert(!item.match(/\\s/), 'CONFIG: invalid uplink name: ' + item);\n assert(isNil(users[item]), 'CONFIG: duplicate uplink name: ' + item);\n users[item] = true;\n\n return users;\n}\n"],"mappings":";;;;;;AAMA,IAAa,mBAAmB;AAChC,IAAa,iBAAiB;AAE9B,IAAM,YAAY;CAChB,KAAK;CACL,WAAW;CACX,WAAW;CACX,OAAO;CACP,MAAM;CACP;AAED,SAAgB,kBACd,SACA,QAAa,WACI;CACjB,MAAM,cAAA,GAAA,UAAA,OAAmB,QAAQ;CACjC,IAAI,YAAA,GAAA,UAAA,OAAiB,MAAM;AAE3B,MAAK,MAAM,UAAU,WACnB,KAAI,OAAO,UAAU,eAAe,KAAK,YAAY,OAAO,EAAE;AAC5D,MAAI,OAAO,WAAW,QAAQ,UAAU,YACtC,YAAW,QAAQ,QAAQ;AAE7B,aAAW,iBAAiB,QAAQ,SAAS;;AAIjD,QAAO;;AAGT,SAAgB,wBAAwB,eAAiD;CACvF,MAAM,WAAA,GAAA,UAAA,OAAgB,cAAc;AAEpC,MAAK,MAAM,UAAU,QACnB,KAAI,OAAO,UAAU,eAAe,KAAK,SAAS,OAAO,EAAE;AACzD,GAAA,GAAA,YAAA,SAAO,QAAQ,QAAQ,KAAK,gCAAgC,OAAO;AACnE,GAAA,GAAA,YAAA,SACE,OAAO,QAAQ,QAAQ,QAAQ,UAC/B,0CAA0C,OAC3C;AACD,UAAQ,QAAQ,MAAM,QAAQ,QAAQ,IAAI,QAAQ,OAAO,GAAG;;AAIhE,QAAO;;AAGT,SAAgB,qBAAqB,KAAa,UAAiC;AAEjF,QADmB,gBAAA,UAAU,uBAAuB,KAAK,SAAS,EAC/C,SAAS,EAAE;;AAGhC,SAAgB,WAAW,KAAa,QAAgB,UAAgC;CACtF,MAAM,YAAY,qBAAqB,KAAK,SAAS;AACrD,KAAI,UACF,QAAO,UAAU,MAAM,SAAS,WAAW,KAAK;AAGlD,QAAO;;AAGT,SAAgB,iBAAiB,MAAc,OAAiB;AAC9D,EAAA,GAAA,YAAA,SACE,SAAS,SACP,SAAS,WACT,SAAS,eACT,SAAS,eACT,SAAS,QACX,mCAAmC,KACpC;AACD,EAAA,GAAA,YAAA,SAAO,CAAC,KAAK,MAAM,KAAK,EAAE,kCAAkC,KAAK;AACjE,EAAA,GAAA,YAAA,UAAA,GAAA,UAAA,OAAa,MAAM,MAAM,EAAE,oCAAoC,KAAK;AACpE,OAAM,QAAQ;AAEd,QAAO"}
|
package/build/uplinks.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { clone, isNil } from "lodash-es";
|
|
2
2
|
import assert from "node:assert";
|
|
3
3
|
import { authUtils } from "@verdaccio/core";
|
|
4
4
|
//#region src/uplinks.ts
|
|
@@ -12,8 +12,8 @@ var BLACKLIST = {
|
|
|
12
12
|
none: true
|
|
13
13
|
};
|
|
14
14
|
function uplinkSanityCheck(uplinks, users = BLACKLIST) {
|
|
15
|
-
const newUplinks =
|
|
16
|
-
let newUsers =
|
|
15
|
+
const newUplinks = clone(uplinks);
|
|
16
|
+
let newUsers = clone(users);
|
|
17
17
|
for (const uplink in newUplinks) if (Object.prototype.hasOwnProperty.call(newUplinks, uplink)) {
|
|
18
18
|
if (typeof newUplinks[uplink].cache === "undefined") newUplinks[uplink].cache = true;
|
|
19
19
|
newUsers = sanityCheckNames(uplink, newUsers);
|
|
@@ -21,10 +21,10 @@ function uplinkSanityCheck(uplinks, users = BLACKLIST) {
|
|
|
21
21
|
return newUplinks;
|
|
22
22
|
}
|
|
23
23
|
function sanityCheckUplinksProps(configUpLinks) {
|
|
24
|
-
const uplinks =
|
|
24
|
+
const uplinks = clone(configUpLinks);
|
|
25
25
|
for (const uplink in uplinks) if (Object.prototype.hasOwnProperty.call(uplinks, uplink)) {
|
|
26
26
|
assert(uplinks[uplink].url, "CONFIG: no url for uplink: " + uplink);
|
|
27
|
-
assert(
|
|
27
|
+
assert(typeof uplinks[uplink].url === "string", "CONFIG: wrong url format for uplink: " + uplink);
|
|
28
28
|
uplinks[uplink].url = uplinks[uplink].url.replace(/\/$/, "");
|
|
29
29
|
}
|
|
30
30
|
return uplinks;
|
|
@@ -40,7 +40,7 @@ function hasProxyTo(pkg, upLink, packages) {
|
|
|
40
40
|
function sanityCheckNames(item, users) {
|
|
41
41
|
assert(item !== "all" && item !== "owner" && item !== "anonymous" && item !== "undefined" && item !== "none", "CONFIG: reserved uplink name: " + item);
|
|
42
42
|
assert(!item.match(/\s/), "CONFIG: invalid uplink name: " + item);
|
|
43
|
-
assert(
|
|
43
|
+
assert(isNil(users[item]), "CONFIG: duplicate uplink name: " + item);
|
|
44
44
|
users[item] = true;
|
|
45
45
|
return users;
|
|
46
46
|
}
|
package/build/uplinks.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uplinks.mjs","names":[],"sources":["../src/uplinks.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"uplinks.mjs","names":[],"sources":["../src/uplinks.ts"],"sourcesContent":["import { clone, isNil } from 'lodash-es';\nimport assert from 'node:assert';\n\nimport { authUtils } from '@verdaccio/core';\nimport type { PackageList, UpLinksConfList } from '@verdaccio/types';\n\nexport const DEFAULT_REGISTRY = 'https://registry.npmjs.org';\nexport const DEFAULT_UPLINK = 'npmjs';\n\nconst BLACKLIST = {\n all: true,\n anonymous: true,\n undefined: true,\n owner: true,\n none: true,\n};\n\nexport function uplinkSanityCheck(\n uplinks: UpLinksConfList,\n users: any = BLACKLIST\n): UpLinksConfList {\n const newUplinks = clone(uplinks);\n let newUsers = clone(users);\n\n for (const uplink in newUplinks) {\n if (Object.prototype.hasOwnProperty.call(newUplinks, uplink)) {\n if (typeof newUplinks[uplink].cache === 'undefined') {\n newUplinks[uplink].cache = true;\n }\n newUsers = sanityCheckNames(uplink, newUsers);\n }\n }\n\n return newUplinks;\n}\n\nexport function sanityCheckUplinksProps(configUpLinks: UpLinksConfList): UpLinksConfList {\n const uplinks = clone(configUpLinks);\n\n for (const uplink in uplinks) {\n if (Object.prototype.hasOwnProperty.call(uplinks, uplink)) {\n assert(uplinks[uplink].url, 'CONFIG: no url for uplink: ' + uplink);\n assert(\n typeof uplinks[uplink].url === 'string',\n 'CONFIG: wrong url format for uplink: ' + uplink\n );\n uplinks[uplink].url = uplinks[uplink].url.replace(/\\/$/, '');\n }\n }\n\n return uplinks;\n}\n\nexport function getProxiesForPackage(pkg: string, packages: PackageList): string[] {\n const matchedPkg = authUtils.getMatchedPackagesSpec(pkg, packages);\n return matchedPkg?.proxy || [];\n}\n\nexport function hasProxyTo(pkg: string, upLink: string, packages: PackageList): boolean {\n const proxyList = getProxiesForPackage(pkg, packages);\n if (proxyList) {\n return proxyList.some((curr) => upLink === curr);\n }\n\n return false;\n}\n\nexport function sanityCheckNames(item: string, users: any): any {\n assert(\n item !== 'all' &&\n item !== 'owner' &&\n item !== 'anonymous' &&\n item !== 'undefined' &&\n item !== 'none',\n 'CONFIG: reserved uplink name: ' + item\n );\n assert(!item.match(/\\s/), 'CONFIG: invalid uplink name: ' + item);\n assert(isNil(users[item]), 'C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AM,MAAM,EAAE,oCAAoC,KAAK;AACpE,OAAM,QAAQ;AAEd,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/config",
|
|
3
|
-
"version": "9.0.0-next-9.
|
|
3
|
+
"version": "9.0.0-next-9.8",
|
|
4
4
|
"description": "Verdaccio Configuration",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -33,13 +33,14 @@
|
|
|
33
33
|
"node": ">=24"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@verdaccio/core": "9.0.0-next-9.
|
|
36
|
+
"@verdaccio/core": "9.0.0-next-9.8",
|
|
37
37
|
"debug": "4.4.3",
|
|
38
38
|
"js-yaml": "4.1.1",
|
|
39
|
-
"lodash": "4.17.23"
|
|
39
|
+
"lodash-es": "4.17.23"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@verdaccio/types": "14.0.0-next-9.4",
|
|
43
|
+
"@types/lodash-es": "4.17.12",
|
|
43
44
|
"vitest": "4.1.0"
|
|
44
45
|
},
|
|
45
46
|
"funding": {
|