@verdaccio/config 6.0.0-6-next.51 → 6.0.0-6-next.53
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/CHANGELOG.md +14 -0
- package/build/agent.js +0 -2
- package/build/agent.js.map +1 -1
- package/build/builder.js +0 -15
- package/build/builder.js.map +1 -1
- package/build/conf/index.js +0 -3
- package/build/conf/index.js.map +1 -1
- package/build/config-path.d.ts +1 -1
- package/build/config-path.js +17 -47
- package/build/config-path.js.map +1 -1
- package/build/config-utils.js +1 -7
- package/build/config-utils.js.map +1 -1
- package/build/config.js +18 -38
- package/build/config.js.map +1 -1
- package/build/index.js +0 -18
- package/build/index.js.map +1 -1
- package/build/package-access.js +8 -18
- package/build/package-access.js.map +1 -1
- package/build/parse.js +1 -18
- package/build/parse.js.map +1 -1
- package/build/security.js.map +1 -1
- package/build/serverSettings.js.map +1 -1
- package/build/token.js +1 -4
- package/build/token.js.map +1 -1
- package/build/uplinks.js +0 -17
- package/build/uplinks.js.map +1 -1
- package/build/user.js +4 -8
- package/build/user.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @verdaccio/config
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.53
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @verdaccio/core@6.0.0-6-next.53
|
|
8
|
+
- @verdaccio/utils@6.0.0-6-next.21
|
|
9
|
+
|
|
10
|
+
## 6.0.0-6-next.52
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- @verdaccio/core@6.0.0-6-next.52
|
|
15
|
+
- @verdaccio/utils@6.0.0-6-next.20
|
|
16
|
+
|
|
3
17
|
## 6.0.0-6-next.51
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/build/agent.js
CHANGED
package/build/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","names":["pkgVersion","require","version","getUserAgent"],"sources":["../src/agent.ts"],"sourcesContent":["const pkgVersion = require('../package.json').version;\n\nexport function getUserAgent(): string {\n return `verdaccio/${pkgVersion}`;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent.js","names":["pkgVersion","require","version","getUserAgent"],"sources":["../src/agent.ts"],"sourcesContent":["const pkgVersion = require('../package.json').version;\n\nexport function getUserAgent(): string {\n return `verdaccio/${pkgVersion}`;\n}\n"],"mappings":";;;;;;AAAA,MAAMA,UAAU,GAAGC,OAAO,CAAC,iBAAiB,CAAC,CAACC,OAAO;AAE9C,SAASC,YAAY,GAAW;EACrC,OAAQ,aAAYH,UAAW,EAAC;AAClC"}
|
package/build/builder.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _lodash = require("lodash");
|
|
9
|
-
|
|
10
8
|
var _ = require(".");
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Helper configuration builder constructor, used to build the configuration for testing or
|
|
14
11
|
* programatically creating a configuration.
|
|
@@ -22,56 +19,44 @@ class ConfigBuilder {
|
|
|
22
19
|
security: {}
|
|
23
20
|
};
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
static build(config) {
|
|
27
23
|
return new ConfigBuilder(config);
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
addPackageAccess(pattern, pkgAccess) {
|
|
31
26
|
// @ts-ignore
|
|
32
27
|
this.config.packages[pattern] = pkgAccess;
|
|
33
28
|
return this;
|
|
34
29
|
}
|
|
35
|
-
|
|
36
30
|
addUplink(id, uplink) {
|
|
37
31
|
this.config.uplinks[id] = uplink;
|
|
38
32
|
return this;
|
|
39
33
|
}
|
|
40
|
-
|
|
41
34
|
addSecurity(security) {
|
|
42
35
|
this.config.security = (0, _lodash.merge)(this.config.security, security);
|
|
43
36
|
return this;
|
|
44
37
|
}
|
|
45
|
-
|
|
46
38
|
addAuth(auth) {
|
|
47
39
|
this.config.auth = (0, _lodash.merge)(this.config.auth, auth);
|
|
48
40
|
return this;
|
|
49
41
|
}
|
|
50
|
-
|
|
51
42
|
addLogger(log) {
|
|
52
43
|
this.config.log = log;
|
|
53
44
|
return this;
|
|
54
45
|
}
|
|
55
|
-
|
|
56
46
|
addStorage(storage) {
|
|
57
47
|
if (typeof storage === 'string') {
|
|
58
48
|
this.config.storage = storage;
|
|
59
49
|
} else {
|
|
60
50
|
this.config.store = storage;
|
|
61
51
|
}
|
|
62
|
-
|
|
63
52
|
return this;
|
|
64
53
|
}
|
|
65
|
-
|
|
66
54
|
getConfig() {
|
|
67
55
|
return this.config;
|
|
68
56
|
}
|
|
69
|
-
|
|
70
57
|
getAsYaml() {
|
|
71
58
|
return (0, _.fromJStoYAML)(this.config);
|
|
72
59
|
}
|
|
73
|
-
|
|
74
60
|
}
|
|
75
|
-
|
|
76
61
|
exports.default = ConfigBuilder;
|
|
77
62
|
//# sourceMappingURL=builder.js.map
|
package/build/builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","names":["ConfigBuilder","constructor","config","uplinks","packages","security","build","addPackageAccess","pattern","pkgAccess","addUplink","id","uplink","addSecurity","merge","addAuth","auth","addLogger","log","addStorage","storage","store","getConfig","getAsYaml","fromJStoYAML"],"sources":["../src/builder.ts"],"sourcesContent":["import { merge } from 'lodash';\n\nimport {\n AuthConf,\n ConfigYaml,\n LoggerConfItem,\n PackageAccessYaml,\n Security,\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 // @ts-ignore\n this.config = 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: LoggerConfItem) {\n this.config.log = log;\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":"
|
|
1
|
+
{"version":3,"file":"builder.js","names":["ConfigBuilder","constructor","config","uplinks","packages","security","build","addPackageAccess","pattern","pkgAccess","addUplink","id","uplink","addSecurity","merge","addAuth","auth","addLogger","log","addStorage","storage","store","getConfig","getAsYaml","fromJStoYAML"],"sources":["../src/builder.ts"],"sourcesContent":["import { merge } from 'lodash';\n\nimport {\n AuthConf,\n ConfigYaml,\n LoggerConfItem,\n PackageAccessYaml,\n Security,\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 // @ts-ignore\n this.config = 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: LoggerConfItem) {\n this.config.log = log;\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":";;;;;;AAAA;AAWA;AAEA;AACA;AACA;AACA;AACe,MAAMA,aAAa,CAAC;EAG1BC,WAAW,CAACC,MAA4B,EAAE;IAC/C;IACA,IAAI,CAACA,MAAM,GAAGA,MAAM,IAAI;MAAEC,OAAO,EAAE,CAAC,CAAC;MAAEC,QAAQ,EAAE,CAAC,CAAC;MAAEC,QAAQ,EAAE,CAAC;IAAE,CAAC;EACrE;EAEA,OAAcC,KAAK,CAACJ,MAA4B,EAAiB;IAC/D,OAAO,IAAIF,aAAa,CAACE,MAAM,CAAC;EAClC;EAEOK,gBAAgB,CAACC,OAAe,EAAEC,SAA4B,EAAE;IACrE;IACA,IAAI,CAACP,MAAM,CAACE,QAAQ,CAACI,OAAO,CAAC,GAAGC,SAAS;IACzC,OAAO,IAAI;EACb;EAEOC,SAAS,CAACC,EAAU,EAAEC,MAAkB,EAAE;IAC/C,IAAI,CAACV,MAAM,CAACC,OAAO,CAACQ,EAAE,CAAC,GAAGC,MAAM;IAChC,OAAO,IAAI;EACb;EAEOC,WAAW,CAACR,QAA2B,EAAE;IAC9C,IAAI,CAACH,MAAM,CAACG,QAAQ,GAAG,IAAAS,aAAK,EAAC,IAAI,CAACZ,MAAM,CAACG,QAAQ,EAAEA,QAAQ,CAAC;IAC5D,OAAO,IAAI;EACb;EAEOU,OAAO,CAACC,IAAuB,EAAE;IACtC,IAAI,CAACd,MAAM,CAACc,IAAI,GAAG,IAAAF,aAAK,EAAC,IAAI,CAACZ,MAAM,CAACc,IAAI,EAAEA,IAAI,CAAC;IAChD,OAAO,IAAI;EACb;EAEOC,SAAS,CAACC,GAAmB,EAAE;IACpC,IAAI,CAAChB,MAAM,CAACgB,GAAG,GAAGA,GAAG;IACrB,OAAO,IAAI;EACb;EAEOC,UAAU,CAACC,OAAwB,EAAE;IAC1C,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;MAC/B,IAAI,CAAClB,MAAM,CAACkB,OAAO,GAAGA,OAAO;IAC/B,CAAC,MAAM;MACL,IAAI,CAAClB,MAAM,CAACmB,KAAK,GAAGD,OAAO;IAC7B;IACA,OAAO,IAAI;EACb;EAEOE,SAAS,GAAe;IAC7B,OAAO,IAAI,CAACpB,MAAM;EACpB;EAEOqB,SAAS,GAAW;IACzB,OAAO,IAAAC,cAAY,EAAC,IAAI,CAACtB,MAAM,CAAC;EAClC;AACF;AAAC"}
|
package/build/conf/index.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getDefaultConfig = getDefaultConfig;
|
|
7
|
-
|
|
8
7
|
var _path = require("path");
|
|
9
|
-
|
|
10
8
|
var _parse = require("../parse");
|
|
11
|
-
|
|
12
9
|
function getDefaultConfig(fileName = 'default.yaml') {
|
|
13
10
|
const file = (0, _path.join)(__dirname, `./${fileName}`);
|
|
14
11
|
return (0, _parse.parseConfigFile)(file);
|
package/build/conf/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getDefaultConfig","fileName","file","join","__dirname","parseConfigFile"],"sources":["../../src/conf/index.ts"],"sourcesContent":["import { join } from 'path';\n\nimport { parseConfigFile } from '../parse';\n\nexport function getDefaultConfig(fileName = 'default.yaml') {\n const file = join(__dirname, `./${fileName}`);\n return parseConfigFile(file);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["getDefaultConfig","fileName","file","join","__dirname","parseConfigFile"],"sources":["../../src/conf/index.ts"],"sourcesContent":["import { join } from 'path';\n\nimport { parseConfigFile } from '../parse';\n\nexport function getDefaultConfig(fileName = 'default.yaml') {\n const file = join(__dirname, `./${fileName}`);\n return parseConfigFile(file);\n}\n"],"mappings":";;;;;;AAAA;AAEA;AAEO,SAASA,gBAAgB,CAACC,QAAQ,GAAG,cAAc,EAAE;EAC1D,MAAMC,IAAI,GAAG,IAAAC,UAAI,EAACC,SAAS,EAAG,KAAIH,QAAS,EAAC,CAAC;EAC7C,OAAO,IAAAI,sBAAe,EAACH,IAAI,CAAC;AAC9B"}
|
package/build/config-path.d.ts
CHANGED
package/build/config-path.js
CHANGED
|
@@ -5,119 +5,95 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.findConfigFile = findConfigFile;
|
|
7
7
|
exports.readDefaultConfig = readDefaultConfig;
|
|
8
|
-
|
|
9
8
|
var _debug = _interopRequireDefault(require("debug"));
|
|
10
|
-
|
|
11
9
|
var _fs = _interopRequireDefault(require("fs"));
|
|
12
|
-
|
|
13
10
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
14
|
-
|
|
15
11
|
var _path = _interopRequireDefault(require("path"));
|
|
16
|
-
|
|
17
12
|
var _core = require("@verdaccio/core");
|
|
18
|
-
|
|
19
13
|
var _configUtils = require("./config-utils");
|
|
20
|
-
|
|
21
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
23
15
|
const CONFIG_FILE = 'config.yaml';
|
|
24
16
|
const XDG = 'xdg';
|
|
25
17
|
const WIN = 'win';
|
|
26
|
-
const WIN32 = 'win32';
|
|
27
|
-
|
|
18
|
+
const WIN32 = 'win32';
|
|
19
|
+
// eslint-disable-next-line
|
|
28
20
|
const pkgJSON = {
|
|
29
21
|
name: 'verdaccio'
|
|
30
22
|
};
|
|
31
23
|
const debug = (0, _debug.default)('verdaccio:config');
|
|
24
|
+
|
|
32
25
|
/**
|
|
33
26
|
* Find and get the first config file that match.
|
|
34
27
|
* @return {String} the config file path
|
|
35
28
|
*/
|
|
36
|
-
|
|
37
29
|
function findConfigFile(configPath) {
|
|
38
30
|
// console.log(process.env);
|
|
39
31
|
if (typeof configPath !== 'undefined') {
|
|
40
32
|
return _path.default.resolve(configPath);
|
|
41
33
|
}
|
|
42
|
-
|
|
43
34
|
const configPaths = getConfigPaths();
|
|
44
35
|
debug('%o posible locations found', configPaths.length);
|
|
45
|
-
|
|
46
36
|
if (_lodash.default.isEmpty(configPaths)) {
|
|
47
37
|
// this should never happens
|
|
48
38
|
throw new Error('no configuration files can be processed');
|
|
49
|
-
}
|
|
50
|
-
|
|
39
|
+
}
|
|
51
40
|
|
|
41
|
+
// find the first location that already exist
|
|
52
42
|
const primaryConf = _lodash.default.find(configPaths, configLocation => (0, _configUtils.fileExists)(configLocation.path));
|
|
53
|
-
|
|
54
43
|
if (typeof primaryConf !== 'undefined') {
|
|
55
44
|
debug('previous location exist already %s', primaryConf === null || primaryConf === void 0 ? void 0 : primaryConf.path);
|
|
56
45
|
return primaryConf.path;
|
|
57
|
-
}
|
|
58
|
-
|
|
46
|
+
}
|
|
59
47
|
|
|
48
|
+
// @ts-ignore
|
|
60
49
|
return createConfigFile(_lodash.default.head(configPaths)).path;
|
|
61
50
|
}
|
|
62
|
-
|
|
63
51
|
function createConfigFile(configLocation) {
|
|
64
52
|
createConfigFolder(configLocation);
|
|
65
53
|
const defaultConfig = updateStorageLinks(configLocation, readDefaultConfig());
|
|
66
|
-
|
|
67
54
|
_fs.default.writeFileSync(configLocation.path, defaultConfig);
|
|
68
|
-
|
|
69
55
|
return configLocation;
|
|
70
56
|
}
|
|
71
|
-
|
|
72
57
|
function readDefaultConfig() {
|
|
73
58
|
const pathDefaultConf = _path.default.resolve(__dirname, 'conf/default.yaml');
|
|
74
|
-
|
|
75
59
|
try {
|
|
76
60
|
debug('default configuration file %s', pathDefaultConf);
|
|
77
|
-
|
|
78
61
|
_fs.default.accessSync(pathDefaultConf, _fs.default.constants.R_OK);
|
|
79
62
|
} catch {
|
|
80
63
|
throw new TypeError('configuration file does not have enough permissions for reading');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
64
|
+
}
|
|
65
|
+
// @ts-ignore
|
|
84
66
|
return _fs.default.readFileSync(pathDefaultConf, _core.CHARACTER_ENCODING.UTF8);
|
|
85
67
|
}
|
|
86
|
-
|
|
87
68
|
function createConfigFolder(configLocation) {
|
|
88
69
|
_fs.default.mkdirSync(_path.default.dirname(configLocation.path), {
|
|
89
70
|
recursive: true
|
|
90
71
|
});
|
|
91
|
-
|
|
92
72
|
debug(`Creating default config file in %o`, configLocation === null || configLocation === void 0 ? void 0 : configLocation.path);
|
|
93
73
|
}
|
|
94
|
-
|
|
95
74
|
function updateStorageLinks(configLocation, defaultConfig) {
|
|
96
75
|
if (configLocation.type !== XDG) {
|
|
97
76
|
return defaultConfig;
|
|
98
|
-
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// $XDG_DATA_HOME defines the base directory relative to which user specific data
|
|
99
80
|
// files should be stored, If $XDG_DATA_HOME is either not set or empty, a default
|
|
100
81
|
// equal to $HOME/.local/share should be used.
|
|
101
|
-
|
|
102
|
-
|
|
103
82
|
let dataDir = process.env.XDG_DATA_HOME || _path.default.join(process.env.HOME, '.local', 'share');
|
|
104
|
-
|
|
105
83
|
if ((0, _configUtils.folderExists)(dataDir)) {
|
|
106
84
|
debug(`previous storage located`);
|
|
107
85
|
debug(`update storage links to %s`, dataDir);
|
|
108
86
|
dataDir = _path.default.resolve(_path.default.join(dataDir, pkgJSON.name, 'storage'));
|
|
109
87
|
return defaultConfig.replace(/^storage: .\/storage$/m, `storage: ${dataDir}`);
|
|
110
88
|
}
|
|
111
|
-
|
|
112
89
|
debug(`could not find a previous storage location, skip override`);
|
|
113
90
|
return defaultConfig;
|
|
114
91
|
}
|
|
92
|
+
|
|
115
93
|
/**
|
|
116
94
|
* Return a list of configuration locations by platform.
|
|
117
95
|
* @returns
|
|
118
96
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
97
|
function getConfigPaths() {
|
|
122
98
|
const listPaths = [getXDGDirectory(), getWindowsDirectory(), getRelativeDefaultDirectory(), getOldDirectory()];
|
|
123
99
|
return listPaths.reduce(function (acc, currentValue) {
|
|
@@ -125,19 +101,16 @@ function getConfigPaths() {
|
|
|
125
101
|
debug('directory detected path %s for type %s', currentValue === null || currentValue === void 0 ? void 0 : currentValue.path, currentValue.type);
|
|
126
102
|
acc.push(currentValue);
|
|
127
103
|
}
|
|
128
|
-
|
|
129
104
|
return acc;
|
|
130
105
|
}, []);
|
|
131
106
|
}
|
|
107
|
+
|
|
132
108
|
/**
|
|
133
109
|
* Get XDG_CONFIG_HOME or HOME location (usually unix)
|
|
134
110
|
* @returns
|
|
135
111
|
*/
|
|
136
|
-
|
|
137
|
-
|
|
138
112
|
const getXDGDirectory = () => {
|
|
139
113
|
const xDGConfigPath = process.env.XDG_CONFIG_HOME || process.env.HOME && _path.default.join(process.env.HOME, '.config');
|
|
140
|
-
|
|
141
114
|
if (xDGConfigPath && (0, _configUtils.folderExists)(xDGConfigPath)) {
|
|
142
115
|
debug('XDGConfig folder path %s', xDGConfigPath);
|
|
143
116
|
return {
|
|
@@ -146,13 +119,12 @@ const getXDGDirectory = () => {
|
|
|
146
119
|
};
|
|
147
120
|
}
|
|
148
121
|
};
|
|
122
|
+
|
|
149
123
|
/**
|
|
150
124
|
* Detect windows location, APPDATA
|
|
151
125
|
* usually something like C:\User\<Build User>\AppData\Local
|
|
152
126
|
* @returns
|
|
153
127
|
*/
|
|
154
|
-
|
|
155
|
-
|
|
156
128
|
const getWindowsDirectory = () => {
|
|
157
129
|
if (process.platform === WIN32 && process.env.APPDATA && (0, _configUtils.folderExists)(process.env.APPDATA)) {
|
|
158
130
|
debug('is windows appdata: %s', process.env.APPDATA);
|
|
@@ -162,25 +134,23 @@ const getWindowsDirectory = () => {
|
|
|
162
134
|
};
|
|
163
135
|
}
|
|
164
136
|
};
|
|
137
|
+
|
|
165
138
|
/**
|
|
166
139
|
* Return relative directory, this is the default.
|
|
167
140
|
* It will cretate config in your {currentLocation/verdaccio/config.yaml}
|
|
168
141
|
* @returns
|
|
169
142
|
*/
|
|
170
|
-
|
|
171
|
-
|
|
172
143
|
const getRelativeDefaultDirectory = () => {
|
|
173
144
|
return {
|
|
174
145
|
path: _path.default.resolve(_path.default.join('.', pkgJSON.name, CONFIG_FILE)),
|
|
175
146
|
type: 'def'
|
|
176
147
|
};
|
|
177
148
|
};
|
|
149
|
+
|
|
178
150
|
/**
|
|
179
151
|
* This should never happens, consider it DEPRECATED
|
|
180
152
|
* @returns
|
|
181
153
|
*/
|
|
182
|
-
|
|
183
|
-
|
|
184
154
|
const getOldDirectory = () => {
|
|
185
155
|
return {
|
|
186
156
|
path: _path.default.resolve(_path.default.join('.', CONFIG_FILE)),
|
package/build/config-path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-path.js","names":["CONFIG_FILE","XDG","WIN","WIN32","pkgJSON","name","debug","buildDebug","findConfigFile","configPath","path","resolve","configPaths","getConfigPaths","length","_","isEmpty","Error","primaryConf","find","configLocation","fileExists","createConfigFile","head","createConfigFolder","defaultConfig","updateStorageLinks","readDefaultConfig","fs","writeFileSync","pathDefaultConf","__dirname","accessSync","constants","R_OK","TypeError","readFileSync","CHARACTER_ENCODING","UTF8","mkdirSync","dirname","recursive","type","dataDir","process","env","XDG_DATA_HOME","join","HOME","folderExists","replace","listPaths","getXDGDirectory","getWindowsDirectory","getRelativeDefaultDirectory","getOldDirectory","reduce","acc","currentValue","push","xDGConfigPath","XDG_CONFIG_HOME","platform","APPDATA"],"sources":["../src/config-path.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport fs from 'fs';\nimport _ from 'lodash';\nimport path from 'path';\n\nimport { CHARACTER_ENCODING } from '@verdaccio/core';\n\nimport { fileExists, folderExists } from './config-utils';\n\nconst CONFIG_FILE = 'config.yaml';\nconst XDG = 'xdg';\nconst WIN = 'win';\nconst WIN32 = 'win32';\n// eslint-disable-next-line\nconst pkgJSON = {\n name: 'verdaccio',\n};\n\nexport type SetupDirectory = {\n path: string;\n type: string;\n};\n\nconst debug = buildDebug('verdaccio:config');\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 // console.log(process.env);\n if (typeof configPath !== 'undefined') {\n return path.resolve(configPath);\n }\n\n const configPaths: SetupDirectory[] = getConfigPaths();\n debug('%o posible locations found', configPaths.length);\n if (_.isEmpty(configPaths)) {\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('previous location exist already %s', primaryConf?.path);\n return primaryConf.path;\n }\n\n // @ts-ignore\n return createConfigFile(_.head(configPaths)).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(): Buffer {\n const pathDefaultConf: string = path.resolve(__dirname, 'conf/default.yaml');\n try {\n debug('default configuration file %s', pathDefaultConf);\n fs.accessSync(pathDefaultConf, fs.constants.R_OK);\n } catch {\n throw new TypeError('configuration file does not have enough permissions for reading');\n }\n // @ts-ignore\n return fs.readFileSync(pathDefaultConf, CHARACTER_ENCODING.UTF8);\n}\n\nfunction createConfigFolder(configLocation): void {\n fs.mkdirSync(path.dirname(configLocation.path), { recursive: true });\n debug(`Creating default config file in %o`, configLocation?.path);\n}\n\nfunction updateStorageLinks(configLocation, defaultConfig): string {\n if (configLocation.type !== XDG) {\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('directory detected path %s for type %s', currentValue?.path, currentValue.type);\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 * @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 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 (process.platform === WIN32 && process.env.APPDATA && folderExists(process.env.APPDATA)) {\n debug('is windows appdata: %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 return {\n path: path.resolve(path.join('.', pkgJSON.name, CONFIG_FILE)),\n type: 'def',\n };\n};\n\n/**\n * This should never happens, consider it DEPRECATED\n * @returns\n */\nconst getOldDirectory = (): SetupDirectory => {\n return {\n path: path.resolve(path.join('.', CONFIG_FILE)),\n type: 'old',\n };\n};\n\nexport { findConfigFile };\n"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;;;AAEA,MAAMA,WAAW,GAAG,aAApB;AACA,MAAMC,GAAG,GAAG,KAAZ;AACA,MAAMC,GAAG,GAAG,KAAZ;AACA,MAAMC,KAAK,GAAG,OAAd,C,CACA;;AACA,MAAMC,OAAO,GAAG;EACdC,IAAI,EAAE;AADQ,CAAhB;AASA,MAAMC,KAAK,GAAG,IAAAC,cAAA,EAAW,kBAAX,CAAd;AAEA;AACA;AACA;AACA;;AACA,SAASC,cAAT,CAAwBC,UAAxB,EAAqD;EACnD;EACA,IAAI,OAAOA,UAAP,KAAsB,WAA1B,EAAuC;IACrC,OAAOC,aAAA,CAAKC,OAAL,CAAaF,UAAb,CAAP;EACD;;EAED,MAAMG,WAA6B,GAAGC,cAAc,EAApD;EACAP,KAAK,CAAC,4BAAD,EAA+BM,WAAW,CAACE,MAA3C,CAAL;;EACA,IAAIC,eAAA,CAAEC,OAAF,CAAUJ,WAAV,CAAJ,EAA4B;IAC1B;IACA,MAAM,IAAIK,KAAJ,CAAU,yCAAV,CAAN;EACD,CAXkD,CAanD;;;EACA,MAAMC,WAAkC,GAAGH,eAAA,CAAEI,IAAF,CAAOP,WAAP,EAAqBQ,cAAD,IAC7D,IAAAC,uBAAA,EAAWD,cAAc,CAACV,IAA1B,CADyC,CAA3C;;EA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CAAaD,aAAA,CAAKqC,IAAL,CAAU,GAAV,EAAe3C,OAAO,CAACC,IAAvB,EAA6BL,WAA7B,CAAb,CADD;IAEL0C,IAAI,EAAE;EAFD,CAAP;AAID,CALD;AAOA;AACA;AACA;AACA;;;AACA,MAAMa,eAAe,GAAG,MAAsB;EAC5C,OAAO;IACL7C,IAAI,EAAEA,aAAA,CAAKC,OAAL,CAAaD,aAAA,CAAKqC,IAAL,CAAU,GAAV,EAAe/C,WAAf,CAAb,CADD;IAEL0C,IAAI,EAAE;EAFD,CAAP;AAID,CALD"}
|
|
1
|
+
{"version":3,"file":"config-path.js","names":["CONFIG_FILE","XDG","WIN","WIN32","pkgJSON","name","debug","buildDebug","findConfigFile","configPath","path","resolve","configPaths","getConfigPaths","length","_","isEmpty","Error","primaryConf","find","configLocation","fileExists","createConfigFile","head","createConfigFolder","defaultConfig","updateStorageLinks","readDefaultConfig","fs","writeFileSync","pathDefaultConf","__dirname","accessSync","constants","R_OK","TypeError","readFileSync","CHARACTER_ENCODING","UTF8","mkdirSync","dirname","recursive","type","dataDir","process","env","XDG_DATA_HOME","join","HOME","folderExists","replace","listPaths","getXDGDirectory","getWindowsDirectory","getRelativeDefaultDirectory","getOldDirectory","reduce","acc","currentValue","push","xDGConfigPath","XDG_CONFIG_HOME","platform","APPDATA"],"sources":["../src/config-path.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport fs from 'fs';\nimport _ from 'lodash';\nimport path from 'path';\n\nimport { CHARACTER_ENCODING } from '@verdaccio/core';\n\nimport { fileExists, folderExists } from './config-utils';\n\nconst CONFIG_FILE = 'config.yaml';\nconst XDG = 'xdg';\nconst WIN = 'win';\nconst WIN32 = 'win32';\n// eslint-disable-next-line\nconst pkgJSON = {\n name: 'verdaccio',\n};\n\nexport type SetupDirectory = {\n path: string;\n type: string;\n};\n\nconst debug = buildDebug('verdaccio:config');\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 // console.log(process.env);\n if (typeof configPath !== 'undefined') {\n return path.resolve(configPath);\n }\n\n const configPaths: SetupDirectory[] = getConfigPaths();\n debug('%o posible locations found', configPaths.length);\n if (_.isEmpty(configPaths)) {\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('previous location exist already %s', primaryConf?.path);\n return primaryConf.path;\n }\n\n // @ts-ignore\n return createConfigFile(_.head(configPaths)).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(): Buffer {\n const pathDefaultConf: string = path.resolve(__dirname, 'conf/default.yaml');\n try {\n debug('default configuration file %s', pathDefaultConf);\n fs.accessSync(pathDefaultConf, fs.constants.R_OK);\n } catch {\n throw new TypeError('configuration file does not have enough permissions for reading');\n }\n // @ts-ignore\n return fs.readFileSync(pathDefaultConf, CHARACTER_ENCODING.UTF8);\n}\n\nfunction createConfigFolder(configLocation): void {\n fs.mkdirSync(path.dirname(configLocation.path), { recursive: true });\n debug(`Creating default config file in %o`, configLocation?.path);\n}\n\nfunction updateStorageLinks(configLocation, defaultConfig): string {\n if (configLocation.type !== XDG) {\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('directory detected path %s for type %s', currentValue?.path, currentValue.type);\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 * @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 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 (process.platform === WIN32 && process.env.APPDATA && folderExists(process.env.APPDATA)) {\n debug('is windows appdata: %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 return {\n path: path.resolve(path.join('.', pkgJSON.name, CONFIG_FILE)),\n type: 'def',\n };\n};\n\n/**\n * This should never happens, consider it DEPRECATED\n * @returns\n */\nconst getOldDirectory = (): SetupDirectory => {\n return {\n path: path.resolve(path.join('.', CONFIG_FILE)),\n type: 'old',\n };\n};\n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MACzD0C,IAAI,EAAEzC;IACR,CAAC;EACH;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMoD,mBAAmB,GAAG,MAA6B;EACvD,IAAIT,OAAO,CAACkB,QAAQ,KAAK3D,KAAK,IAAIyC,OAAO,CAACC,GAAG,CAACkB,OAAO,IAAI,IAAAd,yBAAY,EAACL,OAAO,CAACC,GAAG,CAACkB,OAAO,CAAC,EAAE;IAC1FzD,KAAK,CAAC,wBAAwB,EAAEsC,OAAO,CAACC,GAAG,CAACkB,OAAO,CAAC;IACpD,OAAO;MACLrD,IAAI,EAAEA,aAAI,CAACC,OAAO,CAACD,aAAI,CAACqC,IAAI,CAACH,OAAO,CAACC,GAAG,CAACkB,OAAO,EAAE3D,OAAO,CAACC,IAAI,EAAEL,WAAW,CAAC,CAAC;MAC7E0C,IAAI,EAAExC;IACR,CAAC;EACH;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMoD,2BAA2B,GAAG,MAAsB;EACxD,OAAO;IACL5C,IAAI,EAAEA,aAAI,CAACC,OAAO,CAACD,aAAI,CAACqC,IAAI,CAAC,GAAG,EAAE3C,OAAO,CAACC,IAAI,EAAEL,WAAW,CAAC,CAAC;IAC7D0C,IAAI,EAAE;EACR,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMa,eAAe,GAAG,MAAsB;EAC5C,OAAO;IACL7C,IAAI,EAAEA,aAAI,CAACC,OAAO,CAACD,aAAI,CAACqC,IAAI,CAAC,GAAG,EAAE/C,WAAW,CAAC,CAAC;IAC/C0C,IAAI,EAAE;EACR,CAAC;AACH,CAAC"}
|
package/build/config-utils.js
CHANGED
|
@@ -5,11 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.fileExists = fileExists;
|
|
7
7
|
exports.folderExists = folderExists;
|
|
8
|
-
|
|
9
8
|
var _fs = _interopRequireDefault(require("fs"));
|
|
10
|
-
|
|
11
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
10
|
/**
|
|
14
11
|
* Check whether the path already exist.
|
|
15
12
|
* @param {String} path
|
|
@@ -18,23 +15,20 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
15
|
function folderExists(path) {
|
|
19
16
|
try {
|
|
20
17
|
const stat = _fs.default.statSync(path);
|
|
21
|
-
|
|
22
18
|
return stat.isDirectory();
|
|
23
19
|
} catch (_) {
|
|
24
20
|
return false;
|
|
25
21
|
}
|
|
26
22
|
}
|
|
23
|
+
|
|
27
24
|
/**
|
|
28
25
|
* Check whether the file already exist.
|
|
29
26
|
* @param {String} path
|
|
30
27
|
* @return {Boolean}
|
|
31
28
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
29
|
function fileExists(path) {
|
|
35
30
|
try {
|
|
36
31
|
const stat = _fs.default.statSync(path);
|
|
37
|
-
|
|
38
32
|
return stat.isFile();
|
|
39
33
|
} catch (_) {
|
|
40
34
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-utils.js","names":["folderExists","path","stat","fs","statSync","isDirectory","_","fileExists","isFile"],"sources":["../src/config-utils.ts"],"sourcesContent":["import fs from 'fs';\n\n/**\n * Check whether the path already exist.\n * @param {String} path\n * @return {Boolean}\n */\nexport function folderExists(path: string): boolean {\n try {\n const stat = fs.statSync(path);\n return stat.isDirectory();\n } catch (_: any) {\n return false;\n }\n}\n\n/**\n * Check whether the file already exist.\n * @param {String} path\n * @return {Boolean}\n */\nexport function fileExists(path: string): boolean {\n try {\n const stat = fs.statSync(path);\n return stat.isFile();\n } catch (_: any) {\n return false;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config-utils.js","names":["folderExists","path","stat","fs","statSync","isDirectory","_","fileExists","isFile"],"sources":["../src/config-utils.ts"],"sourcesContent":["import fs from 'fs';\n\n/**\n * Check whether the path already exist.\n * @param {String} path\n * @return {Boolean}\n */\nexport function folderExists(path: string): boolean {\n try {\n const stat = fs.statSync(path);\n return stat.isDirectory();\n } catch (_: any) {\n return false;\n }\n}\n\n/**\n * Check whether the file already exist.\n * @param {String} path\n * @return {Boolean}\n */\nexport function fileExists(path: string): boolean {\n try {\n const stat = fs.statSync(path);\n return stat.isFile();\n } catch (_: any) {\n return false;\n }\n}\n"],"mappings":";;;;;;;AAAA;AAAoB;AAEpB;AACA;AACA;AACA;AACA;AACO,SAASA,YAAY,CAACC,IAAY,EAAW;EAClD,IAAI;IACF,MAAMC,IAAI,GAAGC,WAAE,CAACC,QAAQ,CAACH,IAAI,CAAC;IAC9B,OAAOC,IAAI,CAACG,WAAW,EAAE;EAC3B,CAAC,CAAC,OAAOC,CAAM,EAAE;IACf,OAAO,KAAK;EACd;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,UAAU,CAACN,IAAY,EAAW;EAChD,IAAI;IACF,MAAMC,IAAI,GAAGC,WAAE,CAACC,QAAQ,CAACH,IAAI,CAAC;IAC9B,OAAOC,IAAI,CAACM,MAAM,EAAE;EACtB,CAAC,CAAC,OAAOF,CAAM,EAAE;IACf,OAAO,KAAK;EACd;AACF"}
|
package/build/config.js
CHANGED
|
@@ -4,54 +4,39 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.WEB_TITLE = exports.Config = void 0;
|
|
7
|
-
|
|
8
7
|
var _assert = _interopRequireDefault(require("assert"));
|
|
9
|
-
|
|
10
8
|
var _debug = _interopRequireDefault(require("debug"));
|
|
11
|
-
|
|
12
9
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
|
-
|
|
14
10
|
var _core = require("@verdaccio/core");
|
|
15
|
-
|
|
16
11
|
var _utils = require("@verdaccio/utils");
|
|
17
|
-
|
|
18
12
|
var _agent = require("./agent");
|
|
19
|
-
|
|
20
13
|
var _packageAccess = require("./package-access");
|
|
21
|
-
|
|
22
14
|
var _security = require("./security");
|
|
23
|
-
|
|
24
15
|
var _serverSettings = _interopRequireDefault(require("./serverSettings"));
|
|
25
|
-
|
|
26
16
|
var _token = require("./token");
|
|
27
|
-
|
|
28
17
|
var _uplinks = require("./uplinks");
|
|
29
|
-
|
|
30
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
19
|
const strategicConfigProps = ['uplinks', 'packages'];
|
|
33
20
|
const allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];
|
|
34
21
|
const debug = (0, _debug.default)('verdaccio:config');
|
|
35
22
|
const WEB_TITLE = 'Verdaccio';
|
|
23
|
+
|
|
36
24
|
/**
|
|
37
25
|
* Coordinates the application configuration
|
|
38
26
|
*/
|
|
39
|
-
|
|
40
27
|
exports.WEB_TITLE = WEB_TITLE;
|
|
41
|
-
|
|
42
28
|
class Config {
|
|
43
29
|
// @deprecated use configPath instead
|
|
30
|
+
|
|
44
31
|
// @ts-ignore
|
|
32
|
+
|
|
45
33
|
constructor(config) {
|
|
46
34
|
var _config$flags;
|
|
47
|
-
|
|
48
35
|
const self = this;
|
|
49
36
|
this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;
|
|
50
|
-
|
|
51
37
|
if (!config.configPath) {
|
|
52
38
|
throw new Error('config_path is required');
|
|
53
39
|
}
|
|
54
|
-
|
|
55
40
|
this.config_path = config.config_path ?? config.configPath;
|
|
56
41
|
this.configPath = config.configPath;
|
|
57
42
|
debug('config path: %s', this.configPath);
|
|
@@ -61,73 +46,68 @@ class Config {
|
|
|
61
46
|
this.flags = {
|
|
62
47
|
searchRemote: ((_config$flags = config.flags) === null || _config$flags === void 0 ? void 0 : _config$flags.searchRemote) ?? true
|
|
63
48
|
};
|
|
64
|
-
|
|
65
49
|
for (const configProp in config) {
|
|
66
50
|
if (self[configProp] == null) {
|
|
67
51
|
self[configProp] = config[configProp];
|
|
68
52
|
}
|
|
69
|
-
}
|
|
70
|
-
|
|
53
|
+
}
|
|
71
54
|
|
|
55
|
+
// @ts-ignore
|
|
72
56
|
if (_lodash.default.isNil(this.user_agent)) {
|
|
73
57
|
this.user_agent = (0, _agent.getUserAgent)();
|
|
74
|
-
}
|
|
75
|
-
|
|
58
|
+
}
|
|
76
59
|
|
|
77
|
-
|
|
60
|
+
// some weird shell scripts are valid yaml files parsed as string
|
|
61
|
+
(0, _assert.default)(_lodash.default.isObject(config), _core.APP_ERROR.CONFIG_NOT_VALID);
|
|
78
62
|
|
|
63
|
+
// sanity check for strategic config properties
|
|
79
64
|
strategicConfigProps.forEach(function (x) {
|
|
80
65
|
if (self[x] == null) {
|
|
81
66
|
self[x] = {};
|
|
82
67
|
}
|
|
83
|
-
|
|
84
68
|
(0, _assert.default)((0, _utils.isObject)(self[x]), `CONFIG: bad "${x}" value (object expected)`);
|
|
85
69
|
});
|
|
86
70
|
this.uplinks = (0, _uplinks.sanityCheckUplinksProps)((0, _uplinks.uplinkSanityCheck)(this.uplinks));
|
|
87
|
-
this.packages = (0, _packageAccess.normalisePackageAccess)(self.packages);
|
|
71
|
+
this.packages = (0, _packageAccess.normalisePackageAccess)(self.packages);
|
|
88
72
|
|
|
73
|
+
// loading these from ENV if aren't in config
|
|
89
74
|
allowedEnvConfig.forEach(envConf => {
|
|
90
75
|
if (!(envConf in self)) {
|
|
91
76
|
self[envConf] = process.env[envConf] || process.env[envConf.toUpperCase()];
|
|
92
77
|
}
|
|
93
|
-
});
|
|
94
|
-
// @ts-ignore
|
|
78
|
+
});
|
|
95
79
|
|
|
80
|
+
// unique identifier of self server (or a cluster), used to avoid loops
|
|
81
|
+
// @ts-ignore
|
|
96
82
|
if (!this.server_id) {
|
|
97
83
|
this.server_id = (0, _utils.generateRandomHexString)(6);
|
|
98
84
|
}
|
|
99
85
|
}
|
|
86
|
+
|
|
100
87
|
/**
|
|
101
88
|
* Check for package spec
|
|
102
89
|
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
90
|
getMatchedPackagesSpec(pkgName) {
|
|
106
91
|
// TODO: remove this method and replace by library utils
|
|
107
92
|
return (0, _utils.getMatchedPackagesSpec)(pkgName, this.packages);
|
|
108
93
|
}
|
|
94
|
+
|
|
109
95
|
/**
|
|
110
96
|
* Store or create whether receive a secret key
|
|
111
97
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
98
|
checkSecretKey(secret) {
|
|
115
99
|
debug('check secret key');
|
|
116
|
-
|
|
117
100
|
if (_lodash.default.isString(secret) && _lodash.default.isEmpty(secret) === false) {
|
|
118
101
|
this.secret = secret;
|
|
119
102
|
debug('reusing previous key');
|
|
120
103
|
return secret;
|
|
121
|
-
}
|
|
104
|
+
}
|
|
105
|
+
// it generates a secret key
|
|
122
106
|
// FUTURE: this might be an external secret key, perhaps within config file?
|
|
123
|
-
|
|
124
|
-
|
|
125
107
|
debug('generate a new key');
|
|
126
108
|
this.secret = (0, _token.generateRandomSecretKey)();
|
|
127
109
|
return this.secret;
|
|
128
110
|
}
|
|
129
|
-
|
|
130
111
|
}
|
|
131
|
-
|
|
132
112
|
exports.Config = Config;
|
|
133
113
|
//# sourceMappingURL=config.js.map
|
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["strategicConfigProps","allowedEnvConfig","debug","buildDebug","WEB_TITLE","Config","constructor","config","self","storage","process","env","VERDACCIO_STORAGE_PATH","configPath","Error","config_path","plugins","security","_","merge","defaultSecurity","serverSettings","flags","searchRemote","configProp","isNil","user_agent","getUserAgent","assert","isObject","APP_ERROR","CONFIG_NOT_VALID","forEach","x","uplinks","sanityCheckUplinksProps","uplinkSanityCheck","packages","normalisePackageAccess","envConf","toUpperCase","server_id","generateRandomHexString","getMatchedPackagesSpec","pkgName","checkSecretKey","secret","isString","isEmpty","generateRandomSecretKey"],"sources":["../src/config.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { APP_ERROR } from '@verdaccio/core';\nimport {\n Config as AppConfig,\n AuthConf,\n ConfigYaml,\n FlagsConfig,\n PackageAccess,\n PackageList,\n Security,\n ServerSettingsConf,\n} from '@verdaccio/types';\nimport { generateRandomHexString, getMatchedPackagesSpec, isObject } from '@verdaccio/utils';\n\nimport { getUserAgent } from './agent';\nimport { normalisePackageAccess } from './package-access';\nimport { defaultSecurity } from './security';\nimport serverSettings 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/**\n * Coordinates the application configuration\n */\nclass Config implements AppConfig {\n public user_agent: string;\n public uplinks: any;\n public packages: PackageList;\n public users: any;\n public auth: AuthConf;\n public server_id: string;\n // @deprecated use configPath instead\n public config_path: string;\n public configPath: string;\n public storage: string | void;\n\n public plugins: string | void | null;\n public security: Security;\n public serverSettings: ServerSettingsConf;\n // @ts-ignore\n public secret: string;\n public flags: FlagsConfig;\n\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 throw new Error('config_path is required');\n }\n this.config_path = config.config_path ?? (config.configPath as string);\n this.configPath = config.configPath;\n debug('config path: %s', this.configPath);\n this.plugins = config.plugins;\n this.security = _.merge(defaultSecurity, config.security);\n this.serverSettings = serverSettings;\n this.flags = {\n searchRemote: config.flags?.searchRemote ?? true,\n };\n\n for (const configProp in config) {\n if (self[configProp] == null) {\n self[configProp] = config[configProp];\n }\n }\n\n // @ts-ignore\n if (_.isNil(this.user_agent)) {\n this.user_agent = getUserAgent();\n }\n\n // some weird shell scripts are valid yaml files parsed as string\n assert(_.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(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 = generateRandomHexString(6);\n }\n }\n\n /**\n * Check for package spec\n */\n public getMatchedPackagesSpec(pkgName: string): PackageAccess | void {\n // TODO: remove this method and replace by library utils\n return getMatchedPackagesSpec(pkgName, this.packages);\n }\n\n /**\n * Store or create whether receive a secret key\n */\n public checkSecretKey(secret?: string): string {\n debug('check secret key');\n if (_.isString(secret) && _.isEmpty(secret) === false) {\n this.secret = secret;\n debug('reusing previous key');\n return secret;\n }\n // it generates a secret key\n // FUTURE: this might be an external secret key, perhaps within config file?\n debug('generate a new key');\n this.secret = generateRandomSecretKey();\n return this.secret;\n }\n}\n\nexport { Config };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","names":["strategicConfigProps","allowedEnvConfig","debug","buildDebug","WEB_TITLE","Config","constructor","config","self","storage","process","env","VERDACCIO_STORAGE_PATH","configPath","Error","config_path","plugins","security","_","merge","defaultSecurity","serverSettings","flags","searchRemote","configProp","isNil","user_agent","getUserAgent","assert","isObject","APP_ERROR","CONFIG_NOT_VALID","forEach","x","uplinks","sanityCheckUplinksProps","uplinkSanityCheck","packages","normalisePackageAccess","envConf","toUpperCase","server_id","generateRandomHexString","getMatchedPackagesSpec","pkgName","checkSecretKey","secret","isString","isEmpty","generateRandomSecretKey"],"sources":["../src/config.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { APP_ERROR } from '@verdaccio/core';\nimport {\n Config as AppConfig,\n AuthConf,\n ConfigYaml,\n FlagsConfig,\n PackageAccess,\n PackageList,\n Security,\n ServerSettingsConf,\n} from '@verdaccio/types';\nimport { generateRandomHexString, getMatchedPackagesSpec, isObject } from '@verdaccio/utils';\n\nimport { getUserAgent } from './agent';\nimport { normalisePackageAccess } from './package-access';\nimport { defaultSecurity } from './security';\nimport serverSettings 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/**\n * Coordinates the application configuration\n */\nclass Config implements AppConfig {\n public user_agent: string;\n public uplinks: any;\n public packages: PackageList;\n public users: any;\n public auth: AuthConf;\n public server_id: string;\n // @deprecated use configPath instead\n public config_path: string;\n public configPath: string;\n public storage: string | void;\n\n public plugins: string | void | null;\n public security: Security;\n public serverSettings: ServerSettingsConf;\n // @ts-ignore\n public secret: string;\n public flags: FlagsConfig;\n\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 throw new Error('config_path is required');\n }\n this.config_path = config.config_path ?? (config.configPath as string);\n this.configPath = config.configPath;\n debug('config path: %s', this.configPath);\n this.plugins = config.plugins;\n this.security = _.merge(defaultSecurity, config.security);\n this.serverSettings = serverSettings;\n this.flags = {\n searchRemote: config.flags?.searchRemote ?? true,\n };\n\n for (const configProp in config) {\n if (self[configProp] == null) {\n self[configProp] = config[configProp];\n }\n }\n\n // @ts-ignore\n if (_.isNil(this.user_agent)) {\n this.user_agent = getUserAgent();\n }\n\n // some weird shell scripts are valid yaml files parsed as string\n assert(_.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(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 = generateRandomHexString(6);\n }\n }\n\n /**\n * Check for package spec\n */\n public getMatchedPackagesSpec(pkgName: string): PackageAccess | void {\n // TODO: remove this method and replace by library utils\n return getMatchedPackagesSpec(pkgName, this.packages);\n }\n\n /**\n * Store or create whether receive a secret key\n */\n public checkSecretKey(secret?: string): string {\n debug('check secret key');\n if (_.isString(secret) && _.isEmpty(secret) === false) {\n this.secret = secret;\n debug('reusing previous key');\n return secret;\n }\n // it generates a secret key\n // FUTURE: this might be an external secret key, perhaps within config file?\n debug('generate a new key');\n this.secret = generateRandomSecretKey();\n return this.secret;\n }\n}\n\nexport { Config };\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AAWA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAuE;AAEvE,MAAMA,oBAAoB,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC;AACpD,MAAMC,gBAAgB,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,UAAU,CAAC;AAClE,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,kBAAkB,CAAC;AAErC,MAAMC,SAAS,GAAG,WAAW;;AAEpC;AACA;AACA;AAFA;AAGA,MAAMC,MAAM,CAAsB;EAOhC;;EAQA;;EAIOC,WAAW,CAACC,MAA4C,EAAE;IAAA;IAC/D,MAAMC,IAAI,GAAG,IAAI;IACjB,IAAI,CAACC,OAAO,GAAGC,OAAO,CAACC,GAAG,CAACC,sBAAsB,IAAIL,MAAM,CAACE,OAAO;I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ACpB;AACF;AAAC"}
|
package/build/index.js
CHANGED
|
@@ -33,9 +33,7 @@ Object.defineProperty(exports, "parseConfigFile", {
|
|
|
33
33
|
return _parse.parseConfigFile;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
|
|
37
36
|
var _config = require("./config");
|
|
38
|
-
|
|
39
37
|
Object.keys(_config).forEach(function (key) {
|
|
40
38
|
if (key === "default" || key === "__esModule") return;
|
|
41
39
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -47,9 +45,7 @@ Object.keys(_config).forEach(function (key) {
|
|
|
47
45
|
}
|
|
48
46
|
});
|
|
49
47
|
});
|
|
50
|
-
|
|
51
48
|
var _configPath = require("./config-path");
|
|
52
|
-
|
|
53
49
|
Object.keys(_configPath).forEach(function (key) {
|
|
54
50
|
if (key === "default" || key === "__esModule") return;
|
|
55
51
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -61,9 +57,7 @@ Object.keys(_configPath).forEach(function (key) {
|
|
|
61
57
|
}
|
|
62
58
|
});
|
|
63
59
|
});
|
|
64
|
-
|
|
65
60
|
var _token = require("./token");
|
|
66
|
-
|
|
67
61
|
Object.keys(_token).forEach(function (key) {
|
|
68
62
|
if (key === "default" || key === "__esModule") return;
|
|
69
63
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -75,9 +69,7 @@ Object.keys(_token).forEach(function (key) {
|
|
|
75
69
|
}
|
|
76
70
|
});
|
|
77
71
|
});
|
|
78
|
-
|
|
79
72
|
var _packageAccess = require("./package-access");
|
|
80
|
-
|
|
81
73
|
Object.keys(_packageAccess).forEach(function (key) {
|
|
82
74
|
if (key === "default" || key === "__esModule") return;
|
|
83
75
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -89,11 +81,8 @@ Object.keys(_packageAccess).forEach(function (key) {
|
|
|
89
81
|
}
|
|
90
82
|
});
|
|
91
83
|
});
|
|
92
|
-
|
|
93
84
|
var _parse = require("./parse");
|
|
94
|
-
|
|
95
85
|
var _uplinks = require("./uplinks");
|
|
96
|
-
|
|
97
86
|
Object.keys(_uplinks).forEach(function (key) {
|
|
98
87
|
if (key === "default" || key === "__esModule") return;
|
|
99
88
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -105,9 +94,7 @@ Object.keys(_uplinks).forEach(function (key) {
|
|
|
105
94
|
}
|
|
106
95
|
});
|
|
107
96
|
});
|
|
108
|
-
|
|
109
97
|
var _security = require("./security");
|
|
110
|
-
|
|
111
98
|
Object.keys(_security).forEach(function (key) {
|
|
112
99
|
if (key === "default" || key === "__esModule") return;
|
|
113
100
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -119,9 +106,7 @@ Object.keys(_security).forEach(function (key) {
|
|
|
119
106
|
}
|
|
120
107
|
});
|
|
121
108
|
});
|
|
122
|
-
|
|
123
109
|
var _user = require("./user");
|
|
124
|
-
|
|
125
110
|
Object.keys(_user).forEach(function (key) {
|
|
126
111
|
if (key === "default" || key === "__esModule") return;
|
|
127
112
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -133,10 +118,7 @@ Object.keys(_user).forEach(function (key) {
|
|
|
133
118
|
}
|
|
134
119
|
});
|
|
135
120
|
});
|
|
136
|
-
|
|
137
121
|
var _builder = _interopRequireDefault(require("./builder"));
|
|
138
|
-
|
|
139
122
|
var _conf = require("./conf");
|
|
140
|
-
|
|
141
123
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
142
124
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from './config';\nexport * from './config-path';\nexport * from './token';\nexport * from './package-access';\nexport { fromJStoYAML, parseConfigFile } from './parse';\nexport * from './uplinks';\nexport * from './security';\nexport * from './user';\nexport { default as ConfigBuilder } from './builder';\nexport { getDefaultConfig } from './conf';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from './config';\nexport * from './config-path';\nexport * from './token';\nexport * from './package-access';\nexport { fromJStoYAML, parseConfigFile } from './parse';\nexport * from './uplinks';\nexport * from './security';\nexport * from './user';\nexport { default as ConfigBuilder } from './builder';\nexport { getDefaultConfig } from './conf';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AACA;AAA0C"}
|
package/build/package-access.js
CHANGED
|
@@ -6,15 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.ROLES = exports.PACKAGE_ACCESS = void 0;
|
|
7
7
|
exports.normalisePackageAccess = normalisePackageAccess;
|
|
8
8
|
exports.normalizeUserList = normalizeUserList;
|
|
9
|
-
|
|
10
9
|
var _assert = _interopRequireDefault(require("assert"));
|
|
11
|
-
|
|
12
10
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
|
-
|
|
14
11
|
var _core = require("@verdaccio/core");
|
|
15
|
-
|
|
16
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
13
|
// @deprecated use @verdaccio/core:authUtils
|
|
19
14
|
const ROLES = {
|
|
20
15
|
$ALL: '$all',
|
|
@@ -24,23 +19,22 @@ const ROLES = {
|
|
|
24
19
|
DEPRECATED_ALL: '@all',
|
|
25
20
|
DEPRECATED_AUTH: '@authenticated',
|
|
26
21
|
DEPRECATED_ANONYMOUS: '@anonymous'
|
|
27
|
-
};
|
|
22
|
+
};
|
|
28
23
|
|
|
24
|
+
// @deprecated use @verdaccio/core:authUtils
|
|
29
25
|
exports.ROLES = ROLES;
|
|
30
26
|
const PACKAGE_ACCESS = {
|
|
31
27
|
SCOPE: '@*/*',
|
|
32
28
|
ALL: '**'
|
|
33
29
|
};
|
|
34
30
|
exports.PACKAGE_ACCESS = PACKAGE_ACCESS;
|
|
35
|
-
|
|
36
31
|
function normalizeUserList(groupsList) {
|
|
37
32
|
const result = [];
|
|
38
|
-
|
|
39
33
|
if (_lodash.default.isNil(groupsList)) {
|
|
40
34
|
return result;
|
|
41
|
-
}
|
|
42
|
-
|
|
35
|
+
}
|
|
43
36
|
|
|
37
|
+
// if it's a string, split it to array
|
|
44
38
|
if (_lodash.default.isString(groupsList)) {
|
|
45
39
|
const groupsArray = groupsList.split(/\s+/);
|
|
46
40
|
result.push(groupsArray);
|
|
@@ -49,14 +43,12 @@ function normalizeUserList(groupsList) {
|
|
|
49
43
|
} else {
|
|
50
44
|
throw _core.errorUtils.getInternalError('CONFIG: bad package acl (array or string expected): ' + JSON.stringify(groupsList));
|
|
51
45
|
}
|
|
52
|
-
|
|
53
46
|
return _lodash.default.flatten(result);
|
|
54
47
|
}
|
|
55
|
-
|
|
56
48
|
function normalisePackageAccess(packages) {
|
|
57
|
-
const normalizedPkgs = {
|
|
49
|
+
const normalizedPkgs = {
|
|
50
|
+
...packages
|
|
58
51
|
};
|
|
59
|
-
|
|
60
52
|
if (_lodash.default.isNil(normalizedPkgs['**'])) {
|
|
61
53
|
normalizedPkgs['**'] = {
|
|
62
54
|
access: [],
|
|
@@ -65,7 +57,6 @@ function normalisePackageAccess(packages) {
|
|
|
65
57
|
proxy: []
|
|
66
58
|
};
|
|
67
59
|
}
|
|
68
|
-
|
|
69
60
|
for (const pkg in packages) {
|
|
70
61
|
if (Object.prototype.hasOwnProperty.call(packages, pkg)) {
|
|
71
62
|
const packageAccess = packages[pkg];
|
|
@@ -73,12 +64,11 @@ function normalisePackageAccess(packages) {
|
|
|
73
64
|
(0, _assert.default)(isInvalid, `CONFIG: bad "'${pkg}'" package description (object expected)`);
|
|
74
65
|
normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);
|
|
75
66
|
normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);
|
|
76
|
-
normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);
|
|
77
|
-
|
|
67
|
+
normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);
|
|
68
|
+
// if unpublish is not defined, we set to false to fallback in publish access
|
|
78
69
|
normalizedPkgs[pkg].unpublish = _lodash.default.isUndefined(packageAccess.unpublish) ? false : normalizeUserList(packageAccess.unpublish);
|
|
79
70
|
}
|
|
80
71
|
}
|
|
81
|
-
|
|
82
72
|
return normalizedPkgs;
|
|
83
73
|
}
|
|
84
74
|
//# sourceMappingURL=package-access.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-access.js","names":["ROLES","$ALL","ALL","$AUTH","$ANONYMOUS","DEPRECATED_ALL","DEPRECATED_AUTH","DEPRECATED_ANONYMOUS","PACKAGE_ACCESS","SCOPE","normalizeUserList","groupsList","result","_","isNil","isString","groupsArray","split","push","Array","isArray","errorUtils","getInternalError","JSON","stringify","flatten","normalisePackageAccess","packages","normalizedPkgs","access","publish","unpublish","proxy","pkg","Object","prototype","hasOwnProperty","call","packageAccess","isInvalid","isObject","assert","isUndefined"],"sources":["../src/package-access.ts"],"sourcesContent":["import assert from 'assert';\nimport _ from 'lodash';\n\nimport { errorUtils } from '@verdaccio/core';\nimport { PackageAccess } from '@verdaccio/types';\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)) {\n return result;\n }\n\n // if it's a string, split it to array\n if (_.isString(groupsList)) {\n const groupsArray = groupsList.split(/\\s+/);\n\n result.push(groupsArray);\n } else if (Array.isArray(groupsList)) {\n result.push(groupsList);\n } else {\n throw errorUtils.getInternalError(\n 'CONFIG: bad package acl (array or string expected): ' + JSON.stringify(groupsList)\n );\n }\n\n return _.flatten(result);\n}\n\nexport function normalisePackageAccess(packages: LegacyPackageList): LegacyPackageList {\n const normalizedPkgs: LegacyPackageList = { ...packages };\n if (_.isNil(normalizedPkgs['**'])) {\n normalizedPkgs['**'] = {\n access: [],\n publish: [],\n unpublish: [],\n proxy: [],\n };\n }\n\n for (const pkg in packages) {\n if (Object.prototype.hasOwnProperty.call(packages, pkg)) {\n const packageAccess = packages[pkg];\n const isInvalid = _.isObject(packageAccess) && _.isArray(packageAccess) === false;\n assert(isInvalid, `CONFIG: bad \"'${pkg}'\" package description (object expected)`);\n\n normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);\n normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);\n normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);\n // if unpublish is not defined, we set to false to fallback in publish access\n normalizedPkgs[pkg].unpublish = _.isUndefined(packageAccess.unpublish)\n ? false\n : normalizeUserList(packageAccess.unpublish);\n }\n }\n\n return normalizedPkgs;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"package-access.js","names":["ROLES","$ALL","ALL","$AUTH","$ANONYMOUS","DEPRECATED_ALL","DEPRECATED_AUTH","DEPRECATED_ANONYMOUS","PACKAGE_ACCESS","SCOPE","normalizeUserList","groupsList","result","_","isNil","isString","groupsArray","split","push","Array","isArray","errorUtils","getInternalError","JSON","stringify","flatten","normalisePackageAccess","packages","normalizedPkgs","access","publish","unpublish","proxy","pkg","Object","prototype","hasOwnProperty","call","packageAccess","isInvalid","isObject","assert","isUndefined"],"sources":["../src/package-access.ts"],"sourcesContent":["import assert from 'assert';\nimport _ from 'lodash';\n\nimport { errorUtils } from '@verdaccio/core';\nimport { PackageAccess } from '@verdaccio/types';\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)) {\n return result;\n }\n\n // if it's a string, split it to array\n if (_.isString(groupsList)) {\n const groupsArray = groupsList.split(/\\s+/);\n\n result.push(groupsArray);\n } else if (Array.isArray(groupsList)) {\n result.push(groupsList);\n } else {\n throw errorUtils.getInternalError(\n 'CONFIG: bad package acl (array or string expected): ' + JSON.stringify(groupsList)\n );\n }\n\n return _.flatten(result);\n}\n\nexport function normalisePackageAccess(packages: LegacyPackageList): LegacyPackageList {\n const normalizedPkgs: LegacyPackageList = { ...packages };\n if (_.isNil(normalizedPkgs['**'])) {\n normalizedPkgs['**'] = {\n access: [],\n publish: [],\n unpublish: [],\n proxy: [],\n };\n }\n\n for (const pkg in packages) {\n if (Object.prototype.hasOwnProperty.call(packages, pkg)) {\n const packageAccess = packages[pkg];\n const isInvalid = _.isObject(packageAccess) && _.isArray(packageAccess) === false;\n assert(isInvalid, `CONFIG: bad \"'${pkg}'\" package description (object expected)`);\n\n normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);\n normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);\n normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);\n // if unpublish is not defined, we set to false to fallback in publish access\n normalizedPkgs[pkg].unpublish = _.isUndefined(packageAccess.unpublish)\n ? false\n : normalizeUserList(packageAccess.unpublish);\n }\n }\n\n return normalizedPkgs;\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAEA;AAA6C;AAO7C;AACO,MAAMA,KAAK,GAAG;EACnBC,IAAI,EAAE,MAAM;EACZC,GAAG,EAAE,KAAK;EACVC,KAAK,EAAE,gBAAgB;EACvBC,UAAU,EAAE,YAAY;EACxBC,cAAc,EAAE,MAAM;EACtBC,eAAe,EAAE,gBAAgB;EACjCC,oBAAoB,EAAE;AACxB,CAAC;;AAED;AAAA;AACO,MAAMC,cAAc,GAAG;EAC5BC,KAAK,EAAE,MAAM;EACbP,GAAG,EAAE;AACP,CAAC;AAAC;AAEK,SAASQ,iBAAiB,CAACC,UAAe,EAAO;EACtD,MAAMC,MAAa,GAAG,EAAE;EACxB,IAAIC,eAAC,CAACC,KAAK,CAACH,UAAU,CAAC,EAAE;IACvB,OAAOC,MAAM;EACf;;EAEA;EACA,IAAIC,eAAC,CAACE,QAAQ,CAACJ,UAAU,CAAC,EAAE;IAC1B,MAAMK,WAAW,GAAGL,UAAU,CAACM,KAAK,CAAC,KAAK,CAAC;IAE3CL,MAAM,CAACM,IAAI,CAACF,WAAW,CAAC;EAC1B,CAAC,MAAM,IAAIG,KAAK,CAACC,OAAO,CAACT,UAAU,CAAC,EAAE;IACpCC,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AAS,GAAGlB,eAAC,CAAC6B,WAAW,CAACJ,aAAa,CAACP,SAAS,CAAC,GAClE,KAAK,GACLrB,iBAAiB,CAAC4B,aAAa,CAACP,SAAS,CAAC;IAChD;EACF;EAEA,OAAOH,cAAc;AACvB"}
|
package/build/parse.js
CHANGED
|
@@ -5,51 +5,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.fromJStoYAML = fromJStoYAML;
|
|
7
7
|
exports.parseConfigFile = parseConfigFile;
|
|
8
|
-
|
|
9
8
|
var _debug = _interopRequireDefault(require("debug"));
|
|
10
|
-
|
|
11
9
|
var _fs = _interopRequireDefault(require("fs"));
|
|
12
|
-
|
|
13
10
|
var _lodash = require("lodash");
|
|
14
|
-
|
|
15
11
|
var _yaml = _interopRequireDefault(require("yaml"));
|
|
16
|
-
|
|
17
12
|
var _core = require("@verdaccio/core");
|
|
18
|
-
|
|
19
13
|
var _configUtils = require("./config-utils");
|
|
20
|
-
|
|
21
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
23
15
|
const debug = (0, _debug.default)('verdaccio:config:parse');
|
|
16
|
+
|
|
24
17
|
/**
|
|
25
18
|
* Parse a config file from yaml to JSON.
|
|
26
19
|
* @param configPath the absolute path of the configuration file
|
|
27
20
|
*/
|
|
28
|
-
|
|
29
21
|
function parseConfigFile(configPath) {
|
|
30
22
|
debug('parse config file %s', configPath);
|
|
31
|
-
|
|
32
23
|
if (!(0, _configUtils.fileExists)(configPath)) {
|
|
33
24
|
throw new Error(`config file does not exist or not reachable`);
|
|
34
25
|
}
|
|
35
|
-
|
|
36
26
|
debug('parsing config file: %o', configPath);
|
|
37
|
-
|
|
38
27
|
try {
|
|
39
28
|
if (/\.ya?ml$/i.test(configPath)) {
|
|
40
29
|
const yamlConfig = _yaml.default.parse(_fs.default.readFileSync(configPath, 'utf8'), {
|
|
41
30
|
strict: false
|
|
42
31
|
});
|
|
43
|
-
|
|
44
32
|
return Object.assign({}, yamlConfig, {
|
|
45
33
|
configPath,
|
|
46
34
|
// @deprecated use configPath instead
|
|
47
35
|
config_path: configPath
|
|
48
36
|
});
|
|
49
37
|
}
|
|
50
|
-
|
|
51
38
|
const jsonConfig = require(configPath);
|
|
52
|
-
|
|
53
39
|
return Object.assign({}, jsonConfig, {
|
|
54
40
|
configPath,
|
|
55
41
|
// @deprecated use configPath instead
|
|
@@ -60,14 +46,11 @@ function parseConfigFile(configPath) {
|
|
|
60
46
|
debug('config module not found %o error: %o', configPath, e.message);
|
|
61
47
|
throw Error(_core.APP_ERROR.CONFIG_NOT_VALID);
|
|
62
48
|
}
|
|
63
|
-
|
|
64
49
|
throw e;
|
|
65
50
|
}
|
|
66
51
|
}
|
|
67
|
-
|
|
68
52
|
function fromJStoYAML(config) {
|
|
69
53
|
debug('convert config from JSON to YAML');
|
|
70
|
-
|
|
71
54
|
if ((0, _lodash.isObject)(config)) {
|
|
72
55
|
return _yaml.default.stringify(config);
|
|
73
56
|
} else {
|
package/build/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","names":["debug","buildDebug","parseConfigFile","configPath","fileExists","Error","test","yamlConfig","YAML","parse","fs","readFileSync","strict","Object","assign","config_path","jsonConfig","require","e","code","message","APP_ERROR","CONFIG_NOT_VALID","fromJStoYAML","config","isObject","stringify"],"sources":["../src/parse.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport fs from 'fs';\nimport { isObject } from 'lodash';\nimport YAML from 'yaml';\n\nimport { APP_ERROR } from '@verdaccio/core';\nimport { ConfigYaml } from '@verdaccio/types';\n\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.parse(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.stringify(config);\n } else {\n throw new Error(`config is not a valid object`);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse.js","names":["debug","buildDebug","parseConfigFile","configPath","fileExists","Error","test","yamlConfig","YAML","parse","fs","readFileSync","strict","Object","assign","config_path","jsonConfig","require","e","code","message","APP_ERROR","CONFIG_NOT_VALID","fromJStoYAML","config","isObject","stringify"],"sources":["../src/parse.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport fs from 'fs';\nimport { isObject } from 'lodash';\nimport YAML from 'yaml';\n\nimport { APP_ERROR } from '@verdaccio/core';\nimport { ConfigYaml } from '@verdaccio/types';\n\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.parse(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.stringify(config);\n } else {\n throw new Error(`config is not a valid object`);\n }\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AAEA;AAGA;AAA4C;AAE5C,MAAMA,KAAK,GAAG,IAAAC,cAAU,EAAC,wBAAwB,CAAC;;AAElD;AACA;AACA;AACA;AACO,SAASC,eAAe,CAACC,UAAkB,EAIhD;EACAH,KAAK,CAAC,sBAAsB,EAAEG,UAAU,CAAC;EACzC,IAAI,CAAC,IAAAC,uBAAU,EAACD,UAAU,CAAC,EAAE;IAC3B,MAAM,IAAIE,KAAK,CAAE,6CAA4C,CAAC;EAChE;EACAL,KAAK,CAAC,yBAAyB,EAAEG,UAAU,CAAC;EAC5C,IAAI;IACF,IAAI,WAAW,CAACG,IAAI,CAACH,UAAU,CAAC,EAAE;MAChC,MAAMI,UAAU,GAAGC,aAAI,CAACC,KAAK,CAACC,WAAE,CAACC,YAAY,CAACR,UAAU,EAAE,MAAM,CAAC,EAAE;QACjES,MAAM,EAAE;MACV,CAAC,CAAe;MAEhB,OAAOC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEP,UAAU,EAAE;QACnCJ,UAAU;QACV;QACAY,WAAW,EAAEZ;MACf,CAAC,CAAC;IACJ;IAEA,MAAMa,UAAU,GAAGC,OAAO,CAACd,UAAU,CAAe;IACpD,OAAOU,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEE,UAAU,EAAE;MACnCb,UAAU;MACV;MACAY,WAAW,EAAEZ;IACf,CAAC,CAAC;EACJ,CAAC,CAAC,OAAOe,CAAM,EAAE;IACf,IAAIA,CAAC,CAACC,IAAI,KAAK,kBAAkB,EAAE;MACjCnB,KAAK,CAAC,sCAAsC,EAAEG,UAAU,EAAEe,CAAC,CAACE,OAAO,CAAC;MACpE,MAAMf,KAAK,CAACgB,eAAS,CAACC,gBAAgB,CAAC;IACzC;IAEA,MAAMJ,CAAC;EACT;AACF;AAEO,SAASK,YAAY,CAACC,MAA2B,EAAiB;EACvExB,KAAK,CAAC,kCAAkC,CAAC;EACzC,IAAI,IAAAyB,gBAAQ,EAACD,MAAM,CAAC,EAAE;IACpB,OAAOhB,aAAI,CAACkB,SAAS,CAACF,MAAM,CAAC;EAC/B,CAAC,MAAM;IACL,MAAM,IAAInB,KAAK,CAAE,8BAA6B,CAAC;EACjD;AACF"}
|
package/build/security.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.js","names":["TIME_EXPIRATION_1H","defaultWebTokenOptions","sign","expiresIn","verify","defaultApiTokenConf","legacy","defaultSecurity","web","api"],"sources":["../src/security.ts"],"sourcesContent":["import { APITokenOptions, JWTOptions, Security } from '@verdaccio/types';\n\n// TODO: get this from core package\nexport const TIME_EXPIRATION_1H = '1h';\n\nconst defaultWebTokenOptions: JWTOptions = {\n sign: {\n // The expiration token for the website is 7 days\n expiresIn: TIME_EXPIRATION_1H,\n },\n verify: {},\n};\n\nconst defaultApiTokenConf: APITokenOptions = {\n legacy: true,\n};\n\nexport const defaultSecurity: Security = {\n web: defaultWebTokenOptions,\n api: defaultApiTokenConf,\n};\n"],"mappings":";;;;;;AAEA;AACO,MAAMA,kBAAkB,GAAG,
|
|
1
|
+
{"version":3,"file":"security.js","names":["TIME_EXPIRATION_1H","defaultWebTokenOptions","sign","expiresIn","verify","defaultApiTokenConf","legacy","defaultSecurity","web","api"],"sources":["../src/security.ts"],"sourcesContent":["import { APITokenOptions, JWTOptions, Security } from '@verdaccio/types';\n\n// TODO: get this from core package\nexport const TIME_EXPIRATION_1H = '1h';\n\nconst defaultWebTokenOptions: JWTOptions = {\n sign: {\n // The expiration token for the website is 7 days\n expiresIn: TIME_EXPIRATION_1H,\n },\n verify: {},\n};\n\nconst defaultApiTokenConf: APITokenOptions = {\n legacy: true,\n};\n\nexport const defaultSecurity: Security = {\n web: defaultWebTokenOptions,\n api: defaultApiTokenConf,\n};\n"],"mappings":";;;;;;AAEA;AACO,MAAMA,kBAAkB,GAAG,IAAI;AAAC;AAEvC,MAAMC,sBAAkC,GAAG;EACzCC,IAAI,EAAE;IACJ;IACAC,SAAS,EAAEH;EACb,CAAC;EACDI,MAAM,EAAE,CAAC;AACX,CAAC;AAED,MAAMC,mBAAoC,GAAG;EAC3CC,MAAM,EAAE;AACV,CAAC;AAEM,MAAMC,eAAyB,GAAG;EACvCC,GAAG,EAAEP,sBAAsB;EAC3BQ,GAAG,EAAEJ;AACP,CAAC;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverSettings.js","names":["rateLimit","windowMs","max","keepAliveTimeout"],"sources":["../src/serverSettings.ts"],"sourcesContent":["export default {\n // https://www.npmjs.com/package/express-rate-limit\n // values are intended to be high, please customize based on own needs\n rateLimit: {\n windowMs: 1000,\n max: 10000,\n },\n // deprecated\n keepAliveTimeout: 60,\n};\n"],"mappings":";;;;;;eAAe;EACb;EACA;EACAA,SAAS,EAAE;IACTC,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"serverSettings.js","names":["rateLimit","windowMs","max","keepAliveTimeout"],"sources":["../src/serverSettings.ts"],"sourcesContent":["export default {\n // https://www.npmjs.com/package/express-rate-limit\n // values are intended to be high, please customize based on own needs\n rateLimit: {\n windowMs: 1000,\n max: 10000,\n },\n // deprecated\n keepAliveTimeout: 60,\n};\n"],"mappings":";;;;;;eAAe;EACb;EACA;EACAA,SAAS,EAAE;IACTC,QAAQ,EAAE,IAAI;IACdC,GAAG,EAAE;EACP,CAAC;EACD;EACAC,gBAAgB,EAAE;AACpB,CAAC;AAAA"}
|
package/build/token.js
CHANGED
|
@@ -5,16 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.TOKEN_VALID_LENGTH = void 0;
|
|
7
7
|
exports.generateRandomSecretKey = generateRandomSecretKey;
|
|
8
|
-
|
|
9
8
|
var _crypto = require("crypto");
|
|
10
|
-
|
|
11
9
|
const TOKEN_VALID_LENGTH = 32;
|
|
10
|
+
|
|
12
11
|
/**
|
|
13
12
|
* Secret key must have 32 characters.
|
|
14
13
|
*/
|
|
15
|
-
|
|
16
14
|
exports.TOKEN_VALID_LENGTH = TOKEN_VALID_LENGTH;
|
|
17
|
-
|
|
18
15
|
function generateRandomSecretKey() {
|
|
19
16
|
return (0, _crypto.randomBytes)(TOKEN_VALID_LENGTH).toString('base64').substring(0, TOKEN_VALID_LENGTH);
|
|
20
17
|
}
|
package/build/token.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","names":["TOKEN_VALID_LENGTH","generateRandomSecretKey","randomBytes","toString","substring"],"sources":["../src/token.ts"],"sourcesContent":["import { randomBytes } from 'crypto';\n\nexport const TOKEN_VALID_LENGTH = 32;\n\n/**\n * Secret key must have 32 characters.\n */\nexport function generateRandomSecretKey(): string {\n return randomBytes(TOKEN_VALID_LENGTH).toString('base64').substring(0, TOKEN_VALID_LENGTH);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"token.js","names":["TOKEN_VALID_LENGTH","generateRandomSecretKey","randomBytes","toString","substring"],"sources":["../src/token.ts"],"sourcesContent":["import { randomBytes } from 'crypto';\n\nexport const TOKEN_VALID_LENGTH = 32;\n\n/**\n * Secret key must have 32 characters.\n */\nexport function generateRandomSecretKey(): string {\n return randomBytes(TOKEN_VALID_LENGTH).toString('base64').substring(0, TOKEN_VALID_LENGTH);\n}\n"],"mappings":";;;;;;;AAAA;AAEO,MAAMA,kBAAkB,GAAG,EAAE;;AAEpC;AACA;AACA;AAFA;AAGO,SAASC,uBAAuB,GAAW;EAChD,OAAO,IAAAC,mBAAW,EAACF,kBAAkB,CAAC,CAACG,QAAQ,CAAC,QAAQ,CAAC,CAACC,SAAS,CAAC,CAAC,EAAEJ,kBAAkB,CAAC;AAC5F"}
|
package/build/uplinks.js
CHANGED
|
@@ -8,15 +8,10 @@ exports.hasProxyTo = hasProxyTo;
|
|
|
8
8
|
exports.sanityCheckNames = sanityCheckNames;
|
|
9
9
|
exports.sanityCheckUplinksProps = sanityCheckUplinksProps;
|
|
10
10
|
exports.uplinkSanityCheck = uplinkSanityCheck;
|
|
11
|
-
|
|
12
11
|
var _assert = _interopRequireDefault(require("assert"));
|
|
13
|
-
|
|
14
12
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
15
|
-
|
|
16
13
|
var _utils = require("@verdaccio/utils");
|
|
17
|
-
|
|
18
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
15
|
const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
|
21
16
|
exports.DEFAULT_REGISTRY = DEFAULT_REGISTRY;
|
|
22
17
|
const DEFAULT_UPLINK = 'npmjs';
|
|
@@ -28,28 +23,21 @@ const BLACKLIST = {
|
|
|
28
23
|
owner: true,
|
|
29
24
|
none: true
|
|
30
25
|
};
|
|
31
|
-
|
|
32
26
|
function uplinkSanityCheck(uplinks, users = BLACKLIST) {
|
|
33
27
|
const newUplinks = _lodash.default.clone(uplinks);
|
|
34
|
-
|
|
35
28
|
let newUsers = _lodash.default.clone(users);
|
|
36
|
-
|
|
37
29
|
for (const uplink in newUplinks) {
|
|
38
30
|
if (Object.prototype.hasOwnProperty.call(newUplinks, uplink)) {
|
|
39
31
|
if (typeof newUplinks[uplink].cache === 'undefined') {
|
|
40
32
|
newUplinks[uplink].cache = true;
|
|
41
33
|
}
|
|
42
|
-
|
|
43
34
|
newUsers = sanityCheckNames(uplink, newUsers);
|
|
44
35
|
}
|
|
45
36
|
}
|
|
46
|
-
|
|
47
37
|
return newUplinks;
|
|
48
38
|
}
|
|
49
|
-
|
|
50
39
|
function sanityCheckUplinksProps(configUpLinks) {
|
|
51
40
|
const uplinks = _lodash.default.clone(configUpLinks);
|
|
52
|
-
|
|
53
41
|
for (const uplink in uplinks) {
|
|
54
42
|
if (Object.prototype.hasOwnProperty.call(uplinks, uplink)) {
|
|
55
43
|
(0, _assert.default)(uplinks[uplink].url, 'CONFIG: no url for uplink: ' + uplink);
|
|
@@ -57,21 +45,16 @@ function sanityCheckUplinksProps(configUpLinks) {
|
|
|
57
45
|
uplinks[uplink].url = uplinks[uplink].url.replace(/\/$/, '');
|
|
58
46
|
}
|
|
59
47
|
}
|
|
60
|
-
|
|
61
48
|
return uplinks;
|
|
62
49
|
}
|
|
63
|
-
|
|
64
50
|
function hasProxyTo(pkg, upLink, packages) {
|
|
65
51
|
const matchedPkg = (0, _utils.getMatchedPackagesSpec)(pkg, packages);
|
|
66
52
|
const proxyList = typeof matchedPkg !== 'undefined' ? matchedPkg.proxy : [];
|
|
67
|
-
|
|
68
53
|
if (proxyList) {
|
|
69
54
|
return proxyList.some(curr => upLink === curr);
|
|
70
55
|
}
|
|
71
|
-
|
|
72
56
|
return false;
|
|
73
57
|
}
|
|
74
|
-
|
|
75
58
|
function sanityCheckNames(item, users) {
|
|
76
59
|
(0, _assert.default)(item !== 'all' && item !== 'owner' && item !== 'anonymous' && item !== 'undefined' && item !== 'none', 'CONFIG: reserved uplink name: ' + item);
|
|
77
60
|
(0, _assert.default)(!item.match(/\s/), 'CONFIG: invalid uplink name: ' + item);
|
package/build/uplinks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uplinks.js","names":["DEFAULT_REGISTRY","DEFAULT_UPLINK","BLACKLIST","all","anonymous","undefined","owner","none","uplinkSanityCheck","uplinks","users","newUplinks","_","clone","newUsers","uplink","Object","prototype","hasOwnProperty","call","cache","sanityCheckNames","sanityCheckUplinksProps","configUpLinks","assert","url","isString","replace","hasProxyTo","pkg","upLink","packages","matchedPkg","getMatchedPackagesSpec","proxyList","proxy","some","curr","item","match","isNil"],"sources":["../src/uplinks.ts"],"sourcesContent":["import assert from 'assert';\nimport _ from 'lodash';\n\nimport { PackageList, UpLinksConfList } from '@verdaccio/types';\nimport { getMatchedPackagesSpec } from '@verdaccio/utils';\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(_.isString(uplinks[uplink].url), 'CONFIG: wrong url format for uplink: ' + uplink);\n uplinks[uplink].url = uplinks[uplink].url.replace(/\\/$/, '');\n }\n }\n\n return uplinks;\n}\n\nexport function hasProxyTo(pkg: string, upLink: string, packages: PackageList): boolean {\n const matchedPkg = getMatchedPackagesSpec(pkg, packages);\n const proxyList = typeof matchedPkg !== 'undefined' ? matchedPkg.proxy : [];\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":"
|
|
1
|
+
{"version":3,"file":"uplinks.js","names":["DEFAULT_REGISTRY","DEFAULT_UPLINK","BLACKLIST","all","anonymous","undefined","owner","none","uplinkSanityCheck","uplinks","users","newUplinks","_","clone","newUsers","uplink","Object","prototype","hasOwnProperty","call","cache","sanityCheckNames","sanityCheckUplinksProps","configUpLinks","assert","url","isString","replace","hasProxyTo","pkg","upLink","packages","matchedPkg","getMatchedPackagesSpec","proxyList","proxy","some","curr","item","match","isNil"],"sources":["../src/uplinks.ts"],"sourcesContent":["import assert from 'assert';\nimport _ from 'lodash';\n\nimport { PackageList, UpLinksConfList } from '@verdaccio/types';\nimport { getMatchedPackagesSpec } from '@verdaccio/utils';\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(_.isString(uplinks[uplink].url), 'CONFIG: wrong url format for uplink: ' + uplink);\n uplinks[uplink].url = uplinks[uplink].url.replace(/\\/$/, '');\n }\n }\n\n return uplinks;\n}\n\nexport function hasProxyTo(pkg: string, upLink: string, packages: PackageList): boolean {\n const matchedPkg = getMatchedPackagesSpec(pkg, packages);\n const proxyList = typeof matchedPkg !== 'undefined' ? matchedPkg.proxy : [];\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":";;;;;;;;;;AAAA;AACA;AAGA;AAA0D;AAEnD,MAAMA,gBAAgB,GAAG,4BAA4B;AAAC;AACtD,MAAMC,cAAc,GAAG,OAAO;AAAC;AAEtC,MAAMC,SAAS,GAAG;EAChBC,GAAG,EAAE,IAAI;EACTC,SAAS,EAAE,IAAI;EACfC,SAAS,EAAE,IAAI;EACfC,KAAK,EAAE,IAAI;EACXC,IAAI,EAAE;AACR,CAAC;AAEM,SAASC,iBAAiB,CAC/BC,OAAwB,EACxBC,KAAU,GAAGR,SAAS,EACL;EACjB,MAAMS,UAAU,GAAGC,eAAC,CAACC,KAAK,CAACJ,OAAO,CAAC;EACnC,IAAIK,QAAQ,GAAGF,eAAC,CAACC,KAAK,CAACH,KAAK,CAAC;EAE7B,KAAK,MAAMK,MAAM,IAAIJ,UAAU,EAAE;IAC/B,IA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AAI,CAAEC,IAAI,IAAKP,MAAM,KAAKO,IAAI,CAAC;EAClD;EAEA,OAAO,KAAK;AACd;AAEO,SAAShB,gBAAgB,CAACiB,IAAY,EAAE5B,KAAU,EAAO;EAC9D,IAAAc,eAAM,EACJc,IAAI,KAAK,KAAK,IACZA,IAAI,KAAK,OAAO,IAChBA,IAAI,KAAK,WAAW,IACpBA,IAAI,KAAK,WAAW,IACpBA,IAAI,KAAK,MAAM,EACjB,gCAAgC,GAAGA,IAAI,CACxC;EACD,IAAAd,eAAM,EAAC,CAACc,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE,+BAA+B,GAAGD,IAAI,CAAC;EACjE,IAAAd,eAAM,EAACZ,eAAC,CAAC4B,KAAK,CAAC9B,KAAK,CAAC4B,IAAI,CAAC,CAAC,EAAE,iCAAiC,GAAGA,IAAI,CAAC;EACtE5B,KAAK,CAAC4B,IAAI,CAAC,GAAG,IAAI;EAElB,OAAO5B,KAAK;AACd"}
|
package/build/user.js
CHANGED
|
@@ -6,9 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.createAnonymousRemoteUser = createAnonymousRemoteUser;
|
|
7
7
|
exports.createRemoteUser = createRemoteUser;
|
|
8
8
|
exports.defaultNonLoggedUserRoles = exports.defaultLoggedUserRoles = void 0;
|
|
9
|
-
|
|
10
9
|
var _packageAccess = require("./package-access");
|
|
11
|
-
|
|
12
10
|
/**
|
|
13
11
|
* All logged users will have by default the group $all and $authenticate
|
|
14
12
|
*/
|
|
@@ -16,17 +14,16 @@ const defaultLoggedUserRoles = [_packageAccess.ROLES.$ALL, _packageAccess.ROLES.
|
|
|
16
14
|
/**
|
|
17
15
|
*
|
|
18
16
|
*/
|
|
19
|
-
|
|
20
17
|
exports.defaultLoggedUserRoles = defaultLoggedUserRoles;
|
|
21
|
-
const defaultNonLoggedUserRoles = [_packageAccess.ROLES.$ALL, _packageAccess.ROLES.$ANONYMOUS,
|
|
18
|
+
const defaultNonLoggedUserRoles = [_packageAccess.ROLES.$ALL, _packageAccess.ROLES.$ANONYMOUS,
|
|
19
|
+
// groups without '$' are going to be deprecated eventually
|
|
22
20
|
_packageAccess.ROLES.DEPRECATED_ALL, _packageAccess.ROLES.DEPRECATED_ANONYMOUS];
|
|
21
|
+
|
|
23
22
|
/**
|
|
24
23
|
* Create a RemoteUser object
|
|
25
24
|
* @return {Object} { name: xx, pluginGroups: [], real_groups: [] }
|
|
26
25
|
*/
|
|
27
|
-
|
|
28
26
|
exports.defaultNonLoggedUserRoles = defaultNonLoggedUserRoles;
|
|
29
|
-
|
|
30
27
|
function createRemoteUser(name, pluginGroups) {
|
|
31
28
|
const isGroupValid = Array.isArray(pluginGroups);
|
|
32
29
|
const groups = Array.from(new Set((isGroupValid ? pluginGroups : []).concat([...defaultLoggedUserRoles])));
|
|
@@ -36,12 +33,11 @@ function createRemoteUser(name, pluginGroups) {
|
|
|
36
33
|
real_groups: pluginGroups
|
|
37
34
|
};
|
|
38
35
|
}
|
|
36
|
+
|
|
39
37
|
/**
|
|
40
38
|
* Builds an anonymous remote user in case none is logged in.
|
|
41
39
|
* @return {Object} { name: xx, groups: [], real_groups: [] }
|
|
42
40
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
41
|
function createAnonymousRemoteUser() {
|
|
46
42
|
return {
|
|
47
43
|
name: undefined,
|
package/build/user.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","names":["defaultLoggedUserRoles","ROLES","$ALL","$AUTH","DEPRECATED_ALL","DEPRECATED_AUTH","ALL","defaultNonLoggedUserRoles","$ANONYMOUS","DEPRECATED_ANONYMOUS","createRemoteUser","name","pluginGroups","isGroupValid","Array","isArray","groups","from","Set","concat","real_groups","createAnonymousRemoteUser","undefined"],"sources":["../src/user.ts"],"sourcesContent":["import { RemoteUser } from '@verdaccio/types';\n\nimport { ROLES } from './package-access';\n\n/**\n * All logged users will have by default the group $all and $authenticate\n */\nexport const defaultLoggedUserRoles = [\n ROLES.$ALL,\n ROLES.$AUTH,\n ROLES.DEPRECATED_ALL,\n ROLES.DEPRECATED_AUTH,\n ROLES.ALL,\n];\n/**\n *\n */\nexport const defaultNonLoggedUserRoles = [\n ROLES.$ALL,\n ROLES.$ANONYMOUS,\n // groups without '$' are going to be deprecated eventually\n ROLES.DEPRECATED_ALL,\n ROLES.DEPRECATED_ANONYMOUS,\n];\n\n/**\n * Create a RemoteUser object\n * @return {Object} { name: xx, pluginGroups: [], real_groups: [] }\n */\nexport function createRemoteUser(name: string, pluginGroups: string[]): RemoteUser {\n const isGroupValid: boolean = Array.isArray(pluginGroups);\n const groups = Array.from(\n new Set((isGroupValid ? pluginGroups : []).concat([...defaultLoggedUserRoles]))\n );\n\n return {\n name,\n groups,\n real_groups: pluginGroups,\n };\n}\n\n/**\n * Builds an anonymous remote user in case none is logged in.\n * @return {Object} { name: xx, groups: [], real_groups: [] }\n */\nexport function createAnonymousRemoteUser(): RemoteUser {\n return {\n name: undefined,\n groups: [...defaultNonLoggedUserRoles],\n real_groups: [],\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"user.js","names":["defaultLoggedUserRoles","ROLES","$ALL","$AUTH","DEPRECATED_ALL","DEPRECATED_AUTH","ALL","defaultNonLoggedUserRoles","$ANONYMOUS","DEPRECATED_ANONYMOUS","createRemoteUser","name","pluginGroups","isGroupValid","Array","isArray","groups","from","Set","concat","real_groups","createAnonymousRemoteUser","undefined"],"sources":["../src/user.ts"],"sourcesContent":["import { RemoteUser } from '@verdaccio/types';\n\nimport { ROLES } from './package-access';\n\n/**\n * All logged users will have by default the group $all and $authenticate\n */\nexport const defaultLoggedUserRoles = [\n ROLES.$ALL,\n ROLES.$AUTH,\n ROLES.DEPRECATED_ALL,\n ROLES.DEPRECATED_AUTH,\n ROLES.ALL,\n];\n/**\n *\n */\nexport const defaultNonLoggedUserRoles = [\n ROLES.$ALL,\n ROLES.$ANONYMOUS,\n // groups without '$' are going to be deprecated eventually\n ROLES.DEPRECATED_ALL,\n ROLES.DEPRECATED_ANONYMOUS,\n];\n\n/**\n * Create a RemoteUser object\n * @return {Object} { name: xx, pluginGroups: [], real_groups: [] }\n */\nexport function createRemoteUser(name: string, pluginGroups: string[]): RemoteUser {\n const isGroupValid: boolean = Array.isArray(pluginGroups);\n const groups = Array.from(\n new Set((isGroupValid ? pluginGroups : []).concat([...defaultLoggedUserRoles]))\n );\n\n return {\n name,\n groups,\n real_groups: pluginGroups,\n };\n}\n\n/**\n * Builds an anonymous remote user in case none is logged in.\n * @return {Object} { name: xx, groups: [], real_groups: [] }\n */\nexport function createAnonymousRemoteUser(): RemoteUser {\n return {\n name: undefined,\n groups: [...defaultNonLoggedUserRoles],\n real_groups: [],\n };\n}\n"],"mappings":";;;;;;;;AAEA;AAEA;AACA;AACA;AACO,MAAMA,sBAAsB,GAAG,CACpCC,oBAAK,CAACC,IAAI,EACVD,oBAAK,CAACE,KAAK,EACXF,oBAAK,CAACG,cAAc,EACpBH,oBAAK,CAACI,eAAe,EACrBJ,oBAAK,CAACK,GAAG,CACV;AACD;AACA;AACA;AAFA;AAGO,MAAMC,yBAAyB,GAAG,CACvCN,oBAAK,CAACC,IAAI,EACVD,oBAAK,CAACO,UAAU;AAChB;AACAP,oBAAK,CAACG,cAAc,EACpBH,oBAAK,CAACQ,oBAAoB,CAC3B;;AAED;AACA;AACA;AACA;AAHA;AAIO,SAASC,gBAAgB,CAACC,IAAY,EAAEC,YAAsB,EAAc;EACjF,MAAMC,YAAqB,GAAGC,KAAK,CAACC,OAAO,CAACH,YAAY,CAAC;EACzD,MAAMI,MAAM,GAAGF,KAAK,CAACG,IAAI,CACvB,IAAIC,GAAG,CAAC,CAACL,YAAY,GAAGD,YAAY,GAAG,EAAE,EAAEO,MAAM,CAAC,CAAC,GAAGnB,sBAAsB,CAAC,CAAC,CAAC,CAChF;EAED,OAAO;IACLW,IAAI;IACJK,MAAM;IACNI,WAAW,EAAER;EACf,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACO,SAASS,yBAAyB,GAAe;EACtD,OAAO;IACLV,IAAI,EAAEW,SAAS;IACfN,MAAM,EAAE,CAAC,GAAGT,yBAAyB,CAAC;IACtCa,WAAW,EAAE;EACf,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/config",
|
|
3
|
-
"version": "6.0.0-6-next.
|
|
3
|
+
"version": "6.0.0-6-next.53",
|
|
4
4
|
"description": "logger",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"npm": ">=6"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@verdaccio/core": "6.0.0-6-next.
|
|
34
|
-
"@verdaccio/utils": "6.0.0-6-next.
|
|
33
|
+
"@verdaccio/core": "6.0.0-6-next.53",
|
|
34
|
+
"@verdaccio/utils": "6.0.0-6-next.21",
|
|
35
35
|
"debug": "4.3.4",
|
|
36
|
-
"yaml": "2.
|
|
36
|
+
"yaml": "2.2.0",
|
|
37
37
|
"lodash": "4.17.21",
|
|
38
38
|
"minimatch": "3.1.2",
|
|
39
39
|
"yup": "0.32.11"
|