@jacebenson/jsn 5.5.7-dev.214.1 → 5.5.7-dev.216.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jacebenson/jsn",
3
- "version": "5.5.7-dev.214.1",
3
+ "version": "5.5.7-dev.216.1",
4
4
  "description": "A command-line interface for ServiceNow that follows the Unix philosophy: simple, composable, and scriptable.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -302,12 +302,7 @@ async function promptMidCredentials(app, argv) {
302
302
  const validation = await validateMidCredentials(app.getEffectiveInstance(), username, password);
303
303
  return { username, password, releaseName: validation.releaseName };
304
304
  } catch (error) {
305
- const answer = await input({ message: `${error.message}. Press Enter to retry or Q to quit:` });
306
- if (answer.trim().toLowerCase() === 'q') {
307
- const quit = new Error('MID Server installation cancelled');
308
- quit.code = 'cancelled';
309
- throw quit;
310
- }
305
+ await input({ message: `${error.message}. Press Enter to retry or Esc to cancel:` });
311
306
  username = argv.username || '';
312
307
  }
313
308
  }
@@ -41,37 +41,10 @@ const setupHelp = () => [
41
41
  'Configure settings directly: jsn setup --configure-defaults or jsn setup --configure-docs.',
42
42
  ].join('\n');
43
43
 
44
- /** The setup hub prompt; q and Escape resolve with no selected action. */
44
+ /** The setup hub shares searchable local menus; Escape leaves the hub. */
45
45
  export const authHubPrompt = async (config = {}, context = {}) => {
46
- const { runPrompt, escapeResult } = await import('../prompt-engine.js');
47
- const choices = config.choices || [];
48
- const state = { active: 0 };
49
- return runPrompt(config, context, {
50
- escapeValue: escapeResult(undefined),
51
- init: () => state,
52
- key(_state, key, api) {
53
- if (key.name === 'q') return { done: undefined };
54
- if (key.name === 'return' || key.name === 'enter') {
55
- const choice = choices[state.active];
56
- if (choice) return { done: choice.value };
57
- return;
58
- }
59
- if (key.name === 'up' && state.active > 0) { state.active -= 1; api.redraw(); return; }
60
- if (key.name === 'down' && state.active < choices.length - 1) { state.active += 1; api.redraw(); }
61
- },
62
- render() {
63
- // Section headings are rendered inline; the pagination budget the
64
- // Inquirer version needed no longer applies to a local renderer.
65
- const lines = [config.message];
66
- choices.forEach((choice, index) => {
67
- const heading = choices[index - 1]?.section !== choice.section ? `${index ? '\n' : ''} ${choice.section}` : null;
68
- if (heading) lines.push(heading);
69
- lines.push(`${index === state.active ? '❯' : ' '} ${choice.name}`);
70
- });
71
- lines.push('', '↑↓ navigate • ⏎ select • q/Esc exit');
72
- return lines;
73
- },
74
- });
46
+ const { select, escapeResult } = await import('../prompts.js');
47
+ return select({ ...config, escapeValue: escapeResult(undefined) }, context);
75
48
  };
76
49
 
77
50
  /** Interactive hub: what do you want to do? Returns an action or undefined on exit. */
