@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
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getLowerVersion = getLowerVersion;
|
|
7
|
-
exports.mergeDiscoveries = mergeDiscoveries;
|
|
8
|
-
const compare_versions_1 = require("compare-versions");
|
|
9
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
-
function getLowerVersion(a, b) {
|
|
11
|
-
return [a, b].sort(compare_versions_1.compareVersions)[0];
|
|
1
|
+
import { compareVersions } from "compare-versions";
|
|
2
|
+
import { merge } from "lodash-es";
|
|
3
|
+
export function getLowerVersion(a, b) {
|
|
4
|
+
return [a, b].sort(compareVersions)[0];
|
|
12
5
|
}
|
|
13
|
-
function mergeDiscoveries(discovery, newDiscovery) {
|
|
14
|
-
|
|
6
|
+
export function mergeDiscoveries(discovery, newDiscovery) {
|
|
7
|
+
merge(discovery, newDiscovery);
|
|
15
8
|
// eslint-disable-next-line no-param-reassign
|
|
16
9
|
discovery.info.version = getLowerVersion(discovery.info.version, newDiscovery.info.version);
|
|
17
10
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const logger_1 = require("../../../logger");
|
|
5
|
-
const handler_1 = require("../../handler");
|
|
1
|
+
import { getMetadata } from "../../../discovery/index.js";
|
|
2
|
+
import { get as getLogger } from "../../../logger/index.js";
|
|
3
|
+
import { createNextHandler, createParseArgumentsHandler, } from "../../handler/index.js";
|
|
6
4
|
const show = async () => async () => {
|
|
7
|
-
const { output } = (
|
|
8
|
-
const metadata = await
|
|
5
|
+
const { output } = getLogger("commands.show");
|
|
6
|
+
const metadata = await getMetadata();
|
|
9
7
|
if (metadata.length === 0) {
|
|
10
8
|
output("Local CLI cache is empty");
|
|
11
9
|
throw new Error("local CLI cache is empty");
|
|
@@ -25,6 +23,6 @@ const showCommand = {
|
|
|
25
23
|
type: "command",
|
|
26
24
|
command: "show",
|
|
27
25
|
description: "display local CLI cache entries",
|
|
28
|
-
handler:
|
|
26
|
+
handler: createNextHandler("command.config.cache.show", createParseArgumentsHandler(), show),
|
|
29
27
|
};
|
|
30
|
-
|
|
28
|
+
export default showCommand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AddCommands } from "../../types";
|
|
1
|
+
import { AddCommands } from "../../types.js";
|
|
2
2
|
export declare const addCommands: AddCommands;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const utils_1 = require("../../utils/utils");
|
|
10
|
-
const handler_1 = require("../handler");
|
|
11
|
-
const getLogger = () => (0, logger_1.get)("commands.host");
|
|
1
|
+
import { get } from "../../config/index.js";
|
|
2
|
+
import { OPTION_HOST } from "../../constants.js";
|
|
3
|
+
import { get as getLoggerOrig } from "../../logger/index.js";
|
|
4
|
+
import { get as getSettings, remove, set as setSettings, } from "../../settings/index.js";
|
|
5
|
+
import { buildCommand } from "../../utils/commands.js";
|
|
6
|
+
import { getBin, getInfoFromTenant } from "../../utils/utils.js";
|
|
7
|
+
import { createNextHandler, createParseArgumentsHandler, } from "../handler/index.js";
|
|
8
|
+
const getLogger = () => getLoggerOrig("commands.host");
|
|
12
9
|
const set = async () => async () => {
|
|
13
|
-
const config =
|
|
10
|
+
const config = get();
|
|
14
11
|
try {
|
|
15
12
|
// throws if host is not valid
|
|
16
|
-
|
|
17
|
-
await (
|
|
13
|
+
getInfoFromTenant(config.arguments.host, config.verbose, false);
|
|
14
|
+
await setSettings(OPTION_HOST.longName, config.arguments.host);
|
|
18
15
|
}
|
|
19
16
|
catch (err) {
|
|
20
17
|
const { debug, output } = getLogger();
|
|
@@ -25,20 +22,20 @@ const set = async () => async () => {
|
|
|
25
22
|
};
|
|
26
23
|
const show = async () => async () => {
|
|
27
24
|
const { output } = getLogger();
|
|
28
|
-
const settings = await (
|
|
29
|
-
if (settings[
|
|
30
|
-
output(settings[
|
|
25
|
+
const settings = await getSettings();
|
|
26
|
+
if (settings[OPTION_HOST.longName]) {
|
|
27
|
+
output(settings[OPTION_HOST.longName]);
|
|
31
28
|
}
|
|
32
29
|
else {
|
|
33
|
-
output(`no global host set. use ${
|
|
30
|
+
output(`no global host set. use ${getBin()} config host set <host> to set a global host`);
|
|
34
31
|
throw new Error("no global host set");
|
|
35
32
|
}
|
|
36
33
|
};
|
|
37
34
|
const clean = async () => async () => {
|
|
38
|
-
await
|
|
35
|
+
await remove(OPTION_HOST.longName);
|
|
39
36
|
};
|
|
40
|
-
const addCommands = async (program) => {
|
|
41
|
-
await
|
|
37
|
+
export const addCommands = async (program) => {
|
|
38
|
+
await buildCommand(program, {
|
|
42
39
|
type: "topCommand",
|
|
43
40
|
command: "host",
|
|
44
41
|
description: "configure host properties",
|
|
@@ -48,7 +45,7 @@ const addCommands = async (program) => {
|
|
|
48
45
|
command: "set",
|
|
49
46
|
description: "set global host",
|
|
50
47
|
args: [{ argument: "host", description: "global host" }],
|
|
51
|
-
handler:
|
|
48
|
+
handler: createNextHandler("command.config.host.set", createParseArgumentsHandler([{ argument: "host" }]), set),
|
|
52
49
|
},
|
|
53
50
|
{
|
|
54
51
|
type: "command",
|
|
@@ -65,4 +62,3 @@ const addCommands = async (program) => {
|
|
|
65
62
|
],
|
|
66
63
|
});
|
|
67
64
|
};
|
|
68
|
-
exports.addCommands = addCommands;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AddCommands } from "../../types";
|
|
1
|
+
import { AddCommands } from "../../types.js";
|
|
2
2
|
export declare const addCommands: AddCommands;
|
|
@@ -1,52 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.addCommands = void 0;
|
|
40
|
-
const path_1 = __importDefault(require("path"));
|
|
41
|
-
const commands = __importStar(require("../../utils/commands"));
|
|
42
|
-
const utils_1 = require("../../dwc/utils");
|
|
43
|
-
const addCommands = async (program) => {
|
|
1
|
+
import path from "path";
|
|
2
|
+
import * as commands from "../../utils/commands.js";
|
|
3
|
+
import { addCommandsFromFolder } from "../../dwc/utils.js";
|
|
4
|
+
export const addCommands = async (program) => {
|
|
44
5
|
const configCommand = await commands.buildCommand(program, {
|
|
45
6
|
type: "topCommand",
|
|
46
7
|
command: "config",
|
|
47
8
|
description: "configure your CLI",
|
|
48
9
|
subCommands: [],
|
|
49
10
|
});
|
|
50
|
-
await (
|
|
11
|
+
await addCommandsFromFolder(path.join(import.meta.dirname), configCommand);
|
|
51
12
|
};
|
|
52
|
-
exports.addCommands = addCommands;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AddCommands } from "../../types";
|
|
1
|
+
import { AddCommands } from "../../types.js";
|
|
2
2
|
export declare const addCommands: AddCommands;
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const logger_1 = require("../../logger");
|
|
8
|
-
const commands_1 = require("../../utils/commands");
|
|
9
|
-
const handler_1 = require("../handler");
|
|
1
|
+
import { get as getConfig } from "../../config/index.js";
|
|
2
|
+
import { getAuthenticationMethods } from "../../config/core.js";
|
|
3
|
+
import { AuthenticationMethod } from "../../constants.js";
|
|
4
|
+
import { get as getLogger } from "../../logger/index.js";
|
|
5
|
+
import { buildCommand } from "../../utils/commands.js";
|
|
6
|
+
import { createNextHandler, createMandatoryOptionsHandler, createParseArgumentsHandler, } from "../handler/index.js";
|
|
10
7
|
const passcode = async () => async () => {
|
|
11
|
-
const { output } = (
|
|
12
|
-
const config = (
|
|
8
|
+
const { output } = getLogger("commands.passcode");
|
|
9
|
+
const config = getConfig();
|
|
13
10
|
output(config.passcodeUrl);
|
|
14
11
|
};
|
|
15
12
|
const passcodeCommand = {
|
|
16
13
|
type: "command",
|
|
17
14
|
command: "passcode-url",
|
|
18
15
|
description: "display the passcode url",
|
|
19
|
-
handler:
|
|
16
|
+
handler: createNextHandler("commands.config.passcode-url", createParseArgumentsHandler(), createMandatoryOptionsHandler(), passcode),
|
|
20
17
|
};
|
|
21
|
-
const addCommands = async (program) => {
|
|
22
|
-
if (
|
|
23
|
-
await
|
|
18
|
+
export const addCommands = async (program) => {
|
|
19
|
+
if (getAuthenticationMethods().includes(AuthenticationMethod.passcode)) {
|
|
20
|
+
await buildCommand(program, passcodeCommand);
|
|
24
21
|
}
|
|
25
22
|
};
|
|
26
|
-
exports.addCommands = addCommands;
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const handler_1 = require("../../handler");
|
|
6
|
-
const file_1 = require("../../handler/authentication/oauth/secretsProvider/file");
|
|
7
|
-
const logger_1 = require("../../../logger");
|
|
1
|
+
import { OPTION_SECRETS_FILE } from "../../../constants.js";
|
|
2
|
+
import { createNextHandler, createOptionsHandler, createParseArgumentsHandler, } from "../../handler/index.js";
|
|
3
|
+
import { readSecretsFile } from "../../handler/authentication/oauth/secretsProvider/file.js";
|
|
4
|
+
import { get } from "../../../logger/index.js";
|
|
8
5
|
/* jscpd:ignore-end */
|
|
9
6
|
const create = () => async () => async () => {
|
|
10
|
-
const { output } =
|
|
11
|
-
await
|
|
7
|
+
const { output } = get("commands.secrets.check");
|
|
8
|
+
await readSecretsFile();
|
|
12
9
|
output("the secrets file is consistent");
|
|
13
10
|
};
|
|
14
|
-
exports.create = create;
|
|
15
11
|
const refreshCommand = {
|
|
16
12
|
type: "command",
|
|
17
13
|
command: "check",
|
|
18
14
|
description: "check secrets file consistency",
|
|
19
|
-
handler:
|
|
20
|
-
{ ...
|
|
21
|
-
]),
|
|
15
|
+
handler: createNextHandler("commands.config.secrets.check", createParseArgumentsHandler(), createOptionsHandler([
|
|
16
|
+
{ ...OPTION_SECRETS_FILE, required: true, hidden: false },
|
|
17
|
+
]), create()),
|
|
22
18
|
};
|
|
23
|
-
|
|
19
|
+
export default refreshCommand;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const refresh_command_1 = __importDefault(require("./refresh.command"));
|
|
7
|
-
const reset_command_1 = __importDefault(require("./reset.command"));
|
|
8
|
-
const show_command_1 = __importDefault(require("./show.command"));
|
|
9
|
-
const check_command_1 = __importDefault(require("./check.command"));
|
|
1
|
+
import refreshCommand from "./refresh.command.js";
|
|
2
|
+
import resetCommand from "./reset.command.js";
|
|
3
|
+
import showCommand from "./show.command.js";
|
|
4
|
+
import checkCommand from "./check.command.js";
|
|
10
5
|
const secretsCommand = {
|
|
11
6
|
type: "topCommand",
|
|
12
7
|
command: "secrets",
|
|
13
8
|
description: "work with the locally stored secrets",
|
|
14
|
-
subCommands: [
|
|
9
|
+
subCommands: [showCommand, refreshCommand, resetCommand, checkCommand],
|
|
15
10
|
};
|
|
16
|
-
|
|
11
|
+
export default secretsCommand;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const handler_1 = require("../../handler");
|
|
5
|
-
const refreshToken_1 = require("../../handler/authentication/oauth/tokenProvider/refreshToken");
|
|
1
|
+
import { OPTION_HOST } from "../../../constants.js";
|
|
2
|
+
import { createNextHandler, createOptionsHandler, createParseArgumentsHandler, createResilientHandler, } from "../../handler/index.js";
|
|
3
|
+
import { create as createRefreshTokenHandler } from "../../handler/authentication/oauth/tokenProvider/refreshToken.js";
|
|
6
4
|
/* jscpd:ignore-end */
|
|
7
5
|
const refreshCommand = {
|
|
8
6
|
type: "command",
|
|
9
7
|
command: "refresh",
|
|
10
8
|
description: "refresh the access token for interactive OAuth authentication",
|
|
11
|
-
handler:
|
|
9
|
+
handler: createNextHandler("commands.config.secrets.refresh", createParseArgumentsHandler(), createOptionsHandler([{ ...OPTION_HOST, hidden: false }]), createResilientHandler(createRefreshTokenHandler())),
|
|
12
10
|
};
|
|
13
|
-
|
|
11
|
+
export default refreshCommand;
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/* jscpd:ignore-start */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { SecretsStorageSingleton } from "../../../cache/secrets/SecretsStorageSingleton.js";
|
|
3
|
+
import { createNextHandler, createParseArgumentsHandler, createResilientHandler, } from "../../handler/index.js";
|
|
4
|
+
import { create as createSecretsFromCacheProvider } from "../../handler/authentication/oauth/secretsProvider/cache.js";
|
|
7
5
|
/* jscpd:ignore-end */
|
|
8
6
|
const removeSecrets = async () => async () => {
|
|
9
|
-
await
|
|
7
|
+
await SecretsStorageSingleton.SINGLETON.deleteAllSecrets();
|
|
10
8
|
};
|
|
11
9
|
const resetCommand = {
|
|
12
10
|
type: "command",
|
|
13
11
|
command: "reset",
|
|
14
12
|
description: "remove all locally stored secrets for interactive OAuth authentication",
|
|
15
|
-
handler:
|
|
13
|
+
handler: createNextHandler("commands.config.secrets.reset", createParseArgumentsHandler(), createResilientHandler(createSecretsFromCacheProvider()), removeSecrets),
|
|
16
14
|
};
|
|
17
|
-
|
|
15
|
+
export default resetCommand;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/* jscpd:ignore-start */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { SecretsStorageSingleton } from "../../../cache/secrets/SecretsStorageSingleton.js";
|
|
3
|
+
import { get as getLogger } from "../../../logger/index.js";
|
|
4
|
+
import { createNextHandler, createParseArgumentsHandler, createResilientHandler, } from "../../handler/index.js";
|
|
5
|
+
import { create as createSecretsFromCacheProvider } from "../../handler/authentication/oauth/secretsProvider/cache.js";
|
|
8
6
|
/* jscpd:ignore-end */
|
|
9
7
|
const showSecrets = async () => async () => {
|
|
10
|
-
const { output, error } = (
|
|
8
|
+
const { output, error } = getLogger("commands.secrets-show");
|
|
11
9
|
try {
|
|
12
|
-
const secrets = await
|
|
10
|
+
const secrets = await SecretsStorageSingleton.SINGLETON.getAllSecrets();
|
|
13
11
|
if (secrets.length === 0) {
|
|
14
12
|
output("No secrets exist");
|
|
15
13
|
}
|
|
@@ -27,6 +25,6 @@ const showCommand = {
|
|
|
27
25
|
type: "command",
|
|
28
26
|
command: "show",
|
|
29
27
|
description: "display locally stored secrets for interactive OAuth authentication",
|
|
30
|
-
handler:
|
|
28
|
+
handler: createNextHandler("commands.config.secrets.show", createParseArgumentsHandler(), createResilientHandler(createSecretsFromCacheProvider()), showSecrets),
|
|
31
29
|
};
|
|
32
|
-
|
|
30
|
+
export default showCommand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Handler } from "../../../types";
|
|
1
|
+
import { Handler } from "../../../types.js";
|
|
2
2
|
export declare const create: () => Handler;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
: () => (0, next_1.create)("commands.handler.authentication", (0, resilient_1.create)((0, next_1.create)("commands.handler.authentication$oauth", (0, cache_1.create)(), (0, refreshToken_1.create)())), (0, options_1.create)(constants_1.OPTION_CLIENT_ID), (0, options_1.create)(constants_1.OPTION_CLIENT_SECRET), (0, options_1.create)(constants_1.OPTION_ACCESS_TOKEN), (0, options_1.create)(constants_1.OPTION_REFRESH_TOKEN), (0, options_1.create)(constants_1.OPTION_CODE), (0, options_1.create)(constants_1.OPTION_TOKEN_URL), (0, options_1.create)(constants_1.OPTION_AUTHORIZATION_URL), (0, options_1.create)(constants_1.OPTION_AUTHORIZATION_FLOW), (0, core_1.getAuthenticationMethods)().includes(constants_1.AuthenticationMethod.passcode)
|
|
20
|
-
? (0, options_1.create)(constants_1.OPTION_PASSCODE)
|
|
21
|
-
: (0, succeed_1.create)(), (0, options_1.create)(constants_1.OPTION_SECRETS_FILE), (0, or_1.create)("commands.handler.authentication$handler", (0, setAuthorization_1.create)(), (0, passcode_1.create)(), (0, oauth_1.create)()));
|
|
1
|
+
import { create as createNextHandler } from "../next.js";
|
|
2
|
+
import { create as createOrHandler } from "../or.js";
|
|
3
|
+
import { create as createOauthHandler } from "./oauth/index.js";
|
|
4
|
+
import { create as createResilientHandler } from "../resilient.js";
|
|
5
|
+
import { create as createCacheSecretsProvider } from "./oauth/secretsProvider/cache.js";
|
|
6
|
+
import { create as createRefreshTokenHandler } from "./oauth/tokenProvider/refreshToken.js";
|
|
7
|
+
import { create as createSetAuthorizationHandler } from "./oauth/tokenProvider/setAuthorization.js";
|
|
8
|
+
import { create as createPasscodeHandler } from "./passcode/index.js";
|
|
9
|
+
import { create as createTechnicalJWTHandler } from "./technicalJWT/index.js";
|
|
10
|
+
import { create as createOptionsHandler } from "../options/index.js";
|
|
11
|
+
import { AuthenticationMethod, OPTION_ACCESS_TOKEN, OPTION_AUTHORIZATION_FLOW, OPTION_AUTHORIZATION_URL, OPTION_CLIENT_ID, OPTION_CLIENT_SECRET, OPTION_CODE, OPTION_PASSCODE, OPTION_REFRESH_TOKEN, OPTION_SECRETS_FILE, OPTION_TOKEN_URL, } from "../../../constants.js";
|
|
12
|
+
import { getAuthenticationMethods } from "../../../config/core.js";
|
|
13
|
+
import { create as createSucceedHandler } from "../succeed.js";
|
|
14
|
+
export const create = process.env.SUPPORT === "true"
|
|
15
|
+
? createTechnicalJWTHandler
|
|
16
|
+
: () => createNextHandler("commands.handler.authentication", createResilientHandler(createNextHandler("commands.handler.authentication$oauth", createCacheSecretsProvider(), createRefreshTokenHandler())), createOptionsHandler(OPTION_CLIENT_ID), createOptionsHandler(OPTION_CLIENT_SECRET), createOptionsHandler(OPTION_ACCESS_TOKEN), createOptionsHandler(OPTION_REFRESH_TOKEN), createOptionsHandler(OPTION_CODE), createOptionsHandler(OPTION_TOKEN_URL), createOptionsHandler(OPTION_AUTHORIZATION_URL), createOptionsHandler(OPTION_AUTHORIZATION_FLOW), getAuthenticationMethods().includes(AuthenticationMethod.passcode)
|
|
17
|
+
? createOptionsHandler(OPTION_PASSCODE)
|
|
18
|
+
: createSucceedHandler(), createOptionsHandler(OPTION_SECRETS_FILE), createOrHandler("commands.handler.authentication$handler", createSetAuthorizationHandler(), createPasscodeHandler(), createOauthHandler()));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Handler } from "../../../../types";
|
|
2
|
-
export declare const create: (
|
|
1
|
+
import { Handler } from "../../../../types.js";
|
|
2
|
+
export declare const create: () => Handler;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if ((0, core_1.getAuthenticationMethods)().includes(constants_1.AuthenticationMethod.oauth)) {
|
|
14
|
-
return (0, error_1.create)("failed to handle OAuth authorization", (0, next_1.create)("commands.handler.authentication.oauth", (0, checkOptionsExistence_1.create)(constants_1.OPTION_PASSCODE), (0, secretsProvider_1.create)(), (0, tokenProvider_1.create)(overrideExisting)));
|
|
1
|
+
import { create as createNextHandler } from "../../next.js";
|
|
2
|
+
import { create as createFailHandler } from "../../fail.js";
|
|
3
|
+
import { create as createErrorHandler } from "../../error.js";
|
|
4
|
+
import { create as createSecretsProvider } from "./secretsProvider/index.js";
|
|
5
|
+
import { create as createTokenProvider } from "./tokenProvider/index.js";
|
|
6
|
+
import { create as createCheckOptionsExistence } from "../../checkOptionsExistence.js";
|
|
7
|
+
import { AuthenticationMethod, OPTION_PASSCODE, } from "../../../../constants.js";
|
|
8
|
+
import { getAuthenticationMethods } from "../../../../config/core.js";
|
|
9
|
+
/* jscpd:ignore-end */
|
|
10
|
+
export const create = () => {
|
|
11
|
+
if (getAuthenticationMethods().includes(AuthenticationMethod.oauth)) {
|
|
12
|
+
return createErrorHandler("failed to handle OAuth authorization", createNextHandler("commands.handler.authentication.oauth", createCheckOptionsExistence(OPTION_PASSCODE), createSecretsProvider(), createTokenProvider()));
|
|
15
13
|
}
|
|
16
|
-
return (
|
|
14
|
+
return createFailHandler();
|
|
17
15
|
};
|
|
18
|
-
exports.create = create;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Handler } from "../../../../../types";
|
|
1
|
+
import { Handler } from "../../../../../types.js";
|
|
2
2
|
export declare const create: () => Handler;
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const SecretsStorageSingleton_1 = require("../../../../../cache/secrets/SecretsStorageSingleton");
|
|
6
|
-
const create = () => async () => async () => {
|
|
7
|
-
const { error, info } = (0, logger_1.get)("commands.handler.authentication.oauth.secretsProvider.cache");
|
|
1
|
+
import { get } from "../../../../../logger/index.js";
|
|
2
|
+
import { SecretsStorageSingleton } from "../../../../../cache/secrets/SecretsStorageSingleton.js";
|
|
3
|
+
export const create = () => async () => async () => {
|
|
4
|
+
const { error, info } = get("commands.handler.authentication.oauth.secretsProvider.cache");
|
|
8
5
|
info("reading secrets from cache");
|
|
9
6
|
try {
|
|
10
7
|
// verify whether secret is available by retrieving default secret for current host
|
|
11
|
-
await
|
|
8
|
+
await SecretsStorageSingleton.SINGLETON.getDefaultSecret();
|
|
12
9
|
}
|
|
13
10
|
catch (err) {
|
|
14
11
|
error("failed to read secrets from cache", err);
|
|
15
12
|
throw err;
|
|
16
13
|
}
|
|
17
14
|
};
|
|
18
|
-
exports.create = create;
|
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
async function readSecretsFile() {
|
|
15
|
-
const { output, error, debug } = (0, logger_1.get)("commands.handler.authentication.oauth.secretsProvider.file.readSecretsFile");
|
|
16
|
-
const secretsFile = (0, options_1.getOptionValueFromConfig)(constants_1.OPTION_SECRETS_FILE);
|
|
17
|
-
const config = (0, config_1.get)();
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import { create as createNextHandler } from "../../../next.js";
|
|
3
|
+
import { OPTION_SECRETS_FILE } from "../../../../../constants.js";
|
|
4
|
+
import { get } from "../../../../../logger/index.js";
|
|
5
|
+
import { get as getConfig } from "../../../../../config/index.js";
|
|
6
|
+
import { getOptionValueFromConfig } from "../../../../../utils/options.js";
|
|
7
|
+
import { create as createOptionsHandler } from "../../../options/index.js";
|
|
8
|
+
import { SecretsStorageSingleton } from "../../../../../cache/secrets/SecretsStorageSingleton.js";
|
|
9
|
+
import { isCustomClient, isSecretConsistent, updateUrls, } from "../../../../../cache/secrets/utils.js";
|
|
10
|
+
export async function readSecretsFile() {
|
|
11
|
+
const { output, error, debug } = get("commands.handler.authentication.oauth.secretsProvider.file.readSecretsFile");
|
|
12
|
+
const secretsFile = getOptionValueFromConfig(OPTION_SECRETS_FILE);
|
|
13
|
+
const config = getConfig();
|
|
18
14
|
try {
|
|
19
|
-
let content = JSON.parse(await
|
|
15
|
+
let content = JSON.parse(await fs.readFile(secretsFile, "utf8"));
|
|
20
16
|
content.tenantUrl = config.tenantUrl ?? content.tenantUrl;
|
|
21
|
-
content.customClient =
|
|
22
|
-
content = await
|
|
17
|
+
content.customClient = isCustomClient(content.client_id);
|
|
18
|
+
content = await updateUrls(content);
|
|
23
19
|
debug("secrets found from file");
|
|
24
|
-
const consistent =
|
|
20
|
+
const consistent = isSecretConsistent(content);
|
|
25
21
|
if (!consistent.consistent) {
|
|
26
22
|
output(`the provided secrets file is not consistent. ${consistent.errors.join(". ")}`);
|
|
27
23
|
throw new Error("inconsistent secrets file");
|
|
@@ -36,10 +32,9 @@ async function readSecretsFile() {
|
|
|
36
32
|
}
|
|
37
33
|
}
|
|
38
34
|
const handler = async () => async () => {
|
|
39
|
-
const { info } =
|
|
35
|
+
const { info } = get("commands.handler.authentication.oauth.secretsProvider.file");
|
|
40
36
|
info("reading secrets from file");
|
|
41
37
|
const content = await readSecretsFile();
|
|
42
|
-
await
|
|
38
|
+
await SecretsStorageSingleton.SINGLETON.storeSecret(content);
|
|
43
39
|
};
|
|
44
|
-
const create = () => (
|
|
45
|
-
exports.create = create;
|
|
40
|
+
export const create = () => createNextHandler("commands.handler.authentication.oauth.secretsProvider.file", createOptionsHandler([OPTION_SECRETS_FILE]), handler);
|