@jacebenson/jsn 5.5.5-dev.190.1 → 5.5.5-dev.192.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/README.md +27 -305
- package/package.json +1 -1
- package/src/auth/credential-store.js +1 -1
- package/src/auth.js +3 -3
- package/src/commands/auth.js +1 -1
package/README.md
CHANGED
|
@@ -1,329 +1,51 @@
|
|
|
1
1
|
# JSN: ServiceNow CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Read ServiceNow records, inspect platform metadata, search documentation, and make explicit changes from your terminal or AI agent.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[npm](https://www.npmjs.com/package/@jacebenson/jsn) · [GitHub](https://github.com/jacebenson/jsn) · [JSN docs](https://jsn.jace.pro/docs/install/)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Install and connect
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Use the current [Node.js LTS release](https://nodejs.org/en/about/previous-releases) and npm on macOS, Linux, or Windows. Older Node.js release lines are not supported.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
10
12
|
npm install -g @jacebenson/jsn
|
|
11
13
|
jsn setup
|
|
12
14
|
```
|
|
13
15
|
|
|
14
|
-
See
|
|
15
|
-
|
|
16
|
-
### Dev channel
|
|
17
|
-
|
|
18
|
-
For the newest changes from `main`, including changes that may be unstable:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
npm install -g @jacebenson/jsn@dev
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Dev builds check the dev channel for updates during normal use, at most once
|
|
25
|
-
per day. Run `jsn version --check` to check immediately. To install the newest
|
|
26
|
-
dev build, run `jsn upgrade` (alias: `jsn update`). It preserves your installed
|
|
27
|
-
channel and skips installation when no newer version is available. Use
|
|
28
|
-
`--dry-run` to print the npm command without network access or installation,
|
|
29
|
-
`--force` to reinstall, or `--channel dev|latest` to switch channels explicitly.
|
|
30
|
-
For example, `jsn upgrade --channel latest` returns to stable. npm installation
|
|
31
|
-
permissions still apply; the command does not elevate privileges automatically.
|
|
32
|
-
|
|
33
|
-
Pushes to `main` promote the commit to `dev` and publish a tested prerelease
|
|
34
|
-
under npm's `dev` tag. Versions include the workflow run number and attempt
|
|
35
|
-
(for example, `4.3.9-dev.123.1`); they do not move npm's stable `latest` tag.
|
|
36
|
-
The npm trusted publisher for `publish-dev.yml` must authorize the repository's
|
|
37
|
-
`dev` GitHub environment, alongside the production publishing configuration.
|
|
38
|
-
|
|
39
|
-
### Knowledge search
|
|
16
|
+
Setup connects a named profile to your instance. Its default preset allows writes, so enable read-only mode before exploring. See [setup and authentication](https://jsn.jace.pro/docs/setup/).
|
|
40
17
|
|
|
41
|
-
|
|
42
|
-
accessible articles, then `jsn knowledge show KB0000010 --profile work` to read
|
|
43
|
-
one. Search supports bounded `--limit`/`--offset`, knowledge-base sys_ids with
|
|
44
|
-
`--kb`, and `--language`. JSON preserves native HTML; human output uses Markdown.
|
|
45
|
-
Hints preserve an explicitly selected profile/instance. The Knowledge API plugin
|
|
46
|
-
(`sn_km_api`) must be available; access is evaluated by that API, with no fallback
|
|
47
|
-
to direct table reads. Reads do not request view-count updates. See the
|
|
48
|
-
[Knowledge API reference](https://www.servicenow.com/docs/r/yokohama/api-reference/rest-apis/knowledge-api.html).
|
|
18
|
+
For unreleased changes, use `npm install -g @jacebenson/jsn@dev`; see [channels and updates](https://github.com/jacebenson/jsn/blob/main/docs/releases.md).
|
|
49
19
|
|
|
50
|
-
|
|
20
|
+
## Read and discover
|
|
51
21
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
jsn
|
|
57
|
-
jsn scan checks create --type table --data-file check.json --profile dev
|
|
58
|
-
jsn scan checks activate <check-id> --profile dev
|
|
59
|
-
jsn scan suites add-check <suite-id> --check <check-id> --profile dev
|
|
60
|
-
jsn scan run --update-set "My change" --suite "My suite" --wait --profile dev
|
|
61
|
-
jsn scan run --table sys_script_include --record <record-id> --profile dev
|
|
62
|
-
jsn scan results <execution-id> --profile dev
|
|
22
|
+
```sh
|
|
23
|
+
jsn records list --table incident --query "active=true" --limit 5 --json
|
|
24
|
+
jsn discover --table incident
|
|
25
|
+
jsn docs "GlideRecord" --limit 5
|
|
26
|
+
jsn --help
|
|
63
27
|
```
|
|
64
28
|
|
|
65
|
-
|
|
66
|
-
inactive unless the payload explicitly sets `active: true`; activation never
|
|
67
|
-
starts a scan. Both checks and suites support list/show/create/update/delete and
|
|
68
|
-
activate/deactivate. Suites also support add-check/remove-check.
|
|
69
|
-
|
|
70
|
-
Runs require an update set, scope, record plus table, or explicit `--full`.
|
|
71
|
-
Instance-wide scans may traverse many tables even when a check's script only
|
|
72
|
-
examines a few records. Starting and cancelling a scan require confirmation;
|
|
73
|
-
use `--force` only after approving that operation. `--wait --timeout 120` bounds
|
|
74
|
-
the wait, not the scan's lifetime. A timed-out wait keeps the execution id and
|
|
75
|
-
does not cancel or resubmit the scan. Use `status`, `results`, or `cancel` next.
|
|
76
|
-
|
|
77
|
-
Update-set scans examine current instance records, not the historical XML
|
|
78
|
-
versions. Inactive records may be skipped. Script-only checks do not participate
|
|
79
|
-
in record/update-set scans; use an explicitly instance-wide suite run to execute
|
|
80
|
-
them. Execution success does not mean zero findings or complete test coverage:
|
|
81
|
-
results report recorded check executions, finding counts, unreadable sources,
|
|
82
|
-
and truncated lists separately. A result's rerun hint preserves the previous
|
|
83
|
-
target combination and requires `--full` again for instance-wide scans.
|
|
84
|
-
|
|
85
|
-
Every command returns next-step breadcrumbs in human and JSON output, retaining
|
|
86
|
-
an explicitly selected profile or instance. `updatesets show` also offers a scan
|
|
87
|
-
hint. Recommendation/generation of new checks is not part of this command;
|
|
88
|
-
JSN contains no AI and does not infer missing business requirements.
|
|
89
|
-
|
|
90
|
-
### CMDB search
|
|
91
|
-
|
|
92
|
-
`jsn cmdb search "web" --profile work` searches names, FQDNs, IP addresses and
|
|
93
|
-
serial numbers on `cmdb_ci`. Use `--class cmdb_ci_server` for an exact class
|
|
94
|
-
match (excluding subclasses), and bounded `--limit`/`--offset` pagination.
|
|
95
|
-
Search text is literal; encoded-query operators and query scripts are rejected.
|
|
96
|
-
Existing `cmdb list --query` remains available for deliberate encoded queries.
|
|
97
|
-
Results include show/relationship hints and preserve the selected connection.
|
|
29
|
+
Instance reads use your selected profile; add `--profile <name>` to choose another. Documentation search needs no ServiceNow connection and uses the hosted service by default. Use `jsn <command> --help` for options or `jsn --all-commands --help` for the full reference.
|
|
98
30
|
|
|
99
|
-
|
|
31
|
+
## Choose output
|
|
100
32
|
|
|
101
|
-
|
|
102
|
-
supported (three stable releases and three dev builds). For example, with
|
|
103
|
-
stable `4.3.11`, versions `4.3.11`, `4.3.10`, and `4.3.9` are supported.
|
|
104
|
-
Update to the newest version in your channel before reporting an issue.
|
|
33
|
+
Use the default terminal view for people, `--csv` or `--tsv` for flat rows, and `--json` when scripts need pagination, context, or errors. CSV/TSV do not fetch more pages or preserve both reference IDs and labels. Pagination notices go to stderr only when more results are explicitly known; silence does not prove completeness. JSON retains reference objects only if the command has not already flattened them. See [output details](https://jsn.jace.pro/docs/output/).
|
|
105
34
|
|
|
106
|
-
|
|
107
|
-
CI/CD does not deprecate older versions or require an `NPM_TOKEN` secret. Older
|
|
108
|
-
versions remain available; their availability does not extend the support window.
|
|
35
|
+
## Work safely
|
|
109
36
|
|
|
110
|
-
|
|
111
|
-
older versions with `node scripts/deprecate-old-versions.mjs latest` (or `dev`).
|
|
112
|
-
Applying deprecations with `--apply` requires npm authentication and
|
|
113
|
-
`NODE_AUTH_TOKEN`; it is separate from publishing. The script requires the
|
|
114
|
-
checkout's package version to match the channel's current npm tag.
|
|
37
|
+
Use `jsn auth modify <profile> --read-only` to block instance writes. ServiceNow roles and ACLs still decide what you can access. Help and discovery may show a compact command list for the connected account; this is not an access grant or an exhaustive capability check.
|
|
115
38
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
jsn incidents list --query "active=true^priority=1"
|
|
120
|
-
jsn records list --table incident --limit 10 --json
|
|
121
|
-
jsn flows list
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Run `jsn --help` for a concise command overview, or `jsn --all-commands --help` for the complete command and flag reference. See the [CLI guide](https://github.com/jacebenson/jsn/blob/main/docs/cli-guide.md) for authentication, output formats, development, and examples. The [docs site](https://jacebenson.github.io/jsn/) has feature guides.
|
|
39
|
+
Writes are not universally dry-run operations or confirmation prompts. Inspect each command's help, target profile, scope, and update set before changing anything. Use `--force` only for an approved operation. See [safety guidance](https://jsn.jace.pro/docs/safety/).
|
|
125
40
|
|
|
126
41
|
## AI agents
|
|
127
42
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
## Development
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
cd cli
|
|
134
|
-
npm ci
|
|
135
|
-
npm test
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
## License
|
|
139
|
-
|
|
140
|
-
MIT
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
### Commands for the connected account
|
|
144
|
-
|
|
145
|
-
Login and OAuth refresh check for the current account's `admin` role. Profiles
|
|
146
|
-
without that role show a compact command list focused on tickets, generic
|
|
147
|
-
records, people/groups, documentation, and connection management. If the role
|
|
148
|
-
check is unavailable, the profile also uses compact help; this does not assert
|
|
149
|
-
that the account lacks admin. Existing profiles keep full help until renewed.
|
|
150
|
-
|
|
151
|
-
This applies to root help, root JSON, `discover`, and root shell completion.
|
|
152
|
-
Use `jsn --all-commands --help` or `jsn discover --all-commands --json` to inspect
|
|
153
|
-
every registered command. Explicit command paths remain available and ServiceNow
|
|
154
|
-
ACLs decide access. Reauthenticate (or refresh OAuth) after roles change.
|
|
155
|
-
|
|
156
|
-
### Ordering catalog items
|
|
157
|
-
|
|
158
|
-
Use `jsn catalogitems search "laptop" --profile work`, then
|
|
159
|
-
`jsn catalogitems describe <item-sys-id> --profile work` to inspect pricing and
|
|
160
|
-
variable definitions through the native Service Catalog API. Create a JSON file
|
|
161
|
-
mapping variable names to values, then preview with
|
|
162
|
-
`jsn catalogitems order <item-sys-id> --variables-file variables.json --dry-run --profile work`.
|
|
163
|
-
Omit `--dry-run` to submit after confirmation. `--quantity` defaults to one;
|
|
164
|
-
`--requested-for` accepts a user sys_id subject to instance delegation rules.
|
|
165
|
-
|
|
166
|
-
`show` is the one view of an item — `describe` and `inputs` are aliases for it.
|
|
167
|
-
It reads the item twice and answers once: the Table API gives the definition
|
|
168
|
-
(`sc_cat_item` plus `item_option_new`), and
|
|
169
|
-
`/api/sn_sc/servicecatalog/items/{id}` gives what this account can actually
|
|
170
|
-
request. The catalog API wins when it answers; the definition list keeps the
|
|
171
|
-
command working when it does not, with `variables_source` naming which one
|
|
172
|
-
answered and `variables_api_error` carrying the reason for the fallback.
|
|
173
|
-
|
|
174
|
-
Questions come back as `{name, label, type, friendly_type, mandatory,
|
|
175
|
-
instance_supplied}` with `required_variables` and `instance_supplied_variables`,
|
|
176
|
-
so a script can build the payload without guessing names or types. Layout
|
|
177
|
-
entries that draw the form but hold no value — containers, labels, HTML and rich
|
|
178
|
-
text blocks, breaks and UI macros — are not reported as questions; only their
|
|
179
|
-
container children are walked. `required_variables` excludes the
|
|
180
|
-
instance-supplied ones: "Requested for" (type 31) is mandatory in the API
|
|
181
|
-
payload, but the instance fills it from the session and `--requested-for`
|
|
182
|
-
overrides it. `order` refuses locally when a required question is missing and an
|
|
183
|
-
unknown variable name is reported as `unknown_variable_names` without blocking.
|
|
184
|
-
The server remains the authority.
|
|
185
|
-
|
|
186
|
-
What the API returns is what a caller can send: questions withheld by a catalog UI
|
|
187
|
-
policy are absent, and a policy-applied mandatory flag is not visible here, so the
|
|
188
|
-
server still decides at submission. Record producers and order guides expose their
|
|
189
|
-
variables but are not orderable through `order`.
|
|
190
|
-
|
|
191
|
-
Orders use `order_now`, preserving catalog fulfillment rather than inserting an
|
|
192
|
-
RITM directly. `order_now` returns the request (REQ); JSN then reads the request's
|
|
193
|
-
items and reports `request_id`, `request_number` and `requested_items`
|
|
194
|
-
(`sys_id`/`number`). If that follow-up read is denied, the order is still
|
|
195
|
-
reported as placed with `requested_items_readable: false` — inspect requests
|
|
196
|
-
rather than resubmitting. The command handles standard catalog items; record
|
|
197
|
-
producers and order guides require separate workflows. Server rules validate
|
|
198
|
-
dynamic variables at submission; a preview does not validate those rules.
|
|
199
|
-
Preview output lists variable names and required names, not entered values.
|
|
200
|
-
Previews only read, so they work on a read-only profile; submitting requires a
|
|
201
|
-
write-enabled profile and no development update set. Confirmation follows the
|
|
202
|
-
existing profile policy; automation can supply `--force` only for an approved
|
|
203
|
-
order. Timeout or incomplete response is an uncertain outcome: inspect requests
|
|
204
|
-
before retrying. JSN does not automatically submit a second order.
|
|
205
|
-
`create/list/show` retain their definition-management behavior.
|
|
206
|
-
|
|
207
|
-
See the [Service Catalog API reference](https://www.servicenow.com/docs/r/api-reference/rest-apis/c_ServiceCatalogAPI.html).
|
|
208
|
-
|
|
209
|
-
### Viewing service and HR cases
|
|
210
|
-
|
|
211
|
-
`jsn cases list`, `jsn cases show <number>` and `jsn cases search "<text>"` read
|
|
212
|
-
cases through the normal authenticated Table API. Which case table is meant
|
|
213
|
-
depends on the installed application, so JSN probes the known case tables in
|
|
214
|
-
order — `sn_customerservice_case` (Customer Service Management), then
|
|
215
|
-
`sn_hr_core_case` (HR Service Delivery) — and uses the first one the profile can
|
|
216
|
-
read. `jsn cases tables` reports each candidate without claiming access, and
|
|
217
|
-
`--table <name>` names any other case table.
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
jsn cases list --json
|
|
221
|
-
jsn cases list --hr --query "active=true"
|
|
222
|
-
jsn cases search "printer" --table sn_customerservice_case
|
|
223
|
-
jsn cases show CS0001001
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
Visibility is not widened by JSN: application roles and ACLs decide which
|
|
227
|
-
records are returned, and a denied table reports `forbidden` (HTTP 403) rather
|
|
228
|
-
than an empty list. An instance without a case application reports which tables
|
|
229
|
-
were unavailable instead of pretending there are no cases, and naming such a
|
|
230
|
-
table with `--table` fails the same way (`Reading <table> failed (HTTP 400)`,
|
|
231
|
-
exit 2) instead of printing an empty list. To scope a list to the connected
|
|
232
|
-
account, add a query term — field names differ per application, for example
|
|
233
|
-
`--query "opened_by=javascript:gs.getUserID()"`. These commands only read; case
|
|
234
|
-
work that changes state stays in the application UI or `jsn records update`.
|
|
235
|
-
|
|
236
|
-
HR cases are a thin addition over this generic path: `--hr` selects
|
|
237
|
-
`sn_hr_core_case`. Employee self-service visibility depends on the HR roles and
|
|
238
|
-
ACLs of the connected account — an administrator profile does not represent an
|
|
239
|
-
employee's view. HR case tasks, relations and the employee portal's widgets are
|
|
240
|
-
not exposed yet.
|
|
241
|
-
|
|
242
|
-
## Domain configuration and browser sessions
|
|
243
|
-
|
|
244
|
-
`jsn domains current` reports the selected profile's configured `X-Now-Domain`
|
|
245
|
-
header. `domains set <name-or-id>` and `domains set clear` configure that header
|
|
246
|
-
locally. Header effectiveness depends on the instance; clearing it does not
|
|
247
|
-
reset the actual server session domain.
|
|
248
|
-
|
|
249
|
-
With saved browser-session (`gck`) credentials, use these explicit commands:
|
|
250
|
-
|
|
251
|
-
```bash
|
|
252
|
-
jsn domains session-current --profile example --json
|
|
253
|
-
jsn domains session-list --profile example --search '*Internal' --limit 20 --offset 0 --json
|
|
254
|
-
jsn domains session-reset --profile example --json
|
|
255
|
-
jsn domains session-list --profile example --json
|
|
256
|
-
jsn domains session-set <domain-sys-id> --profile example --json
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
`session-list` returns one picker-visible page (`items`, `offset`, `limit`,
|
|
260
|
-
`next_offset`). Search matches a name prefix, or a substring with a leading `*`.
|
|
261
|
-
Visibility depends on the actual session domain. For cross-branch selection,
|
|
262
|
-
explicitly reset to global, then list and select a domain from that result.
|
|
263
|
-
Neither listing nor selecting silently resets the session. `session-current`
|
|
264
|
-
reports both `configured_domain` and `session_domain`.
|
|
265
|
-
|
|
266
|
-
**Session reset and selection may affect a browser sharing these credentials.**
|
|
267
|
-
Both commands verify the resulting domain with a separate readback. They leave
|
|
268
|
-
profile configuration unchanged and omit the configured domain header on picker
|
|
269
|
-
requests. Save the original domain ID from `session-current` if you intend to
|
|
270
|
-
restore it afterward. A failed readback can leave the session changed; inspect
|
|
271
|
-
`session-current` before retrying. These commands do not call `touch-session`.
|
|
272
|
-
Other authentication methods retain the existing profile configuration flow.
|
|
273
|
-
|
|
274
|
-
## Documentation search
|
|
275
|
-
|
|
276
|
-
```bash
|
|
277
|
-
jsn docs "GlideRecord" --limit 5
|
|
278
|
-
jsn docs --path "api-reference/c_GlideRecordClientSideAPI.md"
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
No ServiceNow connection is required. Hosted docs at `https://jsn.jace.pro` are
|
|
282
|
-
the default and download no database. `jsn setup` asks once for defaults for new
|
|
283
|
-
connections and whether to use hosted documentation. Decline hosted docs to let
|
|
284
|
-
JSN start a local server, or decline that too and enter your own service base URL.
|
|
285
|
-
Later changes live under **Defaults and documentation** in setup. Existing connections
|
|
286
|
-
keep their saved settings.
|
|
287
|
-
|
|
288
|
-
Local mode downloads the public documentation on first use and checks for updates
|
|
289
|
-
daily while running. The server starts again automatically when needed. A first
|
|
290
|
-
search can report that the index is still being prepared; later updates preserve
|
|
291
|
-
the last working index if offline. Local storage lives under
|
|
292
|
-
`~/.jsn/docs/docs.db` for the default family. Other families use
|
|
293
|
-
`~/.jsn/docs/releases/NAME/docs.db`. `JSN_DATA_HOME` overrides the parent directory.
|
|
294
|
-
Existing default-family installs keep their original index path.
|
|
295
|
-
|
|
296
|
-
To host the same service yourself, run `jsn docs --serve --host 0.0.0.0 --port 3000`.
|
|
297
|
-
It manages its own index; expose it through your normal HTTPS proxy. The hosted
|
|
298
|
-
website and this server share one search engine. `JSN_DOCS_URL` temporarily
|
|
299
|
-
overrides the saved choice without starting a local server.
|
|
300
|
-
|
|
301
|
-
Choose a family with `jsn docs "GlideRecord" --release brazil`. The same option
|
|
302
|
-
applies to `--path`, `docs show <ID>`, `docs status`, `docs sync`, `docs install`
|
|
303
|
-
and `--serve`. Resolution is `--release` first, then the optional `docs.release`
|
|
304
|
-
preference, then `australia`. Release names contain 1–40 lowercase letters,
|
|
305
|
-
digits or dashes. The service decides which families exist.
|
|
306
|
-
|
|
307
|
-
Documentation preferences are saved in the global profile config at
|
|
308
|
-
`$XDG_CONFIG_HOME/servicenow/config.json`, normally
|
|
309
|
-
`~/.config/servicenow/config.json`. Alongside `docs.source` and `docs.url`, set
|
|
310
|
-
`docs.release` without changing the service URL:
|
|
311
|
-
|
|
312
|
-
```json
|
|
313
|
-
{ "docs": { "source": "hosted", "url": "https://jsn.jace.pro", "release": "brazil" } }
|
|
314
|
-
```
|
|
43
|
+
Inspect the bundled skill with `jsn skill show`, then use `jsn skill install` to select your agent or `jsn skill install --target hermes` for Hermes. Reinstall after upgrading JSN; reinstalling replaces recorded copies, including local edits. See [agent installation](https://jsn.jace.pro/docs/agents/).
|
|
315
44
|
|
|
316
|
-
|
|
317
|
-
paths and the default marker without contacting the network. To install an
|
|
318
|
-
optional local index, use `jsn docs install --source snapshot --release brazil`,
|
|
319
|
-
or `jsn docs sync --release brazil --no-embed`. Sync downloads the named Git
|
|
320
|
-
branch; `--no-ingest` downloads only the source. Snapshot installs use
|
|
321
|
-
`/docs-index/releases/NAME/manifest.json` and verify the declared release. Only
|
|
322
|
-
the default family can fall back to the old `/docs-index/manifest.json` when
|
|
323
|
-
the family manifest returns 404. That legacy manifest may omit `release`.
|
|
324
|
-
`jsn docs --serve --release brazil` serves only Brazil and rejects requests
|
|
325
|
-
for other families. Search, read and status JSON include the selected `release`.
|
|
45
|
+
## Go deeper
|
|
326
46
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
47
|
+
- [CLI guide and feature workflows](https://jsn.jace.pro/docs/cli-guide/)
|
|
48
|
+
- [Documentation search and local hosting](https://jsn.jace.pro/docs/install/)
|
|
49
|
+
- [Feature library](https://jsn.jace.pro/#features)
|
|
50
|
+
- [Development and contributing](https://github.com/jacebenson/jsn#development-and-contributing)
|
|
51
|
+
- [MIT license](https://github.com/jacebenson/jsn/blob/main/LICENSE)
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@ import { globalConfigDir } from '../config.js';
|
|
|
10
10
|
*
|
|
11
11
|
* Whitelist approach (issue #143 findings #2/#3): first map the `://`
|
|
12
12
|
* protocol separator to `_` exactly as the Go version's encoding does
|
|
13
|
-
* (so existing keyring keys like `
|
|
13
|
+
* (so existing keyring keys like `https_example.service-now.com` keep
|
|
14
14
|
* matching), then drop everything outside [a-zA-Z0-9._-]. Blacklist
|
|
15
15
|
* stripping of just `/` and `:` left quotes, `$()`, backticks, `;`,
|
|
16
16
|
* spaces, and backslashes — which broke out of double-quoted shell args
|
package/src/auth.js
CHANGED
|
@@ -26,11 +26,11 @@ export { classifyCredentialState } from './auth/credential-state.js';
|
|
|
26
26
|
|
|
27
27
|
// ─── Basic auth from environment variables ───
|
|
28
28
|
// SN_USERNAME / SN_PASSWORD — global credentials
|
|
29
|
-
// SN_<INSTANCE>_USERNAME / SN_<INSTANCE>_PASSWORD — instance-specific (e.g.
|
|
29
|
+
// SN_<INSTANCE>_USERNAME / SN_<INSTANCE>_PASSWORD — instance-specific (e.g. SN_EXAMPLE_USERNAME)
|
|
30
30
|
|
|
31
31
|
function envVarName(instance) {
|
|
32
32
|
// Normalize instance URL to an env-var-safe name
|
|
33
|
-
// e.g. https://
|
|
33
|
+
// e.g. https://example.service-now.com → EXAMPLE
|
|
34
34
|
const host = instance.replace(/https?:\/\//, '').replace(/\/.*$/, '').replace(/\.service-now\.com.*/, '').replace(/[^a-zA-Z0-9]/g, '').toUpperCase();
|
|
35
35
|
return host;
|
|
36
36
|
}
|
|
@@ -44,7 +44,7 @@ function getBasicAuthFromEnv(instance) {
|
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// Try instance-specific env vars first (e.g.
|
|
47
|
+
// Try instance-specific env vars first (e.g. SN_EXAMPLE_USERNAME)
|
|
48
48
|
const host = envVarName(instance);
|
|
49
49
|
const instanceUser = process.env[`SN_${host}_USERNAME`];
|
|
50
50
|
const instancePass = process.env[`SN_${host}_PASSWORD`];
|
package/src/commands/auth.js
CHANGED
|
@@ -602,7 +602,7 @@ export async function loginProfile(argv, app, { concise = false } = {}) {
|
|
|
602
602
|
Examples:
|
|
603
603
|
jsn auth login https://dev12345.service-now.com
|
|
604
604
|
jsn auth login dev373698
|
|
605
|
-
jsn auth login --basic https://
|
|
605
|
+
jsn auth login --basic https://example.service-now.com
|
|
606
606
|
|
|
607
607
|
Find your instance URL in your browser's address bar when logged into ServiceNow.`);
|
|
608
608
|
}
|