package/src/helpers.js CHANGED
@@ -448,31 +448,24 @@ export async function interactiveList({ app, table, singular, columns, limit = 5
448
448
 
449
449
  // Paginated source adapter: (term, offset, { signal }) => choices[]
450
450
  async function serverSource(term, offset, { signal: _signal } = {}) {
451
- try {
452
- const params = new URLSearchParams();
453
- params.set('sysparm_limit', String(limit));
454
- params.set('sysparm_display_value', 'all');
455
- if (pickerFields) params.set('sysparm_fields', pickerFields);
456
- if (term) {
457
- params.set('sysparm_query', `${baseQuery}${labelField}LIKE${term}^ORDERBYDESCsys_updated_on`);
458
- } else {
459
- params.set('sysparm_query', baseQuery + 'ORDERBYDESCsys_updated_on');
460
- params.set('sysparm_offset', String(offset));
461
- }
462
- const records = await app.sdk.list(table, params);
463
- if (!Array.isArray(records)) {
464
- console.error('SDK non-array:', typeof records);
465
- return [];
466
- }
467
- return records.map(r => ({
468
- name: formatLabel ? formatLabel(r) : (getStringField(r, labelField) || getStringField(r, 'sys_id')),
469
- value: formatValue ? formatValue(r) : r,
470
- }));
471
- } catch (err) {
472
- if (isTerminalAuthError(err)) throw err;
473
- console.error('serverSource error:', err.message || err);
474
- return [];
451
+ const params = new URLSearchParams();
452
+ params.set('sysparm_limit', String(limit));
453
+ params.set('sysparm_display_value', 'all');
454
+ if (pickerFields) params.set('sysparm_fields', pickerFields);
455
+ if (term) {
456
+ params.set('sysparm_query', `${baseQuery}${labelField}LIKE${term}^ORDERBYDESCsys_updated_on`);
457
+ } else {
458
+ params.set('sysparm_query', baseQuery + 'ORDERBYDESCsys_updated_on');
459
+ params.set('sysparm_offset', String(offset));
475
460
  }
461
+ // Only a successful empty page means exhausted. Let the picker render
462
+ // failures and retry this offset; preserve terminal auth errors unchanged.
463
+ const records = await app.sdk.list(table, params);
464
+ if (!Array.isArray(records)) throw new Error(`Could not list ${table}: list returned a non-array result`);
465
+ return records.map(r => ({
466
+ name: formatLabel ? formatLabel(r) : (getStringField(r, labelField) || getStringField(r, 'sys_id')),
467
+ value: formatValue ? formatValue(r) : r,
468
+ }));
476
469
  }
477
470
 
478
471
  const selected = await prompt({
@@ -5,10 +5,12 @@
5
5
  * paginatedSearch({ message, pageSize, totalCount, source }, context?)
6
6
  * source(term, offset, { signal }) -> [{ name, value }]
7
7
  * Enter resolves the active choice object; Escape resolves undefined.
8
- * Down at the last loaded row loads more while loaded < totalCount.
8
+ * Down at the last loaded row loads more while loaded < totalCount;
9
+ * a null totalCount is unknown and continues until a successful empty page.
9
10
  */
10
11
 
11
- import { runPrompt, normalizeChoices, truncate, escapeResult } from './prompt-engine.js';
12
+ import { pickerRows, pickerFooter } from './picker-ui.js';
13
+ import { runPrompt, normalizeChoices, escapeResult } from './prompt-engine.js';
12
14
 
13
15
  export const paginatedSearch = async (config = {}, context = {}) => {
14
16
  const { message, pageSize = 10, totalCount = 0, source } = config;
@@ -24,6 +26,9 @@ export const paginatedSearch = async (config = {}, context = {}) => {
24
26
  error: '',
25
27
  };
26
28
 
29
+ const canLoadMore = () => !state.searchMode && !state.exhausted
30
+ && (totalCount == null || state.loaded < totalCount);
31
+
27
32
  // Every request gets a token. A response may only be applied while its
28
33
  // token is still current, so a stale (slower) search can never replace
29
34
  // newer results or be selected by a later Enter.
@@ -41,6 +46,7 @@ export const paginatedSearch = async (config = {}, context = {}) => {
41
46
  if (!isCurrent(token)) return;
42
47
  state.choices = append ? state.choices.concat(items) : items;
43
48
  state.loaded = state.choices.length;
49
+ state.exhausted = items.length === 0;
44
50
  state.active = Math.min(state.active, Math.max(0, state.choices.length - 1));
45
51
  state.status = 'done';
46
52
  } catch (error) {
@@ -77,7 +83,7 @@ export const paginatedSearch = async (config = {}, context = {}) => {
77
83
  // screen may be about to change.
78
84
  if (state.status === 'loading' || !state.choices.length) return;
79
85
  const choice = state.choices[state.active];
80
- if (!choice) return;
86
+ if (!choice || choice.disabled) return;
81
87
  return { done: choice };
82
88
  }
83
89
  if (key.name === 'up') {
@@ -90,7 +96,7 @@ export const paginatedSearch = async (config = {}, context = {}) => {
90
96
  if (state.active < state.choices.length - 1) {
91
97
  state.active += 1;
92
98
  api?.redraw();
93
- } else if (!state.searchMode && state.loaded < totalCount) {
99
+ } else if (canLoadMore()) {
94
100
  const before = state.loaded;
95
101
  const pending = load('', state.loaded, { append: true });
96
102
  const token = state.token;
@@ -130,17 +136,11 @@ export const paginatedSearch = async (config = {}, context = {}) => {
130
136
  const header = totalCount > 0 && !state.searchMode
131
137
  ? `${message} (${state.loaded} of ${totalCount} loaded)`
132
138
  : message;
133
- const lines = [`${header} Search: ${state.term}${state.status === 'loading' ? ' ...' : ''}`];
139
+ const lines = [header ?? '', `Search: ${state.term}${state.status === 'loading' ? ' ...' : ''}`];
134
140
  if (state.error) lines.push(` ${state.error}`);
135
141
  else if (!state.choices.length) lines.push(state.status === 'loading' ? ' Loading...' : ' No matches');
136
- visible.forEach((choice, index) => {
137
- const absolute = start + index;
138
- lines.push(`${absolute === state.active ? '>' : ' '} ${truncate(choice.name)}`);
139
- });
140
- const help = state.loaded < totalCount && !state.searchMode
141
- ? '(scroll to load more, type to search, Esc to cancel)'
142
- : '(type to search, Esc to cancel)';
143
- lines.push('', help);
142
+ lines.push(...pickerRows(visible, state.active - start));
143
+ lines.push(...pickerFooter({ more: canLoadMore() }));
144
144
  return lines;
145
145
  },
146
146
  });
@@ -0,0 +1,20 @@
1
+ export const PICKER_HELP = '↑↓ navigate • ⏎ select • type to search • Esc cancel';
2
+
3
+ export function pickerRows(choices, active, { picked } = {}) {
4
+ const lines = [];
5
+ choices.forEach((choice, index) => {
6
+ if (choice.section && choice.section !== choices[index - 1]?.section) {
7
+ if (index) lines.push('');
8
+ lines.push(` ${choice.section}`);
9
+ }
10
+ if (choice.separator) { lines.push(` ${choice.name}`); return; }
11
+ const check = picked ? `[${picked.has(choice) ? 'x' : ' '}] ` : '';
12
+ lines.push(`${index === active ? '❯' : ' '} ${check}${choice.name}${choice.disabled ? ' (disabled)' : ''}`);
13
+ if (index === active && choice.description) lines.push(` ${choice.description}`);
14
+ });
15
+ return lines;
16
+ }
17
+
18
+ export function pickerFooter({ checkbox = false, more = false } = {}) {
19
+ return ['', `${PICKER_HELP}${checkbox ? ' • Space toggle' : ''}${more ? ' • ↓ load more' : ''}`];
20
+ }
@@ -12,6 +12,7 @@
12
12
  */
13
13
 
14
14
  import readline from 'node:readline';
15
+ import { stripVTControlCharacters } from 'node:util';
15
16
 
16
17
  export class PromptCancelled extends Error {
17
18
  constructor() {
@@ -27,7 +28,10 @@ export function normalizeChoices(choices = []) {
27
28
  return {
28
29
  name: String(choice.name ?? choice.value ?? ''),
29
30
  value: 'value' in choice ? choice.value : choice.name,
30
- disabled: Boolean(choice.disabled),
31
+ disabled: Boolean(choice.disabled) || choice.type === 'separator',
32
+ ...(choice.type === 'separator' ? { separator: true } : {}),
33
+ ...(choice.section !== undefined ? { section: choice.section } : {}),
34
+ ...(choice.description !== undefined ? { description: choice.description } : {}),
31
35
  checked: Boolean(choice.checked),
32
36
  };
33
37
  }
@@ -78,7 +82,10 @@ export async function runPrompt(config, context, spec) {
78
82
  const text = Array.isArray(rendered) ? rendered.join('\n') : String(rendered ?? '');
79
83
  if (output.isTTY && height > 0) output.write(`\x1b[${height}A\x1b[0J`);
80
84
  output.write(`${text}\n`);
81
- height = text.split('\n').length;
85
+ // Count wrapped terminal rows as well as explicit newlines: the compact
86
+ // footer can still wrap in a narrow terminal.
87
+ const columns = output.isTTY && output.columns > 0 ? output.columns : Infinity;
88
+ height = text.split('\n').reduce((rows, line) => rows + Math.max(1, Math.ceil(Array.from(stripVTControlCharacters(line)).length / columns)), 0);
82
89
  };
83
90
 
84
91
  const finish = value => {
package/src/prompts.js CHANGED
@@ -7,7 +7,8 @@
7
7
  * paginated-search.js and resolve undefined instead.
8
8
  */
9
9
 
10
- import { runPrompt, normalizeChoices, truncate, PromptCancelled, escapeResult } from './prompt-engine.js';
10
+ import { pickerRows, pickerFooter } from './picker-ui.js';
11
+ import { runPrompt, normalizeChoices, PromptCancelled, escapeResult } from './prompt-engine.js';
11
12
  export { PromptCancelled };
12
13
 
13
14
  const ESC_HINT = ' (Esc to cancel)';
@@ -113,33 +114,59 @@ export async function confirm(config = {}, context = {}) {
113
114
  }
114
115
 
115
116
  export async function select(config = {}, context = {}) {
117
+ return localPicker(config, context);
118
+ }
119
+
120
+ async function localPicker(config, context, multiple = false) {
116
121
  const choices = normalizeChoices(config.choices || []);
117
- return runPrompt({ ...config, message: withHint(config) }, context, {
118
- init: () => ({ active: Math.max(firstEnabled(choices), choices.findIndex(choice => !choice.disabled && choice.value === config.default)) }),
119
- key(state, key, api) {
122
+ const state = {
123
+ term: '', choices, active: firstEnabled(choices), error: '',
124
+ picked: new Set(choices.filter(choice => choice.checked && !choice.disabled)),
125
+ };
126
+ const defaultIndex = choices.findIndex(choice => !choice.disabled && choice.value === config.default);
127
+ if (defaultIndex >= 0) state.active = defaultIndex;
128
+ return runPrompt(config, context, {
129
+ ...(config.escapeValue ? { escapeValue: config.escapeValue } : {}),
130
+ init: () => state,
131
+ async key(_state, key, api) {
132
+ const visible = state.choices;
133
+ const choice = visible[state.active];
120
134
  if (key.name === 'return' || key.name === 'enter') {
121
- const choice = choices[state.active];
122
- if (!choice || choice.disabled) return;
123
- return { done: choice.value };
135
+ if (!multiple) {
136
+ if (choice && !choice.disabled) return { done: choice.value };
137
+ return;
138
+ }
139
+ const values = choices.filter(choice => state.picked.has(choice)).map(choice => choice.value);
140
+ state.error = config.required && !values.length ? 'Select at least one option.' : await validateAnswer(config.validate, values);
141
+ if (state.error) { api.redraw(); return; }
142
+ return { done: values };
124
143
  }
125
- if (key.name === 'up') { state.active = move(choices, state.active, -1); api.redraw(); return; }
126
- if (key.name === 'down') { state.active = move(choices, state.active, 1); api.redraw(); return; }
127
- if (key.name === 'k') { state.active = move(choices, state.active, -1); api.redraw(); return; }
128
- if (key.name === 'j') { state.active = move(choices, state.active, 1); api.redraw(); return; }
129
- },
130
- render(state) {
131
- const lines = [withHint(config)];
132
- choices.forEach((choice, index) => {
133
- const marker = index === state.active ? '>' : ' ';
134
- lines.push(`${marker} ${choice.disabled ? `(disabled) ${choice.name}` : choice.name}`);
135
- });
136
- lines.push('', ' Use arrow keys, Enter to select.');
137
- return lines;
144
+ if (multiple && key.name === 'space') {
145
+ if (choice && !choice.disabled) {
146
+ if (state.picked.has(choice)) state.picked.delete(choice);
147
+ else state.picked.add(choice);
148
+ state.error = '';
149
+ }
150
+ } else if (multiple && key.ctrl && key.name === 'a') {
151
+ visible.forEach(choice => { if (!choice.disabled) state.picked.add(choice); });
152
+ } else if (key.name === 'up' || key.name === 'down') {
153
+ state.active = move(visible, state.active, key.name === 'up' ? -1 : 1);
154
+ } else {
155
+ const previous = state.term;
156
+ if (key.name === 'backspace') state.term = Array.from(state.term).slice(0, -1).join('');
157
+ else if (key.text) state.term += key.text;
158
+ if (previous !== state.term) {
159
+ state.choices = state.term ? choices.filter(choice => !choice.separator && choice.name.toLocaleLowerCase().includes(state.term.toLocaleLowerCase())) : choices;
160
+ state.active = firstEnabled(state.choices);
161
+ }
162
+ }
163
+ api.redraw();
138
164
  },
139
- final(cfg, value) {
140
- const chosen = choices.find(choice => choice.value === value);
141
- return `✔ ${withHint(cfg)} ${chosen ? chosen.name : value}`;
165
+ render() {
166
+ return [config.message ?? '', `Search: ${state.term}`, ...pickerRows(state.choices, state.active, multiple ? { picked: state.picked } : {}),
167
+ ...(!state.choices.length ? [' No matches'] : []), ...(state.error ? [` ${state.error}`] : []), ...pickerFooter({ checkbox: multiple })];
142
168
  },
169
+ final: (_cfg, value) => value === undefined ? null : `✔ ${config.message ?? ''} ${multiple ? choices.filter(choice => value.includes(choice.value)).map(choice => choice.name).join(', ') : choices.find(choice => choice.value === value)?.name ?? value ?? ''}`,
143
170
  });
144
171
  }
145
172
 
@@ -190,11 +217,11 @@ export async function search(config = {}, context = {}) {
190
217
  if (state.term !== previous) void load(api);
191
218
  },
192
219
  render() {
193
- const lines = [`${withHint(config)} Search: ${state.term}${state.loading ? ' ...' : ''}`];
220
+ const lines = [config.message ?? '', `Search: ${state.term}${state.loading ? ' ...' : ''}`];
194
221
  if (state.error) lines.push(` ${state.error}`);
195
222
  else if (!state.choices.length) lines.push(state.loading ? ' Loading...' : ' No matches');
196
- else state.choices.forEach((choice, index) => lines.push(`${index === state.active ? '>' : ' '} ${truncate(choice.name)}`));
197
- lines.push('', ' Type to filter, arrows to move, Enter to select.');
223
+ else lines.push(...pickerRows(state.choices, state.active));
224
+ lines.push(...pickerFooter());
198
225
  return lines;
199
226
  },
200
227
  });
@@ -205,46 +232,7 @@ export async function search(config = {}, context = {}) {
205
232
  }
206
233
 
207
234
  export async function checkbox(config = {}, context = {}) {
208
- const choices = normalizeChoices(config.choices || []);
209
- return runPrompt({ ...config, message: withHint(config) }, context, {
210
- init: () => ({ active: firstEnabled(choices), picked: new Set(choices.flatMap((choice, index) => choice.checked && !choice.disabled ? [index] : [])), error: '' }),
211
- key(state, key, api) {
212
- if (key.name === 'return' || key.name === 'enter') {
213
- const values = choices.filter((_choice, index) => state.picked.has(index)).map(choice => choice.value);
214
- if (config.required && values.length === 0) {
215
- state.error = 'Select at least one option.';
216
- api.redraw();
217
- return;
218
- }
219
- return { done: values };
220
- }
221
- if (key.name === 'space') {
222
- if (choices[state.active] && !choices[state.active].disabled) {
223
- if (state.picked.has(state.active)) state.picked.delete(state.active);
224
- else state.picked.add(state.active);
225
- state.error = '';
226
- api.redraw();
227
- }
228
- return;
229
- }
230
- if (key.name === 'a' && key.ctrl) {
231
- choices.forEach((choice, index) => { if (!choice.disabled) state.picked.add(index); });
232
- api.redraw();
233
- return;
234
- }
235
- if (key.name === 'up') { state.active = move(choices, state.active, -1); api.redraw(); return; }
236
- if (key.name === 'down') { state.active = move(choices, state.active, 1); api.redraw(); return; }
237
- },
238
- render(state) {
239
- const lines = [withHint(config)];
240
- choices.forEach((choice, index) => {
241
- lines.push(`${index === state.active ? '>' : ' '} [${state.picked.has(index) ? 'x' : ' '}] ${choice.name}`);
242
- });
243
- if (state.error) lines.push(` ${state.error}`);
244
- lines.push('', ' Space toggles, arrows move, Enter confirms.');
245
- return lines;
246
- },
247
- });
235
+ return localPicker(config, context, true);
248
236
  }
249
237
 
250
238
  function firstEnabled(choices) {
package/src/sdk.js CHANGED
@@ -39,15 +39,13 @@ function serializeCookies(cookieJar) {
39
39
  return [...cookieJar].map(([name, value]) => `${name}=${value}`).join('; ');
40
40
  }
41
41
 
42
- // REST resources that authenticate from the request's own headers. Every CLI
43
- // invocation is a fresh Node process, so `_warmSession()` always pays 2-3
44
- // sequential requests to mint UI cookies these paths never read — measured on a
45
- // live instance, `jsn records list` spent 4 round-trips on one list. Anything
46
- // else (script processors, GraphQL, the concourse picker, xmlhttp.do, update-set
47
- // export/import, binary attachment uploads) keeps the session bootstrap it
48
- // needs, and JSN_ALWAYS_WARM_SESSION=1 restores it for every path.
49
- // Basic is the exception: normal requests must first detect any TOTP challenge
50
- // before a pending operation can be sent. See docs/AUTH_LIFECYCLE.md.
42
+ // Endpoint capability, not authentication policy: these REST surfaces can use
43
+ // header-only auth. OAuth now prefers the existing UI session even here because
44
+ // tables with ws_access=false reject Bearer while allowing the same user's UI
45
+ // session. JSN_ALWAYS_WARM_SESSION=0 opts OAuth out only on these paths;
46
+ // stateful:true, required UI endpoints and value 1 retain session precedence.
47
+ // Basic/TOTP, supplied token and GCK policies remain unchanged. Internal OAuth
48
+ // bootstrap must bypass warming to avoid recursion. See site/docs/guides/setup.md.
51
49
  const STATELESS_REST_PREFIXES = ['/api/now/table/', '/api/now/stats/', '/api/now/v1/batch'];
52
50
 
53
51
  export function needsUiSession(url, { stateful = false, forceSession = false } = {}) {
@@ -106,7 +104,7 @@ export class SDKClient {
106
104
  this._recoveryPromise = null;
107
105
  }
108
106
 
109
- async _setAuth(req, { skipOAuthSession = false, basicSession = false } = {}) {
107
+ async _setAuth(req, { skipOAuthSession = false, basicSession = false, preferOAuthSession = false, oauthHeaderOnly = false } = {}) {
110
108
  if (!this.authProvider) {
111
109
  throw errAuth('No authentication configured');
112
110
  }
@@ -141,14 +139,19 @@ export class SDKClient {
141
139
  break;
142
140
  case 'token':
143
141
  case 'oauth':
144
- if (!skipOAuthSession) {
142
+ if (!skipOAuthSession || creds.auth_method === 'oauth' && preferOAuthSession) {
145
143
  const cookies = await this._warmSession();
146
144
  if (cookies && this.sessionUserToken) {
145
+ if (creds.auth_method === 'oauth') req.headers.delete('Authorization');
147
146
  req.headers.set('Cookie', cookies);
148
147
  req.headers.set('X-UserToken', this.sessionUserToken);
149
148
  break;
150
149
  }
151
150
  }
151
+ if (creds.auth_method === 'oauth' && oauthHeaderOnly) {
152
+ req.headers.delete('Cookie');
153
+ req.headers.delete('X-UserToken');
154
+ }
152
155
  req.headers.set('Authorization', `Bearer ${creds.access_token}`);
153
156
  break;
154
157
  case 'gck':
@@ -181,14 +184,19 @@ export class SDKClient {
181
184
  try {
182
185
  const req = new Request(endpoint, { ...opts, redirect: 'error', signal: controller.signal });
183
186
  if (prepare) prepare(req);
184
- // Header-authenticated REST skips UI warming for OAuth/token/GCK.
185
- // Basic must still check for TOTP before dispatch; internal bootstrap
186
- // requests explicitly bypass that check to avoid recursion.
187
+ // Endpoint requirements and Basic challenge gates are unchanged. OAuth
188
+ // additionally prefers the UI session on otherwise stateless REST unless
189
+ // explicitly opted out. Internal bootstrap bypasses both to avoid recursion.
187
190
  const skipSession = skipOAuthSession || !needsUiSession(endpoint, {
188
191
  stateful,
189
192
  forceSession: process.env.JSN_ALWAYS_WARM_SESSION === '1',
190
193
  });
191
- await this._setAuth(req, { skipOAuthSession: skipSession, basicSession: !skipOAuthSession });
194
+ await this._setAuth(req, {
195
+ skipOAuthSession: skipSession,
196
+ basicSession: !skipOAuthSession,
197
+ preferOAuthSession: !skipOAuthSession && process.env.JSN_ALWAYS_WARM_SESSION !== '0',
198
+ oauthHeaderOnly: !skipOAuthSession && skipSession && process.env.JSN_ALWAYS_WARM_SESSION === '0',
199
+ });
192
200
  timer = setTimeout(() => controller.abort(), timeout);
193
201
  const response = await fetch(req);
194
202
  if (!skipOAuthSession && this.recovery) {