@sap/cli-core 2025.16.0 → 2025.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +1 -1
- package/cache/cache.js +16 -28
- package/cache/index.d.ts +2 -2
- package/cache/index.js +2 -12
- package/cache/secrets/SecretsStorageImpl.d.ts +2 -3
- package/cache/secrets/SecretsStorageImpl.js +18 -25
- package/cache/secrets/SecretsStorageSingleton.d.ts +1 -1
- package/cache/secrets/SecretsStorageSingleton.js +1 -5
- package/cache/secrets/types.d.ts +1 -1
- package/cache/secrets/types.js +1 -2
- package/cache/secrets/utils.d.ts +1 -1
- package/cache/secrets/utils.js +20 -27
- package/cache/utils.js +8 -15
- package/commands/config.command/cache.command/clean.command.d.ts +1 -1
- package/commands/config.command/cache.command/clean.command.js +10 -12
- package/commands/config.command/cache.command/index.d.ts +1 -1
- package/commands/config.command/cache.command/index.js +5 -10
- package/commands/config.command/cache.command/init.command/index.d.ts +1 -1
- package/commands/config.command/cache.command/init.command/index.js +29 -36
- package/commands/config.command/cache.command/init.command/utils.d.ts +1 -1
- package/commands/config.command/cache.command/init.command/utils.js +6 -13
- package/commands/config.command/cache.command/show.command.d.ts +1 -1
- package/commands/config.command/cache.command/show.command.js +7 -9
- package/commands/config.command/host.command.d.ts +1 -1
- package/commands/config.command/host.command.js +19 -23
- package/commands/config.command/index.d.ts +1 -1
- package/commands/config.command/index.js +5 -45
- package/commands/config.command/passcode.command.d.ts +1 -1
- package/commands/config.command/passcode.command.js +12 -16
- package/commands/config.command/secrets.command/check.command.d.ts +1 -2
- package/commands/config.command/secrets.command/check.command.js +10 -14
- package/commands/config.command/secrets.command/index.d.ts +1 -1
- package/commands/config.command/secrets.command/index.js +6 -11
- package/commands/config.command/secrets.command/refresh.command.d.ts +1 -1
- package/commands/config.command/secrets.command/refresh.command.js +5 -7
- package/commands/config.command/secrets.command/reset.command.d.ts +1 -1
- package/commands/config.command/secrets.command/reset.command.js +6 -8
- package/commands/config.command/secrets.command/show.command.d.ts +1 -1
- package/commands/config.command/secrets.command/show.command.js +8 -10
- package/commands/handler/authentication/index.d.ts +1 -1
- package/commands/handler/authentication/index.js +18 -21
- package/commands/handler/authentication/oauth/index.d.ts +2 -2
- package/commands/handler/authentication/oauth/index.js +13 -16
- package/commands/handler/authentication/oauth/secretsProvider/cache.d.ts +1 -1
- package/commands/handler/authentication/oauth/secretsProvider/cache.js +5 -9
- package/commands/handler/authentication/oauth/secretsProvider/file.d.ts +1 -1
- package/commands/handler/authentication/oauth/secretsProvider/file.js +20 -25
- package/commands/handler/authentication/oauth/secretsProvider/index.d.ts +1 -1
- package/commands/handler/authentication/oauth/secretsProvider/index.js +6 -10
- package/commands/handler/authentication/oauth/secretsProvider/options.d.ts +1 -1
- package/commands/handler/authentication/oauth/secretsProvider/options.js +25 -29
- package/commands/handler/authentication/oauth/tokenProvider/getToken.d.ts +2 -2
- package/commands/handler/authentication/oauth/tokenProvider/getToken.js +18 -23
- package/commands/handler/authentication/oauth/tokenProvider/index.d.ts +2 -2
- package/commands/handler/authentication/oauth/tokenProvider/index.js +7 -11
- package/commands/handler/authentication/oauth/tokenProvider/refreshToken.d.ts +1 -1
- package/commands/handler/authentication/oauth/tokenProvider/refreshToken.js +5 -9
- package/commands/handler/authentication/oauth/tokenProvider/setAuthorization.d.ts +1 -1
- package/commands/handler/authentication/oauth/tokenProvider/setAuthorization.js +19 -24
- package/commands/handler/authentication/oauth/tokenProvider/utils.js +30 -36
- package/commands/handler/authentication/oauth/utils.d.ts +1 -1
- package/commands/handler/authentication/oauth/utils.js +15 -24
- package/commands/handler/authentication/passcode/function.d.ts +1 -1
- package/commands/handler/authentication/passcode/function.js +11 -13
- package/commands/handler/authentication/passcode/index.d.ts +1 -1
- package/commands/handler/authentication/passcode/index.js +14 -17
- package/commands/handler/authentication/passcode/input.d.ts +1 -1
- package/commands/handler/authentication/passcode/input.js +13 -20
- package/commands/handler/authentication/passcode/setPasscode.d.ts +1 -1
- package/commands/handler/authentication/passcode/setPasscode.js +9 -13
- package/commands/handler/authentication/passcode/types.js +1 -2
- package/commands/handler/authentication/technicalJWT/cf.js +9 -11
- package/commands/handler/authentication/technicalJWT/exec.d.ts +5 -6
- package/commands/handler/authentication/technicalJWT/exec.js +15 -19
- package/commands/handler/authentication/technicalJWT/index.d.ts +1 -1
- package/commands/handler/authentication/technicalJWT/index.js +8 -12
- package/commands/handler/authentication/technicalJWT/types.d.ts +1 -1
- package/commands/handler/authentication/technicalJWT/types.js +1 -4
- package/commands/handler/authentication/technicalJWT/utils.js +20 -27
- package/commands/handler/authentication/utils.js +3 -7
- package/commands/handler/checkOptionsExistence.d.ts +1 -1
- package/commands/handler/checkOptionsExistence.js +5 -9
- package/commands/handler/error.d.ts +1 -1
- package/commands/handler/error.js +4 -8
- package/commands/handler/fail.d.ts +1 -1
- package/commands/handler/fail.js +3 -7
- package/commands/handler/fetch/fetch.d.ts +1 -1
- package/commands/handler/fetch/fetch.js +26 -27
- package/commands/handler/fetch/index.d.ts +1 -1
- package/commands/handler/fetch/index.js +10 -14
- package/commands/handler/fetch/utils.d.ts +2 -2
- package/commands/handler/fetch/utils.js +55 -74
- package/commands/handler/force.d.ts +1 -1
- package/commands/handler/force.js +8 -15
- package/commands/handler/index.d.ts +18 -18
- package/commands/handler/index.js +18 -39
- package/commands/handler/input/file.d.ts +1 -1
- package/commands/handler/input/file.js +22 -29
- package/commands/handler/input/index.d.ts +1 -1
- package/commands/handler/input/index.js +4 -8
- package/commands/handler/input/input.d.ts +1 -1
- package/commands/handler/input/input.js +16 -23
- package/commands/handler/mandatoryOptions.d.ts +1 -1
- package/commands/handler/mandatoryOptions.js +13 -17
- package/commands/handler/next.d.ts +1 -1
- package/commands/handler/next.js +4 -8
- package/commands/handler/options/env.d.ts +1 -1
- package/commands/handler/options/env.js +8 -12
- package/commands/handler/options/file.d.ts +1 -1
- package/commands/handler/options/file.js +8 -12
- package/commands/handler/options/index.d.ts +1 -1
- package/commands/handler/options/index.js +15 -19
- package/commands/handler/options/option.d.ts +1 -1
- package/commands/handler/options/option.js +12 -13
- package/commands/handler/options/utils.d.ts +4 -2
- package/commands/handler/options/utils.js +18 -26
- package/commands/handler/or.d.ts +1 -1
- package/commands/handler/or.js +3 -7
- package/commands/handler/parseArguments.d.ts +1 -1
- package/commands/handler/parseArguments.js +11 -15
- package/commands/handler/resilient.d.ts +1 -1
- package/commands/handler/resilient.js +3 -7
- package/commands/handler/root/index.d.ts +1 -1
- package/commands/handler/root/index.js +3 -7
- package/commands/handler/stackTrace.d.ts +1 -1
- package/commands/handler/stackTrace.js +3 -7
- package/commands/handler/succeed.d.ts +1 -1
- package/commands/handler/succeed.js +3 -7
- package/commands/handler/utils.d.ts +1 -1
- package/commands/handler/utils.js +17 -27
- package/commands/login.command.d.ts +1 -1
- package/commands/login.command.js +51 -49
- package/commands/logout.command.d.ts +1 -1
- package/commands/logout.command.js +15 -17
- package/commands/openAPI.command/index.d.ts +1 -1
- package/commands/openAPI.command/index.js +20 -24
- package/commands/openAPI.command/utils.d.ts +1 -1
- package/commands/openAPI.command/utils.js +47 -97
- package/commands/utils.d.ts +1 -1
- package/commands/utils.js +6 -11
- package/config/core.d.ts +1 -1
- package/config/core.js +12 -25
- package/config/index.d.ts +1 -1
- package/config/index.js +45 -49
- package/configureLoggers.js +2 -6
- package/constants.d.ts +4 -1
- package/constants.js +62 -59
- package/discovery/index.d.ts +1 -1
- package/discovery/index.js +32 -45
- package/discovery/utils.js +5 -12
- package/dwc/dwc.js +63 -76
- package/dwc/run.js +15 -19
- package/dwc/utils.d.ts +1 -1
- package/dwc/utils.js +42 -38
- package/index.d.ts +4 -4
- package/index.js +22 -68
- package/logger/index.d.ts +2 -2
- package/logger/index.js +17 -22
- package/logger/types.js +1 -2
- package/logger/utils.d.ts +1 -1
- package/logger/utils.js +4 -8
- package/module.d.ts +3 -3
- package/module.js +10 -48
- package/package.json +9 -7
- package/result/ResultHandlerFactory.d.ts +1 -1
- package/result/ResultHandlerFactory.js +1 -5
- package/result/ResultHandlerImpl.d.ts +1 -1
- package/result/ResultHandlerImpl.js +1 -5
- package/result/types.js +1 -2
- package/settings/index.d.ts +1 -1
- package/settings/index.js +11 -17
- package/types.d.ts +1 -1
- package/types.js +6 -9
- package/utils/commands.d.ts +3 -3
- package/utils/commands.js +23 -36
- package/utils/http/httpsAgent.d.ts +6 -0
- package/utils/http/httpsAgent.js +44 -0
- package/utils/http/index.d.ts +1 -1
- package/utils/http/index.js +31 -35
- package/utils/http/utils.d.ts +1 -1
- package/utils/http/utils.js +4 -9
- package/utils/openUtils.js +8 -14
- package/utils/options.d.ts +1 -1
- package/utils/options.js +5 -10
- package/utils/utils.d.ts +2 -2
- package/utils/utils.js +42 -94
package/config/core.js
CHANGED
|
@@ -1,27 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGenericOptionsHelp = exports.getDeprecationMessage = exports.isDeprecated = exports.getVersion = exports.getAuthenticationMethods = exports.getSapHelp = exports.getDiscoveryPaths = exports.getDescription = exports.getPackageName = exports.getName = void 0;
|
|
4
1
|
/* jscpd:ignore-start */
|
|
5
|
-
|
|
2
|
+
import { CLI_DEPRECATED, CLI_DEPRECATION_MESSAGE, CLI_DESCRIPTION, CLI_DISCOVERY_PATHS, CLI_GENERIC_OPTIONS_HELP, CLI_NAME, CLI_PACKAGE_NAME, CLI_SAP_HELP, CLI_SUPPORTED_AUTHENTICATION_METHODS, CLI_VERSION, } from "../constants.js";
|
|
6
3
|
/* jscpd:ignore-end */
|
|
7
|
-
|
|
8
|
-
const getName = () =>
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const getAuthenticationMethods = () => (0, index_1.get)()[constants_1.CLI_SUPPORTED_AUTHENTICATION_METHODS];
|
|
19
|
-
exports.getAuthenticationMethods = getAuthenticationMethods;
|
|
20
|
-
const getVersion = () => (0, index_1.get)()[constants_1.CLI_VERSION];
|
|
21
|
-
exports.getVersion = getVersion;
|
|
22
|
-
const isDeprecated = () => (0, index_1.get)()[constants_1.CLI_DEPRECATED] || false;
|
|
23
|
-
exports.isDeprecated = isDeprecated;
|
|
24
|
-
const getDeprecationMessage = () => (0, index_1.get)()[constants_1.CLI_DEPRECATION_MESSAGE];
|
|
25
|
-
exports.getDeprecationMessage = getDeprecationMessage;
|
|
26
|
-
const getGenericOptionsHelp = () => (0, index_1.get)()[constants_1.CLI_GENERIC_OPTIONS_HELP];
|
|
27
|
-
exports.getGenericOptionsHelp = getGenericOptionsHelp;
|
|
4
|
+
import { get } from "./index.js";
|
|
5
|
+
export const getName = () => get()[CLI_NAME];
|
|
6
|
+
export const getPackageName = () => get()[CLI_PACKAGE_NAME];
|
|
7
|
+
export const getDescription = () => get()[CLI_DESCRIPTION];
|
|
8
|
+
export const getDiscoveryPaths = () => get()[CLI_DISCOVERY_PATHS];
|
|
9
|
+
export const getSapHelp = () => get()[CLI_SAP_HELP];
|
|
10
|
+
export const getAuthenticationMethods = () => get()[CLI_SUPPORTED_AUTHENTICATION_METHODS];
|
|
11
|
+
export const getVersion = () => get()[CLI_VERSION];
|
|
12
|
+
export const isDeprecated = () => get()[CLI_DEPRECATED] || false;
|
|
13
|
+
export const getDeprecationMessage = () => get()[CLI_DEPRECATION_MESSAGE];
|
|
14
|
+
export const getGenericOptionsHelp = () => get()[CLI_GENERIC_OPTIONS_HELP];
|
package/config/index.d.ts
CHANGED
package/config/index.js
CHANGED
|
@@ -1,32 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.get = exports.set = exports.setCustomConfig = exports.initialize = void 0;
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const config_1 = __importDefault(require("config"));
|
|
9
|
-
const logger_1 = require("../logger");
|
|
10
|
-
const utils_1 = require("../utils/utils");
|
|
11
|
-
const constants_1 = require("../constants");
|
|
1
|
+
import { createRequire } from "module";
|
|
2
|
+
import { isEqual, merge } from "lodash-es";
|
|
3
|
+
import { get as getLoggerExt } from "../logger/index.js";
|
|
4
|
+
import { getInfoFromTenant, parseTenant } from "../utils/utils.js";
|
|
5
|
+
import { CLI_DEPRECATED, CLI_DEPRECATION_MESSAGE, CLI_DESCRIPTION, CLI_DISCOVERY_PATHS, CLI_GENERIC_OPTIONS_HELP, CLI_NAME, CLI_PACKAGE_NAME, CLI_SAP_HELP, CLI_SUPPORTED_AUTHENTICATION_METHODS, CLI_VERSION, CONFIG_PASSCODE_FUNCTION, } from "../constants.js";
|
|
12
6
|
const CUSTOM_HOST = "tenant.host";
|
|
13
7
|
const CUSTOM_PASSCODE_URL = "tenant.passcodeUrl";
|
|
14
8
|
const CUSTOM_PUBLIC_FQDN = "tenant.publicfqdn";
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
15
10
|
let config;
|
|
16
11
|
const CONFIGS_TO_KEEP = [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
CONFIG_PASSCODE_FUNCTION,
|
|
13
|
+
CLI_DESCRIPTION,
|
|
14
|
+
CLI_DISCOVERY_PATHS,
|
|
15
|
+
CLI_NAME,
|
|
16
|
+
CLI_PACKAGE_NAME,
|
|
17
|
+
CLI_SAP_HELP,
|
|
18
|
+
CLI_SUPPORTED_AUTHENTICATION_METHODS,
|
|
19
|
+
CLI_VERSION,
|
|
20
|
+
CLI_DEPRECATED,
|
|
21
|
+
CLI_DEPRECATION_MESSAGE,
|
|
22
|
+
CLI_GENERIC_OPTIONS_HELP,
|
|
28
23
|
];
|
|
29
|
-
const initialize = () => {
|
|
24
|
+
export const initialize = () => {
|
|
30
25
|
const keep = {};
|
|
31
26
|
for (const keepConfig of CONFIGS_TO_KEEP) {
|
|
32
27
|
keep[keepConfig] = config?.[keepConfig];
|
|
@@ -38,45 +33,48 @@ const initialize = () => {
|
|
|
38
33
|
}
|
|
39
34
|
}
|
|
40
35
|
};
|
|
41
|
-
|
|
42
|
-
(
|
|
43
|
-
const
|
|
44
|
-
|
|
36
|
+
initialize();
|
|
37
|
+
const getLogger = () => getLoggerExt("config");
|
|
38
|
+
export const setCustomConfig = () => {
|
|
39
|
+
if (process.env.SUPPRESS_NO_CONFIG_WARNING === undefined) {
|
|
40
|
+
process.env.SUPPRESS_NO_CONFIG_WARNING = "true";
|
|
41
|
+
}
|
|
42
|
+
// This has to be loaded via dynamic import to ensure that the env variable is set before the config is loaded.
|
|
43
|
+
const customConfig = require("config");
|
|
45
44
|
const { trace, debug } = getLogger();
|
|
46
45
|
debug("setting custom configuration");
|
|
47
|
-
const sources =
|
|
46
|
+
const sources = customConfig.util.getConfigSources();
|
|
48
47
|
trace("config.custom.getConfigSources", JSON.stringify(sources, null, 2));
|
|
49
|
-
trace("config.custom.NODE_CONFIG_DIR",
|
|
50
|
-
trace("config.custom.NODE_ENV",
|
|
51
|
-
trace("config.custom.NODE_CONFIG", JSON.stringify(
|
|
52
|
-
trace("config.custom.HOSTNAME",
|
|
53
|
-
trace("config.custom.NODE_APP_INSTANCE",
|
|
54
|
-
if (
|
|
55
|
-
config.host =
|
|
48
|
+
trace("config.custom.NODE_CONFIG_DIR", customConfig.util.getEnv("NODE_CONFIG_DIR"));
|
|
49
|
+
trace("config.custom.NODE_ENV", customConfig.util.getEnv("NODE_ENV"));
|
|
50
|
+
trace("config.custom.NODE_CONFIG", JSON.stringify(customConfig.util.getEnv("NODE_CONFIG"), null, 2));
|
|
51
|
+
trace("config.custom.HOSTNAME", customConfig.util.getEnv("HOSTNAME"));
|
|
52
|
+
trace("config.custom.NODE_APP_INSTANCE", customConfig.util.getEnv("NODE_APP_INSTANCE"));
|
|
53
|
+
if (customConfig.has(CUSTOM_HOST)) {
|
|
54
|
+
config.host = customConfig.get(CUSTOM_HOST);
|
|
56
55
|
config.hostSetFromCustomConfig = true;
|
|
57
56
|
}
|
|
58
|
-
if (
|
|
59
|
-
config.passcodeUrl =
|
|
57
|
+
if (customConfig.has(CUSTOM_PASSCODE_URL)) {
|
|
58
|
+
config.passcodeUrl = customConfig.get(CUSTOM_PASSCODE_URL);
|
|
60
59
|
}
|
|
61
|
-
if (
|
|
62
|
-
config.publicfqdn =
|
|
60
|
+
if (customConfig.has(CUSTOM_PUBLIC_FQDN)) {
|
|
61
|
+
config.publicfqdn = parseTenant(customConfig.get(CUSTOM_PUBLIC_FQDN));
|
|
63
62
|
}
|
|
64
63
|
};
|
|
65
|
-
|
|
66
|
-
(0, exports.setCustomConfig)();
|
|
64
|
+
setCustomConfig();
|
|
67
65
|
const setTenant = (tenant) => {
|
|
68
|
-
const info =
|
|
66
|
+
const info = getInfoFromTenant(tenant, config.verbose);
|
|
69
67
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
70
|
-
|
|
68
|
+
set({ ...info, newTenant: tenant });
|
|
71
69
|
};
|
|
72
|
-
const set = (c) => {
|
|
70
|
+
export const set = (c) => {
|
|
73
71
|
const { trace } = getLogger();
|
|
74
72
|
const prev = JSON.parse(JSON.stringify(config));
|
|
75
73
|
if (c.tenant) {
|
|
76
74
|
setTenant(c.tenant);
|
|
77
75
|
}
|
|
78
76
|
else {
|
|
79
|
-
config =
|
|
77
|
+
config = merge(config, c);
|
|
80
78
|
if (config.newTenant) {
|
|
81
79
|
config.tenant = config.newTenant;
|
|
82
80
|
delete config.newTenant;
|
|
@@ -84,11 +82,9 @@ const set = (c) => {
|
|
|
84
82
|
if (c.data) {
|
|
85
83
|
config.data = c.data;
|
|
86
84
|
}
|
|
87
|
-
if (!
|
|
85
|
+
if (!isEqual(prev, config)) {
|
|
88
86
|
trace("configuration changed. previous: %s, current: %s", JSON.stringify(prev), JSON.stringify(config));
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
89
|
};
|
|
92
|
-
|
|
93
|
-
const get = () => config;
|
|
94
|
-
exports.get = get;
|
|
90
|
+
export const get = () => config;
|
package/configureLoggers.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.configureLoggers = void 0;
|
|
4
|
-
const logger_1 = require("./logger");
|
|
5
|
-
const configureLoggers = () => (0, logger_1.configure)({
|
|
1
|
+
import { configure } from "./logger/index.js";
|
|
2
|
+
export const configureLoggers = () => configure({
|
|
6
3
|
logLevel: process.env.LOG_LEVEL
|
|
7
4
|
? parseInt(process.env.LOG_LEVEL, 10)
|
|
8
5
|
: undefined,
|
|
9
6
|
loggers: process.env.LOGGERS ? new RegExp(process.env.LOGGERS) : undefined,
|
|
10
7
|
});
|
|
11
|
-
exports.configureLoggers = configureLoggers;
|
package/constants.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SecureVersion } from "tls";
|
|
2
|
+
import { Option } from "./types.js";
|
|
2
3
|
export declare const VERSION: string;
|
|
4
|
+
export declare const DEFAULT_TLS_VERSION: SecureVersion;
|
|
3
5
|
export type CoreConfiguration = {
|
|
4
6
|
getName: () => string;
|
|
5
7
|
getPackageName: () => string;
|
|
@@ -60,3 +62,4 @@ export declare const OPTION_FILE_PATH: Option;
|
|
|
60
62
|
export declare const OPTION_INPUT: Option;
|
|
61
63
|
export declare const OPTION_BROWSER: Option;
|
|
62
64
|
export declare const OPTION_AUTHORIZATION_FLOW: Option;
|
|
65
|
+
export declare const OPTION_TLS_VERSION: Option;
|
package/constants.js
CHANGED
|
@@ -1,50 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const types_1 = require("./types");
|
|
9
|
-
const utils_1 = require("./utils/utils");
|
|
10
|
-
exports.VERSION = (0, utils_1.getVersion)();
|
|
11
|
-
exports.DISCOVERY_DOCUMENT_PREFIX = "discovery-";
|
|
12
|
-
var AuthenticationMethod;
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { GrantType } from "./types.js";
|
|
3
|
+
import { getVersion } from "./utils/utils.js";
|
|
4
|
+
export const VERSION = getVersion();
|
|
5
|
+
export const DEFAULT_TLS_VERSION = "TLSv1.2";
|
|
6
|
+
export const DISCOVERY_DOCUMENT_PREFIX = "discovery-";
|
|
7
|
+
export var AuthenticationMethod;
|
|
13
8
|
(function (AuthenticationMethod) {
|
|
14
9
|
AuthenticationMethod["oauth"] = "oauth";
|
|
15
10
|
AuthenticationMethod["passcode"] = "passcode";
|
|
16
|
-
})(AuthenticationMethod || (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
11
|
+
})(AuthenticationMethod || (AuthenticationMethod = {}));
|
|
12
|
+
export const ROOT_COMMAND = { name: () => "ROOT", parent: null };
|
|
13
|
+
export const CLI_NAME = "cli-name";
|
|
14
|
+
export const CLI_PACKAGE_NAME = "cli-package-name";
|
|
15
|
+
export const CLI_DESCRIPTION = "cli-description";
|
|
16
|
+
export const CLI_DISCOVERY_PATHS = "cli-discovery-paths";
|
|
17
|
+
export const CLI_SAP_HELP = "cli-sap-help";
|
|
18
|
+
export const CLI_VERSION = "cli-version";
|
|
19
|
+
export const CLI_DEPRECATED = "cli-deprecated";
|
|
20
|
+
export const CLI_DEPRECATION_MESSAGE = "cli-deprecation-message";
|
|
21
|
+
export const CLI_SUPPORTED_AUTHENTICATION_METHODS = "cli-supported-authentication-methods";
|
|
22
|
+
export const CLI_GENERIC_OPTIONS_HELP = "cli-generic-options-help";
|
|
23
|
+
export const SEGMENTS_TO_REMOVE_FOR_PASSCODE_AUTH = ["dwaas-core"];
|
|
24
|
+
export const DISCOVERY_METADATA_PATH = "discovery-metadata.json";
|
|
25
|
+
export const X_CSRF_TOKEN = "x-csrf-token";
|
|
26
|
+
export const X_DSP_API_DEPRECATED_PROPERTIES = "x-dsp-api-deprecated-properties";
|
|
27
|
+
export const X_OUTPUT_FILE_NAME = "x-sap-datasphere-cli-file-name";
|
|
28
|
+
export const PATH_TO_SUCCESS_HTML = path.join(import.meta.dirname, "assets", "success.html");
|
|
29
|
+
export const PATH_TO_ERROR_HTML = path.join(import.meta.dirname, "assets", "error.html");
|
|
30
|
+
export const CACHE_SECRETS_FILE = "secrets.json";
|
|
31
|
+
export const OPTION_VERSION = {
|
|
37
32
|
longName: "version",
|
|
38
33
|
description: "print version",
|
|
39
34
|
hidden: true,
|
|
40
35
|
};
|
|
41
|
-
|
|
36
|
+
export const OPTION_HELP = {
|
|
42
37
|
longName: "help",
|
|
43
38
|
description: "print help for a command",
|
|
44
39
|
args: [{ name: "command" }],
|
|
45
40
|
hidden: true,
|
|
46
41
|
};
|
|
47
|
-
|
|
42
|
+
export const OPTION_HOST = {
|
|
48
43
|
longName: "host",
|
|
49
44
|
description: "specifies the url where the tenant is hosted",
|
|
50
45
|
args: [{ name: "host" }],
|
|
@@ -54,7 +49,7 @@ exports.OPTION_HOST = {
|
|
|
54
49
|
type: "text",
|
|
55
50
|
},
|
|
56
51
|
};
|
|
57
|
-
|
|
52
|
+
export const OPTION_LOGIN_ID = {
|
|
58
53
|
longName: "login-id",
|
|
59
54
|
description: "specifies the login ID",
|
|
60
55
|
args: [{ name: "id" }],
|
|
@@ -65,27 +60,27 @@ exports.OPTION_LOGIN_ID = {
|
|
|
65
60
|
type: "select",
|
|
66
61
|
},
|
|
67
62
|
};
|
|
68
|
-
|
|
63
|
+
export const OPTION_OUTPUT = {
|
|
69
64
|
longName: "output",
|
|
70
65
|
description: "specifies the file to store the output of the command",
|
|
71
66
|
args: [{ name: "output", optional: true }],
|
|
72
67
|
hidden: true,
|
|
73
68
|
};
|
|
74
|
-
|
|
69
|
+
export const OPTION_NO_PRETTY = {
|
|
75
70
|
longName: "no-pretty",
|
|
76
71
|
description: "do not pretty-format JSON responses",
|
|
77
72
|
hidden: true,
|
|
78
73
|
};
|
|
79
|
-
|
|
74
|
+
export const OPTION_VERBOSE = {
|
|
80
75
|
longName: "verbose",
|
|
81
76
|
description: "print detailed log information to console",
|
|
82
77
|
hidden: true,
|
|
83
78
|
};
|
|
84
|
-
|
|
79
|
+
export const OPTION_FORCE = {
|
|
85
80
|
longName: "force",
|
|
86
81
|
description: "force the command execution",
|
|
87
82
|
};
|
|
88
|
-
|
|
83
|
+
export const OPTION_CLIENT_ID = {
|
|
89
84
|
longName: "client-id",
|
|
90
85
|
description: "client id for interactive oauth session authentication",
|
|
91
86
|
args: [{ name: "id" }],
|
|
@@ -95,7 +90,7 @@ exports.OPTION_CLIENT_ID = {
|
|
|
95
90
|
message: `Please enter your client ID:`,
|
|
96
91
|
},
|
|
97
92
|
};
|
|
98
|
-
|
|
93
|
+
export const OPTION_CLIENT_SECRET = {
|
|
99
94
|
longName: "client-secret",
|
|
100
95
|
description: "client secret for interactive oauth session authentication",
|
|
101
96
|
args: [{ name: "secret" }],
|
|
@@ -105,7 +100,7 @@ exports.OPTION_CLIENT_SECRET = {
|
|
|
105
100
|
message: `Please enter your client secret:`,
|
|
106
101
|
},
|
|
107
102
|
};
|
|
108
|
-
|
|
103
|
+
export const OPTION_AUTHORIZATION_URL = {
|
|
109
104
|
longName: "authorization-url",
|
|
110
105
|
description: "authorization url for interactive oauth session authentication",
|
|
111
106
|
args: [{ name: "url" }],
|
|
@@ -115,7 +110,7 @@ exports.OPTION_AUTHORIZATION_URL = {
|
|
|
115
110
|
message: `Please enter your authorization URL:`,
|
|
116
111
|
},
|
|
117
112
|
};
|
|
118
|
-
|
|
113
|
+
export const OPTION_TOKEN_URL = {
|
|
119
114
|
longName: "token-url",
|
|
120
115
|
description: "token url for interactive oauth session authentication",
|
|
121
116
|
args: [{ name: "url" }],
|
|
@@ -125,7 +120,7 @@ exports.OPTION_TOKEN_URL = {
|
|
|
125
120
|
message: `Please enter your token URL:`,
|
|
126
121
|
},
|
|
127
122
|
};
|
|
128
|
-
|
|
123
|
+
export const OPTION_ACCESS_TOKEN = {
|
|
129
124
|
longName: "access-token",
|
|
130
125
|
description: "access token for interactive oauth session authentication",
|
|
131
126
|
args: [{ name: "token" }],
|
|
@@ -135,7 +130,7 @@ exports.OPTION_ACCESS_TOKEN = {
|
|
|
135
130
|
message: `Please enter your access token:`,
|
|
136
131
|
},
|
|
137
132
|
};
|
|
138
|
-
|
|
133
|
+
export const OPTION_REFRESH_TOKEN = {
|
|
139
134
|
longName: "refresh-token",
|
|
140
135
|
description: "refresh token for interactive oauth session authentication",
|
|
141
136
|
args: [{ name: "token" }],
|
|
@@ -145,7 +140,7 @@ exports.OPTION_REFRESH_TOKEN = {
|
|
|
145
140
|
message: `Please enter your refresh token:`,
|
|
146
141
|
},
|
|
147
142
|
};
|
|
148
|
-
|
|
143
|
+
export const OPTION_EXPIRES_IN = {
|
|
149
144
|
longName: "expires-in",
|
|
150
145
|
description: "expires in information for interactive oauth session authentication",
|
|
151
146
|
args: [{ name: "expires" }],
|
|
@@ -155,7 +150,7 @@ exports.OPTION_EXPIRES_IN = {
|
|
|
155
150
|
message: `Please enter a value for expires in:`,
|
|
156
151
|
},
|
|
157
152
|
};
|
|
158
|
-
|
|
153
|
+
export const OPTION_SECRETS_FILE = {
|
|
159
154
|
longName: "secrets-file",
|
|
160
155
|
description: "path to secrets file",
|
|
161
156
|
args: [{ name: "file" }],
|
|
@@ -165,7 +160,7 @@ exports.OPTION_SECRETS_FILE = {
|
|
|
165
160
|
message: `Please enter the path to the secrets file:`,
|
|
166
161
|
},
|
|
167
162
|
};
|
|
168
|
-
|
|
163
|
+
export const OPTION_CODE = {
|
|
169
164
|
longName: "code",
|
|
170
165
|
description: "code for oauth token retrieval",
|
|
171
166
|
args: [{ name: "code" }],
|
|
@@ -175,20 +170,20 @@ exports.OPTION_CODE = {
|
|
|
175
170
|
message: `Please enter the code for retrieving the oauth access_token and refresh_token:`,
|
|
176
171
|
},
|
|
177
172
|
};
|
|
178
|
-
|
|
173
|
+
export const OPTION_PASSCODE = {
|
|
179
174
|
longName: "passcode",
|
|
180
175
|
description: "passcode for interactive session authentication",
|
|
181
176
|
args: [{ name: "passcode" }],
|
|
182
177
|
hidden: true,
|
|
183
178
|
};
|
|
184
|
-
|
|
185
|
-
|
|
179
|
+
export const CONFIG_PASSCODE_FUNCTION = "passcodeFunction";
|
|
180
|
+
export const OPTION_OPTIONS_FILE = {
|
|
186
181
|
longName: "options-file",
|
|
187
182
|
description: "path to options file",
|
|
188
183
|
args: [{ name: "file" }],
|
|
189
184
|
hidden: true,
|
|
190
185
|
};
|
|
191
|
-
|
|
186
|
+
export const OPTION_FILE_PATH = {
|
|
192
187
|
longName: "file-path",
|
|
193
188
|
description: "specifies the file to use as input for the command",
|
|
194
189
|
args: [{ name: "path" }],
|
|
@@ -197,7 +192,7 @@ exports.OPTION_FILE_PATH = {
|
|
|
197
192
|
type: "text",
|
|
198
193
|
},
|
|
199
194
|
};
|
|
200
|
-
|
|
195
|
+
export const OPTION_INPUT = {
|
|
201
196
|
longName: "input",
|
|
202
197
|
description: "specifies input as string to use for the command",
|
|
203
198
|
args: [{ name: "input" }],
|
|
@@ -206,7 +201,7 @@ exports.OPTION_INPUT = {
|
|
|
206
201
|
type: "text",
|
|
207
202
|
},
|
|
208
203
|
};
|
|
209
|
-
|
|
204
|
+
export const OPTION_BROWSER = {
|
|
210
205
|
longName: "browser",
|
|
211
206
|
description: "specifies the browser to open",
|
|
212
207
|
args: [{ name: "browser" }],
|
|
@@ -215,15 +210,23 @@ exports.OPTION_BROWSER = {
|
|
|
215
210
|
type: "select",
|
|
216
211
|
},
|
|
217
212
|
};
|
|
218
|
-
|
|
213
|
+
export const OPTION_AUTHORIZATION_FLOW = {
|
|
219
214
|
longName: "authorization-flow",
|
|
220
215
|
description: "specifies the authorization flow to use",
|
|
221
216
|
args: [{ name: "authorization-flow" }],
|
|
222
217
|
choices: [
|
|
223
|
-
|
|
224
|
-
|
|
218
|
+
GrantType.authorization_code,
|
|
219
|
+
GrantType.client_credentials,
|
|
225
220
|
],
|
|
226
|
-
default:
|
|
221
|
+
default: GrantType.authorization_code,
|
|
227
222
|
required: true,
|
|
228
223
|
hidden: true,
|
|
229
224
|
};
|
|
225
|
+
export const OPTION_TLS_VERSION = {
|
|
226
|
+
longName: "tls-version",
|
|
227
|
+
description: "specifies the TLS version to use for HTTPS connections",
|
|
228
|
+
args: [{ name: "version" }],
|
|
229
|
+
choices: [DEFAULT_TLS_VERSION, "TLSv1.3"],
|
|
230
|
+
default: DEFAULT_TLS_VERSION,
|
|
231
|
+
hidden: true,
|
|
232
|
+
};
|
package/discovery/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Discovery, DiscoveryMetadata } from "../types";
|
|
1
|
+
import { Discovery, DiscoveryMetadata } from "../types.js";
|
|
2
2
|
export declare const getPathToDiscoveryDocument: () => string;
|
|
3
3
|
export declare const getMetadata: () => Promise<Array<DiscoveryMetadata>>;
|
|
4
4
|
export declare const addMetadata: ({ tenant, addedAt, }: Omit<DiscoveryMetadata, "hash">) => Promise<void>;
|
package/discovery/index.js
CHANGED
|
@@ -1,40 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const utils_2 = require("../utils/utils");
|
|
12
|
-
const logger_1 = require("../logger");
|
|
13
|
-
const config_1 = require("../config");
|
|
14
|
-
const constants_1 = require("../constants");
|
|
15
|
-
const core_1 = require("../config/core");
|
|
16
|
-
const getLogger = () => (0, logger_1.get)("discovery");
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { getPath, readFile as readFileFromCache, writeFile as writeFileToCache, } from "../cache/index.js";
|
|
4
|
+
import { getDiscoveryPaths, getVersion } from "../config/core.js";
|
|
5
|
+
import { get as getConfig } from "../config/index.js";
|
|
6
|
+
import { DISCOVERY_DOCUMENT_PREFIX, DISCOVERY_METADATA_PATH, } from "../constants.js";
|
|
7
|
+
import { get } from "../logger/index.js";
|
|
8
|
+
import { parseVersion, sha256 } from "../utils/utils.js";
|
|
9
|
+
import { validate } from "./utils.js";
|
|
10
|
+
const getLogger = () => get("discovery");
|
|
17
11
|
let initialized = false;
|
|
18
12
|
let document;
|
|
19
13
|
let metadata;
|
|
20
14
|
function getHash(tenant) {
|
|
21
|
-
return
|
|
15
|
+
return sha256(`${tenant}${JSON.stringify(getDiscoveryPaths())}`).replace(/[/\\]/g, "_");
|
|
22
16
|
}
|
|
23
17
|
const getDocumentName = () => {
|
|
24
18
|
const { trace } = getLogger();
|
|
25
|
-
const config = (
|
|
19
|
+
const config = getConfig();
|
|
26
20
|
const hash = getHash(config.publicfqdn);
|
|
27
|
-
const name = `${
|
|
21
|
+
const name = `${DISCOVERY_DOCUMENT_PREFIX}${hash}.json`;
|
|
28
22
|
trace(`calculating document name for host ${config.host}, name ${name}`);
|
|
29
23
|
return name;
|
|
30
24
|
};
|
|
31
|
-
const getPathToDiscoveryDocument = () =>
|
|
32
|
-
exports.getPathToDiscoveryDocument = getPathToDiscoveryDocument;
|
|
25
|
+
export const getPathToDiscoveryDocument = () => getPath(getDocumentName());
|
|
33
26
|
const initMetadata = async () => {
|
|
34
27
|
const { error } = getLogger();
|
|
35
28
|
if (!metadata) {
|
|
36
29
|
try {
|
|
37
|
-
metadata = JSON.parse(await (
|
|
30
|
+
metadata = JSON.parse(await readFileFromCache(DISCOVERY_METADATA_PATH));
|
|
38
31
|
}
|
|
39
32
|
catch (err) {
|
|
40
33
|
error("error while reading discovery metadata", err.stack);
|
|
@@ -42,27 +35,24 @@ const initMetadata = async () => {
|
|
|
42
35
|
}
|
|
43
36
|
}
|
|
44
37
|
};
|
|
45
|
-
const getMetadata = async () => {
|
|
38
|
+
export const getMetadata = async () => {
|
|
46
39
|
await initMetadata();
|
|
47
40
|
return metadata;
|
|
48
41
|
};
|
|
49
|
-
|
|
50
|
-
const addMetadata = async ({ tenant, addedAt, }) => {
|
|
42
|
+
export const addMetadata = async ({ tenant, addedAt, }) => {
|
|
51
43
|
await initMetadata();
|
|
52
44
|
metadata = metadata.filter((t) => t.tenant !== tenant);
|
|
53
45
|
const hash = getHash(tenant);
|
|
54
46
|
metadata.push({ tenant, addedAt, hash });
|
|
55
|
-
await (
|
|
47
|
+
await writeFileToCache(DISCOVERY_METADATA_PATH, JSON.stringify(metadata));
|
|
56
48
|
};
|
|
57
|
-
|
|
58
|
-
const clear = () => {
|
|
49
|
+
export const clear = () => {
|
|
59
50
|
initialized = false;
|
|
60
51
|
document = undefined;
|
|
61
52
|
metadata = undefined;
|
|
62
53
|
};
|
|
63
|
-
exports.clear = clear;
|
|
64
54
|
/* jscpd:ignore-start */
|
|
65
|
-
const init = async () => {
|
|
55
|
+
export const init = async () => {
|
|
66
56
|
const { trace, error, debug } = getLogger();
|
|
67
57
|
if (initialized) {
|
|
68
58
|
return document;
|
|
@@ -72,7 +62,7 @@ const init = async () => {
|
|
|
72
62
|
let schema;
|
|
73
63
|
try {
|
|
74
64
|
trace("reading discovery document");
|
|
75
|
-
const file = await (
|
|
65
|
+
const file = await readFileFromCache(getDocumentName());
|
|
76
66
|
document = JSON.parse(file);
|
|
77
67
|
}
|
|
78
68
|
catch (err) {
|
|
@@ -82,13 +72,13 @@ const init = async () => {
|
|
|
82
72
|
try {
|
|
83
73
|
trace("reading schema document");
|
|
84
74
|
try {
|
|
85
|
-
const file = await
|
|
75
|
+
const file = await fs.readFile(path.join(import.meta.dirname, "..", "..", "schemas", "discovery.json"), "utf-8");
|
|
86
76
|
schema = JSON.parse(file);
|
|
87
77
|
}
|
|
88
78
|
catch (err) {
|
|
89
79
|
debug("failed reading schema, trying again", err.stack);
|
|
90
80
|
// path changes after build
|
|
91
|
-
const file = await
|
|
81
|
+
const file = await fs.readFile(path.join(import.meta.dirname, "..", "schemas", "discovery.json"), "utf-8");
|
|
92
82
|
schema = JSON.parse(file);
|
|
93
83
|
}
|
|
94
84
|
}
|
|
@@ -97,21 +87,20 @@ const init = async () => {
|
|
|
97
87
|
throw err;
|
|
98
88
|
}
|
|
99
89
|
debug("validating discovery document against schema");
|
|
100
|
-
const result = await
|
|
90
|
+
const result = await validate(schema, document);
|
|
101
91
|
if (result.result === "INVALID") {
|
|
102
92
|
error("discovery document contains invalid data", result.errors);
|
|
103
93
|
throw new Error("discovery document contains invalid data");
|
|
104
94
|
}
|
|
105
95
|
return document;
|
|
106
96
|
};
|
|
107
|
-
|
|
108
|
-
const compareEtags = async () => {
|
|
97
|
+
export const compareEtags = async () => {
|
|
109
98
|
const { debug, error } = getLogger();
|
|
110
99
|
try {
|
|
111
|
-
const doc = await
|
|
112
|
-
const config = (
|
|
100
|
+
const doc = await init();
|
|
101
|
+
const config = getConfig();
|
|
113
102
|
if (config.etag && doc) {
|
|
114
|
-
const etag =
|
|
103
|
+
const etag = sha256(JSON.stringify(doc));
|
|
115
104
|
if (config.etag === etag) {
|
|
116
105
|
debug("etags match: %s", config.etag);
|
|
117
106
|
return true;
|
|
@@ -126,12 +115,11 @@ const compareEtags = async () => {
|
|
|
126
115
|
}
|
|
127
116
|
return true;
|
|
128
117
|
};
|
|
129
|
-
|
|
130
|
-
const checkVersion = async () => {
|
|
118
|
+
export const checkVersion = async () => {
|
|
131
119
|
const { debug } = getLogger();
|
|
132
|
-
const doc = await
|
|
133
|
-
const local =
|
|
134
|
-
const server =
|
|
120
|
+
const doc = await init();
|
|
121
|
+
const local = parseVersion(getVersion());
|
|
122
|
+
const server = parseVersion(doc.info["x-document-version"]);
|
|
135
123
|
if (local.major < server.major ||
|
|
136
124
|
(local.major === server.major && local.minor < server.minor)) {
|
|
137
125
|
debug(`CLI is outdated (local: ${JSON.stringify(local)}, server: ${JSON.stringify(server)})`);
|
|
@@ -139,4 +127,3 @@ const checkVersion = async () => {
|
|
|
139
127
|
}
|
|
140
128
|
return { status: "UPTODATE" };
|
|
141
129
|
};
|
|
142
|
-
exports.checkVersion = checkVersion;
|