@onlyflows/servicenow-mcp 2.3.0-dev.3 → 2.3.0-dev.5
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 +165 -0
- package/README.md +177 -29
- package/dist/atf-policy.d.ts +1 -1
- package/dist/atf-policy.d.ts.map +1 -1
- package/dist/atf-policy.js +2 -0
- package/dist/atf-policy.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/credential-tables.d.ts +32 -0
- package/dist/credential-tables.d.ts.map +1 -0
- package/dist/credential-tables.js +58 -0
- package/dist/credential-tables.js.map +1 -0
- package/dist/encoded-query-policy.d.ts.map +1 -1
- package/dist/encoded-query-policy.js +8 -1
- package/dist/encoded-query-policy.js.map +1 -1
- package/dist/execution-context.d.ts +14 -0
- package/dist/execution-context.d.ts.map +1 -1
- package/dist/execution-context.js +8 -0
- package/dist/execution-context.js.map +1 -1
- package/dist/field-policy.d.ts +34 -1
- package/dist/field-policy.d.ts.map +1 -1
- package/dist/field-policy.js +308 -25
- package/dist/field-policy.js.map +1 -1
- package/dist/hidden-values.d.ts +225 -0
- package/dist/hidden-values.d.ts.map +1 -0
- package/dist/hidden-values.js +748 -0
- package/dist/hidden-values.js.map +1 -0
- package/dist/http-entrypoint.d.ts.map +1 -1
- package/dist/http-entrypoint.js +7 -0
- package/dist/http-entrypoint.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/metadata-cache.d.ts +38 -0
- package/dist/metadata-cache.d.ts.map +1 -1
- package/dist/metadata-cache.js +76 -3
- package/dist/metadata-cache.js.map +1 -1
- package/dist/policy-card.d.ts +16 -1
- package/dist/policy-card.d.ts.map +1 -1
- package/dist/policy-card.js +13 -2
- package/dist/policy-card.js.map +1 -1
- package/dist/profile-admin.d.ts +18 -0
- package/dist/profile-admin.d.ts.map +1 -1
- package/dist/profile-admin.js +26 -1
- package/dist/profile-admin.js.map +1 -1
- package/dist/profile-manager.d.ts +13 -1
- package/dist/profile-manager.d.ts.map +1 -1
- package/dist/profile-manager.js +23 -1
- package/dist/profile-manager.js.map +1 -1
- package/dist/setup.d.ts +4 -0
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +150 -66
- package/dist/setup.js.map +1 -1
- package/dist/structured-query.d.ts.map +1 -1
- package/dist/structured-query.js +6 -1
- package/dist/structured-query.js.map +1 -1
- package/dist/table-policy.d.ts +34 -1
- package/dist/table-policy.d.ts.map +1 -1
- package/dist/table-policy.js +95 -10
- package/dist/table-policy.js.map +1 -1
- package/dist/tool-error.d.ts +8 -1
- package/dist/tool-error.d.ts.map +1 -1
- package/dist/tool-error.js +23 -0
- package/dist/tool-error.js.map +1 -1
- package/dist/tool-table-access.d.ts.map +1 -1
- package/dist/tool-table-access.js +25 -6
- package/dist/tool-table-access.js.map +1 -1
- package/dist/tools/aggregate.js +2 -2
- package/dist/tools/aggregate.js.map +1 -1
- package/dist/tools/all-fields-cap.d.ts.map +1 -1
- package/dist/tools/all-fields-cap.js +29 -7
- package/dist/tools/all-fields-cap.js.map +1 -1
- package/dist/tools/atf-author-module.d.ts +1 -7
- package/dist/tools/atf-author-module.d.ts.map +1 -1
- package/dist/tools/atf-author-module.js +16 -7
- package/dist/tools/atf-author-module.js.map +1 -1
- package/dist/tools/atf-contracts.d.ts +69 -4
- package/dist/tools/atf-contracts.d.ts.map +1 -1
- package/dist/tools/atf-contracts.js +32 -2
- package/dist/tools/atf-contracts.js.map +1 -1
- package/dist/tools/atf-renderers.js +2 -1
- package/dist/tools/atf-renderers.js.map +1 -1
- package/dist/tools/atf-results-module.d.ts.map +1 -1
- package/dist/tools/atf-results-module.js +5 -3
- package/dist/tools/atf-results-module.js.map +1 -1
- package/dist/tools/atf-run-module.js +3 -2
- package/dist/tools/atf-run-module.js.map +1 -1
- package/dist/tools/atf-shared.d.ts +6 -0
- package/dist/tools/atf-shared.d.ts.map +1 -1
- package/dist/tools/atf-shared.js +49 -10
- package/dist/tools/atf-shared.js.map +1 -1
- package/dist/tools/atf-step-catalog.d.ts +13 -8
- package/dist/tools/atf-step-catalog.d.ts.map +1 -1
- package/dist/tools/atf-step-catalog.js +169 -5
- package/dist/tools/atf-step-catalog.js.map +1 -1
- package/dist/tools/batch.d.ts.map +1 -1
- package/dist/tools/batch.js +4 -2
- package/dist/tools/batch.js.map +1 -1
- package/dist/tools/flow-view-contracts.d.ts +57 -1
- package/dist/tools/flow-view-contracts.d.ts.map +1 -1
- package/dist/tools/flow-view-contracts.js +34 -2
- package/dist/tools/flow-view-contracts.js.map +1 -1
- package/dist/tools/flow-view-graph.d.ts +14 -0
- package/dist/tools/flow-view-graph.d.ts.map +1 -1
- package/dist/tools/flow-view-graph.js +43 -1
- package/dist/tools/flow-view-graph.js.map +1 -1
- package/dist/tools/flow-view-module.js +1 -1
- package/dist/tools/flow-view-module.js.map +1 -1
- package/dist/tools/flow-view-policy.d.ts +3 -3
- package/dist/tools/flow-view-policy.d.ts.map +1 -1
- package/dist/tools/flow-view-policy.js +5 -4
- package/dist/tools/flow-view-policy.js.map +1 -1
- package/dist/tools/flow-view-renderers.d.ts.map +1 -1
- package/dist/tools/flow-view-renderers.js +9 -21
- package/dist/tools/flow-view-renderers.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +80 -13
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/platform-view-contracts.d.ts +189 -0
- package/dist/tools/platform-view-contracts.d.ts.map +1 -0
- package/dist/tools/platform-view-contracts.js +353 -0
- package/dist/tools/platform-view-contracts.js.map +1 -0
- package/dist/tools/platform-view-evaluate.d.ts +11 -0
- package/dist/tools/platform-view-evaluate.d.ts.map +1 -0
- package/dist/tools/platform-view-evaluate.js +19 -0
- package/dist/tools/platform-view-evaluate.js.map +1 -0
- package/dist/tools/platform-view-module.d.ts +28 -0
- package/dist/tools/platform-view-module.d.ts.map +1 -0
- package/dist/tools/platform-view-module.js +111 -0
- package/dist/tools/platform-view-module.js.map +1 -0
- package/dist/tools/platform-view-scan.d.ts +57 -0
- package/dist/tools/platform-view-scan.d.ts.map +1 -0
- package/dist/tools/platform-view-scan.js +375 -0
- package/dist/tools/platform-view-scan.js.map +1 -0
- package/dist/tools/platform-view-upgrades.d.ts +152 -0
- package/dist/tools/platform-view-upgrades.d.ts.map +1 -0
- package/dist/tools/platform-view-upgrades.js +545 -0
- package/dist/tools/platform-view-upgrades.js.map +1 -0
- package/dist/tools/profile.d.ts.map +1 -1
- package/dist/tools/profile.js +1 -0
- package/dist/tools/profile.js.map +1 -1
- package/dist/tools/query-module.js +1 -1
- package/dist/tools/query-module.js.map +1 -1
- package/dist/tools/record-write-shared.d.ts.map +1 -1
- package/dist/tools/record-write-shared.js +4 -3
- package/dist/tools/record-write-shared.js.map +1 -1
- package/dist/tools/result-envelope.d.ts +116 -36
- package/dist/tools/result-envelope.d.ts.map +1 -1
- package/dist/tools/result-envelope.js +38 -3
- package/dist/tools/result-envelope.js.map +1 -1
- package/dist/tools/syslog-cursor.d.ts +61 -0
- package/dist/tools/syslog-cursor.d.ts.map +1 -0
- package/dist/tools/syslog-cursor.js +146 -0
- package/dist/tools/syslog-cursor.js.map +1 -0
- package/dist/tools/syslog.d.ts +2 -0
- package/dist/tools/syslog.d.ts.map +1 -1
- package/dist/tools/syslog.js +126 -2
- package/dist/tools/syslog.js.map +1 -1
- package/dist/update-set-eval/secret-patterns.d.ts +75 -0
- package/dist/update-set-eval/secret-patterns.d.ts.map +1 -0
- package/dist/update-set-eval/secret-patterns.js +570 -0
- package/dist/update-set-eval/secret-patterns.js.map +1 -0
- package/dist/update-set-eval/xml-reader.d.ts +117 -0
- package/dist/update-set-eval/xml-reader.d.ts.map +1 -0
- package/dist/update-set-eval/xml-reader.js +561 -0
- package/dist/update-set-eval/xml-reader.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/CLIENT-SETUP.md +8 -6
- package/docs/FLOW-VIEW.md +14 -5
- package/docs/PRODUCTION-SECURITY.md +63 -0
- package/docs/PROFILE-CREDENTIALS.md +10 -4
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/setup.js
CHANGED
|
@@ -41,6 +41,7 @@ const profile_admin_js_1 = require("./profile-admin.js");
|
|
|
41
41
|
const profile_credentials_js_1 = require("./profile-credentials.js");
|
|
42
42
|
const profile_manager_js_1 = require("./profile-manager.js");
|
|
43
43
|
const policy_card_js_1 = require("./policy-card.js");
|
|
44
|
+
const hidden_values_js_1 = require("./hidden-values.js");
|
|
44
45
|
const risky_grants_js_1 = require("./risky-grants.js");
|
|
45
46
|
const tool_error_js_1 = require("./tool-error.js");
|
|
46
47
|
const table_policy_js_1 = require("./table-policy.js");
|
|
@@ -238,66 +239,16 @@ async function runWizard(options, home, env, dependencies, out) {
|
|
|
238
239
|
}
|
|
239
240
|
const name = await askProfileName(prompter, existing);
|
|
240
241
|
const instance = await askInstance(prompter);
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
// question adjacent to a credential prompt echoes the credential, so the
|
|
250
|
-
// last thing before the hidden prompts is deliberately not this question.
|
|
251
|
-
const mode = (await prompter.ask("How should the credential be stored?", {
|
|
252
|
-
default: "encrypted",
|
|
253
|
-
choices: ["encrypted", "reference"],
|
|
254
|
-
}));
|
|
255
|
-
const provider = mode === "reference"
|
|
256
|
-
? await prompter.ask("Secret provider", { default: "env", choices: ["env"] })
|
|
257
|
-
: undefined;
|
|
258
|
-
const profile = { instance, authType };
|
|
259
|
-
if (authType === "basic" || grantType === "password") {
|
|
260
|
-
profile.username = await prompter.ask("ServiceNow username", {
|
|
261
|
-
validate: (value) => value.trim() === "" ? "A username is required for this auth mode." : undefined,
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
if (authType === "oauth") {
|
|
265
|
-
profile.grantType = grantType;
|
|
266
|
-
profile.clientId = await prompter.ask("OAuth client id (not a secret)", {
|
|
267
|
-
validate: (value) => value.trim() === "" ? "A client id is required for OAuth." : undefined,
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
if (authType === "apikey") {
|
|
271
|
-
profile.apiKeyHeader = await prompter.ask("API key header", {
|
|
272
|
-
default: "x-sn-apikey",
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
const fields = (0, profile_admin_js_1.requiredSecretFields)(authType, grantType);
|
|
276
|
-
(0, profile_admin_js_1.validateCreateMetadata)(profile, fields);
|
|
277
|
-
// 3. Capture the secrets. Never echoed, never in argv, never logged.
|
|
278
|
-
prompter.note(mode === "reference"
|
|
279
|
-
? "\nEnter the NAME of the environment variable holding each secret.\n" +
|
|
280
|
-
"Input is hidden."
|
|
281
|
-
: "\nEnter each secret now. Input is hidden — nothing you type from here\n" +
|
|
282
|
-
"is displayed.");
|
|
283
|
-
const captured = [];
|
|
284
|
-
for (const field of fields) {
|
|
285
|
-
captured.push(Object.freeze({ field, mode, value: await prompter.secret(field) }));
|
|
286
|
-
}
|
|
287
|
-
// 4. Verify against the live instance before anything is persisted.
|
|
288
|
-
const config = wizardConfig(profile, captured, mode, env);
|
|
289
|
-
const verify = dependencies.verifyCredential ?? verifyCredentialAgainstInstance;
|
|
290
|
-
prompter.note("\nVerifying against the instance...");
|
|
291
|
-
let verification = await verify(config);
|
|
292
|
-
while (!verification.ok) {
|
|
293
|
-
prompter.note(`\n FAILED ${verification.detail}`);
|
|
294
|
-
if (verification.remedy)
|
|
295
|
-
prompter.note(` -> ${verification.remedy}`);
|
|
296
|
-
if (!(await prompter.confirm("\nRetry with the same settings?", true))) {
|
|
297
|
-
throw new WizardAbort();
|
|
298
|
-
}
|
|
299
|
-
verification = await verify(config);
|
|
242
|
+
// 3-4. Authentication, the credential, and its verification. Collected in
|
|
243
|
+
// one place so a Basic 401 can send the operator back to OAuth
|
|
244
|
+
// without re-asking the profile name or the instance.
|
|
245
|
+
let forcedAuthType;
|
|
246
|
+
let collected;
|
|
247
|
+
while (collected === undefined) {
|
|
248
|
+
collected = await collectVerifiedCredential(prompter, instance, env, dependencies, forcedAuthType);
|
|
249
|
+
forcedAuthType = "oauth";
|
|
300
250
|
}
|
|
251
|
+
const { profile, captured, mode, provider, config, verification } = collected;
|
|
301
252
|
prompter.note(` ok ${verification.detail}`);
|
|
302
253
|
if (verification.authenticatedButDenied) {
|
|
303
254
|
prompter.note(` note this account cannot read ${WIZARD_PROBE_TABLE}, so metadata\n` +
|
|
@@ -347,6 +298,99 @@ async function runWizard(options, home, env, dependencies, out) {
|
|
|
347
298
|
prompter.close();
|
|
348
299
|
}
|
|
349
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Ask for the authentication type and its credential, then verify it against
|
|
303
|
+
* the instance. Returns `undefined` when the operator, after a 401 on a Basic
|
|
304
|
+
* credential, chose to switch to OAuth: the caller asks again with OAuth
|
|
305
|
+
* forced. Nothing is persisted here, and a discarded Basic credential is not
|
|
306
|
+
* kept anywhere.
|
|
307
|
+
*/
|
|
308
|
+
async function collectVerifiedCredential(prompter, instance, env, dependencies, forcedAuthType) {
|
|
309
|
+
const authType = forcedAuthType ?? (await askAuthType(prompter));
|
|
310
|
+
if (authType === "oauth")
|
|
311
|
+
prompter.note(OAUTH_REQUIREMENTS_NOTE);
|
|
312
|
+
const grantType = authType === "oauth"
|
|
313
|
+
? (await prompter.ask("OAuth grant type", {
|
|
314
|
+
default: "client_credentials",
|
|
315
|
+
choices: ["client_credentials", "password"],
|
|
316
|
+
}))
|
|
317
|
+
: "client_credentials";
|
|
318
|
+
// Asked here, before any secret is in hand. A mistyped answer to a
|
|
319
|
+
// question adjacent to a credential prompt echoes the credential, so the
|
|
320
|
+
// last thing before the hidden prompts is deliberately not this question.
|
|
321
|
+
const mode = (await prompter.ask("How should the credential be stored?", {
|
|
322
|
+
default: "encrypted",
|
|
323
|
+
choices: ["encrypted", "reference"],
|
|
324
|
+
}));
|
|
325
|
+
const provider = mode === "reference"
|
|
326
|
+
? await prompter.ask("Secret provider", { default: "env", choices: ["env"] })
|
|
327
|
+
: undefined;
|
|
328
|
+
const profile = { instance, authType };
|
|
329
|
+
if (authType === "basic" || grantType === "password") {
|
|
330
|
+
profile.username = await prompter.ask("ServiceNow username", {
|
|
331
|
+
validate: (value) => value.trim() === "" ? "A username is required for this auth mode." : undefined,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
if (authType === "oauth") {
|
|
335
|
+
profile.grantType = grantType;
|
|
336
|
+
profile.clientId = await prompter.ask("OAuth client id (not a secret)", {
|
|
337
|
+
validate: (value) => value.trim() === "" ? "A client id is required for OAuth." : undefined,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
if (authType === "apikey") {
|
|
341
|
+
profile.apiKeyHeader = await prompter.ask("API key header", {
|
|
342
|
+
default: "x-sn-apikey",
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
const fields = (0, profile_admin_js_1.requiredSecretFields)(authType, grantType);
|
|
346
|
+
(0, profile_admin_js_1.validateCreateMetadata)(profile, fields);
|
|
347
|
+
// Capture the secrets. Never echoed, never in argv, never logged.
|
|
348
|
+
prompter.note(mode === "reference"
|
|
349
|
+
? "\nEnter the NAME of the environment variable holding each secret.\n" +
|
|
350
|
+
"Input is hidden."
|
|
351
|
+
: "\nEnter each secret now. Input is hidden — nothing you type from here\n" +
|
|
352
|
+
"is displayed.");
|
|
353
|
+
const captured = [];
|
|
354
|
+
for (const field of fields) {
|
|
355
|
+
captured.push(Object.freeze({ field, mode, value: await prompter.secret(field) }));
|
|
356
|
+
}
|
|
357
|
+
// Verify against the live instance before anything is persisted.
|
|
358
|
+
const config = wizardConfig(profile, captured, mode, env);
|
|
359
|
+
const verify = dependencies.verifyCredential ?? verifyCredentialAgainstInstance;
|
|
360
|
+
prompter.note("\nVerifying against the instance...");
|
|
361
|
+
let verification = await verify(config);
|
|
362
|
+
while (!verification.ok) {
|
|
363
|
+
prompter.note(`\n FAILED ${verification.detail}`);
|
|
364
|
+
const offersSwitch = authType === "basic" && verification.authenticationRejected === true;
|
|
365
|
+
if (verification.remedy) {
|
|
366
|
+
prompter.note(` -> ${verification.remedy}${offersSwitch ? BASIC_AUTH_SWITCH_IN_WIZARD : ""}`);
|
|
367
|
+
}
|
|
368
|
+
if (offersSwitch) {
|
|
369
|
+
// A 401 on Basic often means the instance no longer accepts Basic for
|
|
370
|
+
// REST, which retrying cannot fix. Offer the way out next to the retry.
|
|
371
|
+
const next = await prompter.ask("\nWhat next?", {
|
|
372
|
+
default: "retry",
|
|
373
|
+
choices: ["retry", "oauth", "stop"],
|
|
374
|
+
hints: {
|
|
375
|
+
retry: "try the same settings again",
|
|
376
|
+
oauth: "discard this credential and set up OAuth client credentials",
|
|
377
|
+
stop: "cancel; nothing is saved",
|
|
378
|
+
},
|
|
379
|
+
});
|
|
380
|
+
if (next === "stop")
|
|
381
|
+
throw new WizardAbort();
|
|
382
|
+
if (next === "oauth") {
|
|
383
|
+
prompter.note("\nSwitching to OAuth. The Basic credential is discarded.");
|
|
384
|
+
return undefined;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
else if (!(await prompter.confirm("\nRetry with the same settings?", true))) {
|
|
388
|
+
throw new WizardAbort();
|
|
389
|
+
}
|
|
390
|
+
verification = await verify(config);
|
|
391
|
+
}
|
|
392
|
+
return { profile, captured, mode, provider, config, verification };
|
|
393
|
+
}
|
|
350
394
|
/**
|
|
351
395
|
* The checks that decide whether this install actually works.
|
|
352
396
|
*
|
|
@@ -433,10 +477,30 @@ function instanceProblem(value) {
|
|
|
433
477
|
"*.servicenowservices.com. For a self-hosted or custom-domain instance, set " +
|
|
434
478
|
"SN_ALLOWED_INSTANCE_HOSTS before running setup.");
|
|
435
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* OAuth client credentials is the default and listed first. Basic stays
|
|
482
|
+
* available for an instance that still accepts it, and is listed last and
|
|
483
|
+
* marked legacy: ServiceNow is retiring it for REST calls (KB3096078).
|
|
484
|
+
*/
|
|
485
|
+
const AUTH_TYPE_CHOICES = Object.freeze(["oauth", "apikey", "basic"]);
|
|
486
|
+
const AUTH_TYPE_HINTS = Object.freeze({
|
|
487
|
+
oauth: "client credentials, recommended",
|
|
488
|
+
apikey: "inbound API key",
|
|
489
|
+
basic: "legacy, not recommended: ServiceNow is retiring it",
|
|
490
|
+
});
|
|
491
|
+
/** What OAuth client credentials need on the instance. Fixed text, no secret. */
|
|
492
|
+
const OAUTH_REQUIREMENTS_NOTE = "\nOAuth client credentials need these on the instance:\n" +
|
|
493
|
+
" - an Application Registry entry (System OAuth > Application Registry)\n" +
|
|
494
|
+
" with a client ID and client secret\n" +
|
|
495
|
+
" - the client credentials grant enabled for it\n" +
|
|
496
|
+
" - an OAuth Application User: the integration user this server acts as,\n" +
|
|
497
|
+
" with only the roles it needs, not an administrator\n" +
|
|
498
|
+
"Steps: README, section Authentication > OAuth 2.0.\n";
|
|
436
499
|
async function askAuthType(prompter) {
|
|
437
500
|
return (await prompter.ask("Authentication", {
|
|
438
|
-
default: "
|
|
439
|
-
choices:
|
|
501
|
+
default: "oauth",
|
|
502
|
+
choices: AUTH_TYPE_CHOICES,
|
|
503
|
+
hints: AUTH_TYPE_HINTS,
|
|
440
504
|
}));
|
|
441
505
|
}
|
|
442
506
|
/** Build a throwaway config for verification. Never persisted. */
|
|
@@ -502,8 +566,20 @@ const BASIC_AUTH_401_REMEDY = "Check the username and password. A ServiceNow acc
|
|
|
502
566
|
"instance may be rejecting Basic Auth for REST API calls (KB3096078): " +
|
|
503
567
|
"current instances require the role snc_basic_auth_api_access for REST " +
|
|
504
568
|
"Basic auth, or a Web-Service-Access-Only account. ServiceNow is retiring " +
|
|
505
|
-
"Basic auth, so OAuth client credentials are recommended
|
|
506
|
-
|
|
569
|
+
"Basic auth, so OAuth client credentials are recommended.";
|
|
570
|
+
/**
|
|
571
|
+
* How to act on the OAuth recommendation, which depends on where the advice is
|
|
572
|
+
* read. The wizard has a menu right below it; `doctor` has none, so it names
|
|
573
|
+
* the command instead. Kept out of the shared remedy so neither points at a
|
|
574
|
+
* choice that is not on the screen.
|
|
575
|
+
*/
|
|
576
|
+
const BASIC_AUTH_SWITCH_IN_WIZARD = " Choose oauth below to switch this profile.";
|
|
577
|
+
const BASIC_AUTH_SWITCH_IN_DOCTOR = " To switch this profile, re-run servicenow-mcp-setup and choose oauth.";
|
|
578
|
+
/** True for a 401 on a Basic credential, the case the OAuth advice is for. */
|
|
579
|
+
function isBasicAuthRejection(verification, config) {
|
|
580
|
+
return (verification.authenticationRejected === true &&
|
|
581
|
+
(config.authType === undefined || config.authType === "basic"));
|
|
582
|
+
}
|
|
507
583
|
/** Map a probe failure onto the thing the operator must actually change. */
|
|
508
584
|
function classifyVerificationFailure(error, config) {
|
|
509
585
|
const descriptor = (0, tool_error_js_1.trustedToolErrorDescriptor)(error);
|
|
@@ -539,6 +615,7 @@ function classifyVerificationFailure(error, config) {
|
|
|
539
615
|
if (descriptor?.category === "authentication") {
|
|
540
616
|
return Object.freeze({
|
|
541
617
|
ok: false,
|
|
618
|
+
authenticationRejected: true,
|
|
542
619
|
detail: `${host} rejected the credential (HTTP 401).`,
|
|
543
620
|
remedy: config.authType === "oauth"
|
|
544
621
|
? "Check the OAuth client id and secret, and that the client is active on the instance."
|
|
@@ -673,7 +750,9 @@ async function askTableSelection(prompter, operation, fallback) {
|
|
|
673
750
|
prompter.note(`\n "*" grants every table for ${operation.toLowerCase()}. ServiceNow's own\n` +
|
|
674
751
|
" per-user ACLs are then the only remaining boundary, so the integration\n" +
|
|
675
752
|
" account's roles become the whole control. It also skips the per-tool\n" +
|
|
676
|
-
" binding and the related-table closure check
|
|
753
|
+
" binding and the related-table closure check. It does not cover\n" +
|
|
754
|
+
` ${table_policy_js_1.NAMED_ONLY_TABLES.join(", ")};\n` +
|
|
755
|
+
" name them to allow them.\n");
|
|
677
756
|
return Object.freeze(["*"]);
|
|
678
757
|
}
|
|
679
758
|
return askCustomTableList(prompter, operation);
|
|
@@ -895,7 +974,8 @@ function renderQuestion(question, options) {
|
|
|
895
974
|
const lines = [`${question}:`];
|
|
896
975
|
options.choices.forEach((choice, index) => {
|
|
897
976
|
const marker = choice === options.default ? " (default)" : "";
|
|
898
|
-
|
|
977
|
+
const hint = options.hints?.[choice];
|
|
978
|
+
lines.push(` ${index + 1}) ${choice}${marker}${hint ? ` - ${hint}` : ""}`);
|
|
899
979
|
});
|
|
900
980
|
const defaultIndex = options.default ? options.choices.indexOf(options.default) + 1 : 0;
|
|
901
981
|
lines.push(defaultIndex > 0 ? `Choice [${defaultIndex}]: ` : "Choice: ");
|
|
@@ -1338,6 +1418,7 @@ function runPolicy(options, home, env, dependencies, out) {
|
|
|
1338
1418
|
},
|
|
1339
1419
|
encodedQueryAccess,
|
|
1340
1420
|
atf: manager.getAtfConfig(options.profile),
|
|
1421
|
+
fieldTypes: { dictionary: (0, hidden_values_js_1.dictionaryNotRequired)(profile.fieldTypes) ? "not_required" : "required" },
|
|
1341
1422
|
});
|
|
1342
1423
|
out(options.json
|
|
1343
1424
|
? `${JSON.stringify({ policy: card, note: encodedNote }, null, 2)}\n`
|
|
@@ -1392,11 +1473,14 @@ async function runLiveChecks(paths, home, dependencies, only) {
|
|
|
1392
1473
|
}
|
|
1393
1474
|
try {
|
|
1394
1475
|
const result = await verify(config);
|
|
1476
|
+
const remedy = result.remedy !== undefined && isBasicAuthRejection(result, config)
|
|
1477
|
+
? `${result.remedy}${BASIC_AUTH_SWITCH_IN_DOCTOR}`
|
|
1478
|
+
: result.remedy;
|
|
1395
1479
|
return {
|
|
1396
1480
|
name: `profile ${name}: live instance`,
|
|
1397
1481
|
ok: result.ok,
|
|
1398
1482
|
detail: result.detail,
|
|
1399
|
-
...(
|
|
1483
|
+
...(remedy === undefined ? {} : { remedy }),
|
|
1400
1484
|
};
|
|
1401
1485
|
}
|
|
1402
1486
|
catch {
|