@sap-ux/odata-service-inquirer 2.10.0 → 2.11.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/dist/prompts/datasources/sap-system/credentials/questions.d.ts +4 -3
- package/dist/prompts/datasources/sap-system/credentials/questions.js +40 -6
- package/dist/prompts/datasources/sap-system/shared-prompts/shared-prompts.d.ts +3 -1
- package/dist/prompts/datasources/sap-system/shared-prompts/shared-prompts.js +5 -3
- package/dist/prompts/datasources/sap-system/system-selection/questions.js +0 -1
- package/dist/translations/odata-service-inquirer.i18n.json +6 -1
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { InputQuestion, PasswordQuestion } from '@sap-ux/inquirer-common';
|
|
1
|
+
import type { InputQuestion, PasswordQuestion, ConfirmQuestion } from '@sap-ux/inquirer-common';
|
|
2
2
|
import type { Answers } from 'inquirer';
|
|
3
3
|
import type { ConnectionValidator } from '../../../connectionValidator';
|
|
4
4
|
export declare enum BasicCredentialsPromptNames {
|
|
5
5
|
systemUsername = "systemUsername",
|
|
6
|
-
systemPassword = "systemPassword"
|
|
6
|
+
systemPassword = "systemPassword",
|
|
7
|
+
storeSystemCredentials = "storeSystemCredentials"
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* Re-usable credentials prompts for connection to systems using basic auth.
|
|
@@ -18,5 +19,5 @@ export declare enum BasicCredentialsPromptNames {
|
|
|
18
19
|
export declare function getCredentialsPrompts<T extends Answers>(connectionValidator: ConnectionValidator, promptNamespace?: string, sapClient?: {
|
|
19
20
|
sapClient: string | undefined;
|
|
20
21
|
isValid: boolean;
|
|
21
|
-
}): (InputQuestion<T> | PasswordQuestion<T>)[];
|
|
22
|
+
}): (InputQuestion<T> | PasswordQuestion<T> | ConfirmQuestion<T>)[];
|
|
22
23
|
//# sourceMappingURL=questions.d.ts.map
|
|
@@ -11,6 +11,7 @@ var BasicCredentialsPromptNames;
|
|
|
11
11
|
(function (BasicCredentialsPromptNames) {
|
|
12
12
|
BasicCredentialsPromptNames["systemUsername"] = "systemUsername";
|
|
13
13
|
BasicCredentialsPromptNames["systemPassword"] = "systemPassword";
|
|
14
|
+
BasicCredentialsPromptNames["storeSystemCredentials"] = "storeSystemCredentials";
|
|
14
15
|
})(BasicCredentialsPromptNames || (exports.BasicCredentialsPromptNames = BasicCredentialsPromptNames = {}));
|
|
15
16
|
/**
|
|
16
17
|
* Re-usable credentials prompts for connection to systems using basic auth.
|
|
@@ -25,9 +26,10 @@ var BasicCredentialsPromptNames;
|
|
|
25
26
|
function getCredentialsPrompts(connectionValidator, promptNamespace, sapClient) {
|
|
26
27
|
const usernamePromptName = `${promptNamespace ? promptNamespace + ':' : ''}${BasicCredentialsPromptNames.systemUsername}`;
|
|
27
28
|
const passwordPromptName = `${promptNamespace ? promptNamespace + ':' : ''}${BasicCredentialsPromptNames.systemPassword}`;
|
|
29
|
+
const storeCredentialsPromptName = `${promptNamespace ? promptNamespace + ':' : ''}${BasicCredentialsPromptNames.storeSystemCredentials}`;
|
|
28
30
|
// Optimization to prevent re-checking of auth
|
|
29
31
|
let authRequired;
|
|
30
|
-
|
|
32
|
+
const credentialsPrompts = [
|
|
31
33
|
{
|
|
32
34
|
when: async () => {
|
|
33
35
|
authRequired = await connectionValidator.isAuthRequired();
|
|
@@ -83,7 +85,7 @@ function getCredentialsPrompts(connectionValidator, promptNamespace, sapClient)
|
|
|
83
85
|
updatePromptStateWithConnectedSystem(connectionValidator.serviceProvider, selectedSystem, {
|
|
84
86
|
username: answers?.[usernamePromptName],
|
|
85
87
|
password: password
|
|
86
|
-
});
|
|
88
|
+
}); // Store credentials temporarily - will be conditionally kept/removed in store credentials prompt
|
|
87
89
|
return true;
|
|
88
90
|
}
|
|
89
91
|
return valResult;
|
|
@@ -100,9 +102,42 @@ function getCredentialsPrompts(connectionValidator, promptNamespace, sapClient)
|
|
|
100
102
|
severity: yeoman_ui_types_1.Severity.warning
|
|
101
103
|
};
|
|
102
104
|
}
|
|
105
|
+
// Lower priority than the cert error warning - we can only show one at a time, hence this should always be last
|
|
106
|
+
if (utils_1.PromptState.odataService.connectedSystem?.backendSystem) {
|
|
107
|
+
return {
|
|
108
|
+
message: (0, i18n_1.t)('texts.passwordStoreWarning'),
|
|
109
|
+
severity: yeoman_ui_types_1.Severity.warning
|
|
110
|
+
};
|
|
111
|
+
}
|
|
103
112
|
}
|
|
104
113
|
}
|
|
105
114
|
];
|
|
115
|
+
const confirmCredentialStoragePrompt = {
|
|
116
|
+
when: (answers) => !!(connectionValidator.systemAuthType === 'basic' &&
|
|
117
|
+
authRequired &&
|
|
118
|
+
connectionValidator.validity.authenticated &&
|
|
119
|
+
answers[passwordPromptName]),
|
|
120
|
+
type: 'confirm',
|
|
121
|
+
name: storeCredentialsPromptName,
|
|
122
|
+
message: (0, i18n_1.t)('prompts.storeSystemCredentials.message'),
|
|
123
|
+
default: false,
|
|
124
|
+
guiOptions: {
|
|
125
|
+
breadcrumb: (0, i18n_1.t)('prompts.storeSystemCredentials.breadcrumb')
|
|
126
|
+
},
|
|
127
|
+
validate: async (storeCredentials) => {
|
|
128
|
+
if (utils_1.PromptState.odataService.connectedSystem?.backendSystem) {
|
|
129
|
+
const backendSystem = utils_1.PromptState.odataService.connectedSystem.backendSystem;
|
|
130
|
+
utils_1.PromptState.odataService.connectedSystem.backendSystem = Object.assign(backendSystem, {
|
|
131
|
+
newOrUpdated: storeCredentials
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
if (!(0, btp_utils_1.isAppStudio)()) {
|
|
138
|
+
credentialsPrompts.push(confirmCredentialStoragePrompt);
|
|
139
|
+
}
|
|
140
|
+
return credentialsPrompts;
|
|
106
141
|
}
|
|
107
142
|
/**
|
|
108
143
|
* Updates the prompt state with the connected system.
|
|
@@ -120,13 +155,12 @@ function updatePromptStateWithConnectedSystem(serviceProvider, selectedSystem, {
|
|
|
120
155
|
// Update the existing backend system with the new credentials that may be used to update in the store.
|
|
121
156
|
if (selectedSystem?.type === 'backendSystem') {
|
|
122
157
|
const backendSystem = selectedSystem.system;
|
|
123
|
-
// Have the credentials changed
|
|
158
|
+
// Have the credentials changed..?
|
|
124
159
|
if (backendSystem.username !== username || backendSystem.password !== password) {
|
|
125
160
|
utils_1.PromptState.odataService.connectedSystem.backendSystem = Object.assign(backendSystem, {
|
|
126
161
|
username: username,
|
|
127
|
-
password,
|
|
128
|
-
userDisplayName: username
|
|
129
|
-
newOrUpdated: true
|
|
162
|
+
password: password,
|
|
163
|
+
userDisplayName: username
|
|
130
164
|
});
|
|
131
165
|
}
|
|
132
166
|
// If the connection is successful and a destination was selected, assign the connected destination to the prompt state.
|
|
@@ -7,6 +7,8 @@ import type { Answers } from 'inquirer';
|
|
|
7
7
|
import type { ConnectedSystem } from '../../../../types';
|
|
8
8
|
import type { ConnectionValidator } from '../../../connectionValidator';
|
|
9
9
|
import { type NewSystemAnswers } from '../new-system/types';
|
|
10
|
+
import type { SystemSelectionAnswers } from '../system-selection/questions';
|
|
11
|
+
import type { AbapOnPremAnswers } from '../abap-on-prem/questions';
|
|
10
12
|
/**
|
|
11
13
|
* Get the system url prompt. The system url prompt is used to connect to a new system using the user input system url.
|
|
12
14
|
*
|
|
@@ -27,5 +29,5 @@ export declare function getSystemUrlQuestion<T extends Answers>(connectValidator
|
|
|
27
29
|
* This prevents conflicts with other prompts of the same types where the same prompt is used by multiple other prompts but cannot share the name.
|
|
28
30
|
* @returns the new system name prompt
|
|
29
31
|
*/
|
|
30
|
-
export declare function getUserSystemNameQuestion(connectValidator: ConnectionValidator, promptNamespace?: string): InputQuestion<Partial<NewSystemAnswers>>;
|
|
32
|
+
export declare function getUserSystemNameQuestion(connectValidator: ConnectionValidator, promptNamespace?: string): InputQuestion<Partial<NewSystemAnswers & AbapOnPremAnswers & SystemSelectionAnswers>>;
|
|
31
33
|
//# sourceMappingURL=shared-prompts.d.ts.map
|
|
@@ -10,6 +10,7 @@ const types_2 = require("../new-system/types");
|
|
|
10
10
|
const prompt_helpers_1 = require("../prompt-helpers");
|
|
11
11
|
const validators_1 = require("../validators");
|
|
12
12
|
const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
|
|
13
|
+
const questions_1 = require("../credentials/questions");
|
|
13
14
|
/**
|
|
14
15
|
* Convert the system connection scheme (Service Key, Rentrance Ticket, etc) to the store specific authentication type.
|
|
15
16
|
* Note the absence of CF Discovery, in this case the service key file (UAA) is also used for the Abap connectivity.
|
|
@@ -129,7 +130,7 @@ function getUserSystemNameQuestion(connectValidator, promptNamespace) {
|
|
|
129
130
|
}
|
|
130
131
|
return defaultSystemName;
|
|
131
132
|
},
|
|
132
|
-
validate: async (systemName) => {
|
|
133
|
+
validate: async (systemName, previousAnswers) => {
|
|
133
134
|
if (!systemName) {
|
|
134
135
|
return false;
|
|
135
136
|
}
|
|
@@ -143,6 +144,7 @@ function getUserSystemNameQuestion(connectValidator, promptNamespace) {
|
|
|
143
144
|
defaultSystemName = systemName;
|
|
144
145
|
isValid = await (0, validators_1.validateSystemName)(systemName);
|
|
145
146
|
}
|
|
147
|
+
const shouldStoreCreds = !!previousAnswers?.[`${promptNamespacePart}${questions_1.BasicCredentialsPromptNames.storeSystemCredentials}`];
|
|
146
148
|
if (isValid === true) {
|
|
147
149
|
// Update or create the BackendSystem with the new system details for persistent storage
|
|
148
150
|
if (connectValidator.validatedUrl && utils_1.PromptState.odataService.connectedSystem) {
|
|
@@ -151,8 +153,8 @@ function getUserSystemNameQuestion(connectValidator, promptNamespace) {
|
|
|
151
153
|
name: systemName,
|
|
152
154
|
url: connectValidator.validatedUrl,
|
|
153
155
|
client: connectValidator.validatedClient,
|
|
154
|
-
username: connectValidator.axiosConfig?.auth?.username,
|
|
155
|
-
password: connectValidator.axiosConfig?.auth?.password,
|
|
156
|
+
username: shouldStoreCreds ? connectValidator.axiosConfig?.auth?.username : undefined,
|
|
157
|
+
password: shouldStoreCreds ? connectValidator.axiosConfig?.auth?.password : undefined,
|
|
156
158
|
serviceKeys: connectValidator.serviceInfo, // This will not be persisted and is only used to determine cached connection equality for CF provided uaa keys
|
|
157
159
|
userDisplayName: connectValidator.connectedUserName,
|
|
158
160
|
systemType: (0, store_1.getBackendSystemType)({
|
|
@@ -125,7 +125,6 @@ async function getSystemConnectionQuestions(connectionValidator, promptOptions,
|
|
|
125
125
|
return (validateSystemSelection(selectedSystemAnswer, connectionValidator, requiredOdataVersion, cachedConnectedSystem) ?? false);
|
|
126
126
|
},
|
|
127
127
|
additionalMessages: async (selectedSystem) => {
|
|
128
|
-
// Backend systems credentials may need to be updated
|
|
129
128
|
if (selectedSystem.type === 'backendSystem' &&
|
|
130
129
|
connectionValidator.systemAuthType === 'basic' &&
|
|
131
130
|
(await connectionValidator.isAuthRequired())) {
|
|
@@ -84,6 +84,10 @@
|
|
|
84
84
|
"systemPassword": {
|
|
85
85
|
"message": "Password"
|
|
86
86
|
},
|
|
87
|
+
"storeSystemCredentials": {
|
|
88
|
+
"message": "Do you want to store the system credentials?",
|
|
89
|
+
"breadcrumb": "Store Credentials"
|
|
90
|
+
},
|
|
87
91
|
"systemService": {
|
|
88
92
|
"message": "Service",
|
|
89
93
|
"breadcrumb": "Service",
|
|
@@ -257,6 +261,7 @@
|
|
|
257
261
|
"forUserName": "(for user [{{username}}])",
|
|
258
262
|
"httpStatus": "HTTP Status {{httpStatus}}",
|
|
259
263
|
"checkDestinationAuthConfig": "Please check the SAP BTP destination authentication configuration.",
|
|
260
|
-
"choiceNameNone": "None"
|
|
264
|
+
"choiceNameNone": "None",
|
|
265
|
+
"passwordStoreWarning": "Passwords are stored in your operating system's credential manager and are protected by its security policies."
|
|
261
266
|
}
|
|
262
267
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/odata-service-inquirer",
|
|
3
3
|
"description": "Prompts module that can prompt users for inputs required for odata service writing",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.11.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|