abap-local-client 1.4.1 → 1.4.2
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/config-cli.mjs +24 -0
- package/package.json +1 -1
- package/sso-sap-client.mjs +7 -2
package/config-cli.mjs
CHANGED
|
@@ -87,6 +87,10 @@ Usage:
|
|
|
87
87
|
node config-cli.mjs show-config
|
|
88
88
|
Show the full configuration (API key and passwords REDACTED).
|
|
89
89
|
|
|
90
|
+
node config-cli.mjs set-username <systemId> <sapUser>
|
|
91
|
+
Set the SAP username for a system (required for SNC connections).
|
|
92
|
+
Example: node config-cli.mjs set-username S4D FGALASTRI
|
|
93
|
+
|
|
90
94
|
node config-cli.mjs arcanum-fallback <on|off>
|
|
91
95
|
Enable or disable Arcanum fallback for unknown system IDs.
|
|
92
96
|
|
|
@@ -304,6 +308,26 @@ switch (command) {
|
|
|
304
308
|
break;
|
|
305
309
|
}
|
|
306
310
|
|
|
311
|
+
// ── set-username ────────────────────────────────────────────────────────
|
|
312
|
+
case 'set-username': {
|
|
313
|
+
const systemId = args[1];
|
|
314
|
+
const username = args[2];
|
|
315
|
+
if (!systemId || !username) {
|
|
316
|
+
console.error('Usage: node config-cli.mjs set-username <systemId> <sapUser>');
|
|
317
|
+
console.error(' Example: node config-cli.mjs set-username S4D FGALASTRI');
|
|
318
|
+
process.exit(1);
|
|
319
|
+
}
|
|
320
|
+
const sys = config.getSystem(systemId);
|
|
321
|
+
if (!sys) {
|
|
322
|
+
console.error(`System "${systemId}" not found. Run list-systems to see configured systems.`);
|
|
323
|
+
process.exit(1);
|
|
324
|
+
}
|
|
325
|
+
sys.connection = { ...(sys.connection || {}), username: username.toUpperCase() };
|
|
326
|
+
config.addOrUpdateSystem(systemId, sys);
|
|
327
|
+
console.log(`✅ Username for "${systemId}" set to: ${username.toUpperCase()}`);
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
|
|
307
331
|
// ── set-ws-url ──────────────────────────────────────────────────────────
|
|
308
332
|
case 'set-ws-url': {
|
|
309
333
|
const url = args[1];
|
package/package.json
CHANGED
package/sso-sap-client.mjs
CHANGED
|
@@ -16,6 +16,11 @@ import * as config from './config-manager.mjs';
|
|
|
16
16
|
try { process.loadEnvFile?.(); } catch {}
|
|
17
17
|
const env = process.env;
|
|
18
18
|
|
|
19
|
+
/** Resolve the SAP username from connection config. For SNC, set conn.username explicitly. */
|
|
20
|
+
function resolveUsername(conn) {
|
|
21
|
+
return (conn.username || '').toUpperCase();
|
|
22
|
+
}
|
|
23
|
+
|
|
19
24
|
// ════════════════════════════════════════════════════════════════════════════
|
|
20
25
|
// Multi-system auth session cache
|
|
21
26
|
// ════════════════════════════════════════════════════════════════════════════
|
|
@@ -403,7 +408,7 @@ class SAPClient {
|
|
|
403
408
|
if (typeof body === 'string') {
|
|
404
409
|
const lang = conn.language || 'EN';
|
|
405
410
|
const client = conn.client || '100';
|
|
406
|
-
const user = (conn
|
|
411
|
+
const user = resolveUsername(conn);
|
|
407
412
|
body = body
|
|
408
413
|
.replace(/<SAP_LANGUAGE>/g, lang)
|
|
409
414
|
.replace(/<SAP_CLIENT>/g, client)
|
|
@@ -475,7 +480,7 @@ class SAPClient {
|
|
|
475
480
|
if (typeof rawBody === 'string') {
|
|
476
481
|
const conn2 = this.session?.sysConfig?.connection || {};
|
|
477
482
|
const lang2 = conn2.language || 'EN';
|
|
478
|
-
const user2 = (conn2
|
|
483
|
+
const user2 = resolveUsername(conn2);
|
|
479
484
|
rawBody = rawBody
|
|
480
485
|
.replace(/<SAP_LANGUAGE>/g, lang2)
|
|
481
486
|
.replace(/<SAP_CLIENT>/g, conn2.client || '100')
|