@onlyflows/servicenow-mcp 1.0.0 → 2.1.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/.env.example +56 -0
- package/CHANGELOG.md +214 -0
- package/README.md +939 -101
- package/dist/auth.d.ts +88 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +396 -0
- package/dist/auth.js.map +1 -0
- package/dist/client.d.ts +111 -17
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +554 -79
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +41 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +44 -34
- package/dist/config.js.map +1 -1
- package/dist/encoded-query-policy.d.ts +72 -0
- package/dist/encoded-query-policy.d.ts.map +1 -0
- package/dist/encoded-query-policy.js +409 -0
- package/dist/encoded-query-policy.js.map +1 -0
- package/dist/execution-context.d.ts +235 -0
- package/dist/execution-context.d.ts.map +1 -0
- package/dist/execution-context.js +441 -0
- package/dist/execution-context.js.map +1 -0
- package/dist/field-policy.d.ts +117 -0
- package/dist/field-policy.d.ts.map +1 -0
- package/dist/field-policy.js +1684 -0
- package/dist/field-policy.js.map +1 -0
- package/dist/http-auth.d.ts +131 -0
- package/dist/http-auth.d.ts.map +1 -0
- package/dist/http-auth.js +347 -0
- package/dist/http-auth.js.map +1 -0
- package/dist/http-entrypoint.d.ts +26 -0
- package/dist/http-entrypoint.d.ts.map +1 -0
- package/dist/http-entrypoint.js +255 -0
- package/dist/http-entrypoint.js.map +1 -0
- package/dist/http-observability.d.ts +147 -0
- package/dist/http-observability.d.ts.map +1 -0
- package/dist/http-observability.js +711 -0
- package/dist/http-observability.js.map +1 -0
- package/dist/http-request-policy.d.ts +72 -0
- package/dist/http-request-policy.d.ts.map +1 -0
- package/dist/http-request-policy.js +463 -0
- package/dist/http-request-policy.js.map +1 -0
- package/dist/http-request-signal.d.ts +12 -0
- package/dist/http-request-signal.d.ts.map +1 -0
- package/dist/http-request-signal.js +39 -0
- package/dist/http-request-signal.js.map +1 -0
- package/dist/http-runtime.d.ts +77 -0
- package/dist/http-runtime.d.ts.map +1 -0
- package/dist/http-runtime.js +1321 -0
- package/dist/http-runtime.js.map +1 -0
- package/dist/incident-journal-policy.d.ts +22 -0
- package/dist/incident-journal-policy.d.ts.map +1 -0
- package/dist/incident-journal-policy.js +115 -0
- package/dist/incident-journal-policy.js.map +1 -0
- package/dist/index.d.ts +14 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +140 -36
- package/dist/index.js.map +1 -1
- package/dist/metadata-cache.d.ts +71 -0
- package/dist/metadata-cache.d.ts.map +1 -0
- package/dist/metadata-cache.js +397 -0
- package/dist/metadata-cache.js.map +1 -0
- package/dist/profile-admin.d.ts +64 -0
- package/dist/profile-admin.d.ts.map +1 -0
- package/dist/profile-admin.js +351 -0
- package/dist/profile-admin.js.map +1 -0
- package/dist/profile-credentials.d.ts +68 -0
- package/dist/profile-credentials.d.ts.map +1 -0
- package/dist/profile-credentials.js +329 -0
- package/dist/profile-credentials.js.map +1 -0
- package/dist/profile-manager.d.ts +187 -0
- package/dist/profile-manager.d.ts.map +1 -0
- package/dist/profile-manager.js +1026 -0
- package/dist/profile-manager.js.map +1 -0
- package/dist/record-identifier-policy.d.ts +39 -0
- package/dist/record-identifier-policy.d.ts.map +1 -0
- package/dist/record-identifier-policy.js +203 -0
- package/dist/record-identifier-policy.js.map +1 -0
- package/dist/runtime-environment.d.ts +23 -0
- package/dist/runtime-environment.d.ts.map +1 -0
- package/dist/runtime-environment.js +58 -0
- package/dist/runtime-environment.js.map +1 -0
- package/dist/server.d.ts +33 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +73 -0
- package/dist/server.js.map +1 -0
- package/dist/servicenow-identifiers.d.ts +8 -0
- package/dist/servicenow-identifiers.d.ts.map +1 -0
- package/dist/servicenow-identifiers.js +22 -0
- package/dist/servicenow-identifiers.js.map +1 -0
- package/dist/setup-prompts.d.ts +7 -0
- package/dist/setup-prompts.d.ts.map +1 -0
- package/dist/setup-prompts.js +123 -0
- package/dist/setup-prompts.js.map +1 -0
- package/dist/setup.d.ts +109 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +1903 -0
- package/dist/setup.js.map +1 -0
- package/dist/startup.d.ts +43 -0
- package/dist/startup.d.ts.map +1 -0
- package/dist/startup.js +75 -0
- package/dist/startup.js.map +1 -0
- package/dist/stdio-runtime.d.ts +106 -0
- package/dist/stdio-runtime.d.ts.map +1 -0
- package/dist/stdio-runtime.js +231 -0
- package/dist/stdio-runtime.js.map +1 -0
- package/dist/structured-query.d.ts +187 -0
- package/dist/structured-query.d.ts.map +1 -0
- package/dist/structured-query.js +503 -0
- package/dist/structured-query.js.map +1 -0
- package/dist/table-defaults.d.ts +28 -0
- package/dist/table-defaults.d.ts.map +1 -0
- package/dist/table-defaults.js +85 -0
- package/dist/table-defaults.js.map +1 -0
- package/dist/table-policy.d.ts +71 -0
- package/dist/table-policy.d.ts.map +1 -0
- package/dist/table-policy.js +290 -0
- package/dist/table-policy.js.map +1 -0
- package/dist/tool-error.d.ts +48 -0
- package/dist/tool-error.d.ts.map +1 -0
- package/dist/tool-error.js +139 -0
- package/dist/tool-error.js.map +1 -0
- package/dist/tool-table-access.d.ts +19 -0
- package/dist/tool-table-access.d.ts.map +1 -0
- package/dist/tool-table-access.js +388 -0
- package/dist/tool-table-access.js.map +1 -0
- package/dist/tools/aggregate.d.ts +22 -42
- package/dist/tools/aggregate.d.ts.map +1 -1
- package/dist/tools/aggregate.js +103 -47
- package/dist/tools/aggregate.js.map +1 -1
- package/dist/tools/all-fields-cap.d.ts +45 -0
- package/dist/tools/all-fields-cap.d.ts.map +1 -0
- package/dist/tools/all-fields-cap.js +151 -0
- package/dist/tools/all-fields-cap.js.map +1 -0
- package/dist/tools/atf.d.ts +21 -60
- package/dist/tools/atf.d.ts.map +1 -1
- package/dist/tools/atf.js +180 -116
- package/dist/tools/atf.js.map +1 -1
- package/dist/tools/attach.d.ts +31 -45
- package/dist/tools/attach.d.ts.map +1 -1
- package/dist/tools/attach.js +175 -137
- package/dist/tools/attach.js.map +1 -1
- package/dist/tools/batch.d.ts +78 -42
- package/dist/tools/batch.d.ts.map +1 -1
- package/dist/tools/batch.js +172 -68
- package/dist/tools/batch.js.map +1 -1
- package/dist/tools/catalog.d.ts +6 -0
- package/dist/tools/catalog.d.ts.map +1 -0
- package/dist/tools/catalog.js +203 -0
- package/dist/tools/catalog.js.map +1 -0
- package/dist/tools/codesearch.d.ts +14 -25
- package/dist/tools/codesearch.d.ts.map +1 -1
- package/dist/tools/codesearch.js +60 -48
- package/dist/tools/codesearch.js.map +1 -1
- package/dist/tools/create-module.d.ts +48 -0
- package/dist/tools/create-module.d.ts.map +1 -0
- package/dist/tools/create-module.js +98 -0
- package/dist/tools/create-module.js.map +1 -0
- package/dist/tools/create.d.ts +2 -38
- package/dist/tools/create.d.ts.map +1 -1
- package/dist/tools/create.js +9 -41
- package/dist/tools/create.js.map +1 -1
- package/dist/tools/delete.d.ts +13 -23
- package/dist/tools/delete.d.ts.map +1 -1
- package/dist/tools/delete.js +30 -33
- package/dist/tools/delete.js.map +1 -1
- package/dist/tools/discover.d.ts +15 -27
- package/dist/tools/discover.d.ts.map +1 -1
- package/dist/tools/discover.js +103 -60
- package/dist/tools/discover.js.map +1 -1
- package/dist/tools/get-module.d.ts +85 -0
- package/dist/tools/get-module.d.ts.map +1 -0
- package/dist/tools/get-module.js +221 -0
- package/dist/tools/get-module.js.map +1 -0
- package/dist/tools/get.d.ts +2 -51
- package/dist/tools/get.d.ts.map +1 -1
- package/dist/tools/get.js +9 -49
- package/dist/tools/get.js.map +1 -1
- package/dist/tools/handler-result.d.ts +14 -0
- package/dist/tools/handler-result.d.ts.map +1 -0
- package/dist/tools/handler-result.js +177 -0
- package/dist/tools/handler-result.js.map +1 -0
- package/dist/tools/health.d.ts +12 -15
- package/dist/tools/health.d.ts.map +1 -1
- package/dist/tools/health.js +55 -36
- package/dist/tools/health.js.map +1 -1
- package/dist/tools/incident-journal-module.d.ts +12 -0
- package/dist/tools/incident-journal-module.d.ts.map +1 -0
- package/dist/tools/incident-journal-module.js +61 -0
- package/dist/tools/incident-journal-module.js.map +1 -0
- package/dist/tools/index.d.ts +47 -36
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +814 -35
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/nl.d.ts +10 -24
- package/dist/tools/nl.d.ts.map +1 -1
- package/dist/tools/nl.js +37 -147
- package/dist/tools/nl.js.map +1 -1
- package/dist/tools/profile.d.ts +37 -0
- package/dist/tools/profile.d.ts.map +1 -0
- package/dist/tools/profile.js +39 -0
- package/dist/tools/profile.js.map +1 -0
- package/dist/tools/query-module.d.ts +119 -0
- package/dist/tools/query-module.d.ts.map +1 -0
- package/dist/tools/query-module.js +324 -0
- package/dist/tools/query-module.js.map +1 -0
- package/dist/tools/query.d.ts +2 -72
- package/dist/tools/query.d.ts.map +1 -1
- package/dist/tools/query.js +8 -72
- package/dist/tools/query.js.map +1 -1
- package/dist/tools/record-write-shared.d.ts +7 -0
- package/dist/tools/record-write-shared.d.ts.map +1 -0
- package/dist/tools/record-write-shared.js +65 -0
- package/dist/tools/record-write-shared.js.map +1 -0
- package/dist/tools/relationships.d.ts +21 -42
- package/dist/tools/relationships.d.ts.map +1 -1
- package/dist/tools/relationships.js +70 -56
- package/dist/tools/relationships.js.map +1 -1
- package/dist/tools/result-envelope.d.ts +603 -0
- package/dist/tools/result-envelope.d.ts.map +1 -0
- package/dist/tools/result-envelope.js +770 -0
- package/dist/tools/result-envelope.js.map +1 -0
- package/dist/tools/schema-module.d.ts +64 -0
- package/dist/tools/schema-module.d.ts.map +1 -0
- package/dist/tools/schema-module.js +367 -0
- package/dist/tools/schema-module.js.map +1 -0
- package/dist/tools/schema.d.ts +2 -37
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +6 -57
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/script.d.ts +33 -27
- package/dist/tools/script.d.ts.map +1 -1
- package/dist/tools/script.js +43 -37
- package/dist/tools/script.js.map +1 -1
- package/dist/tools/syslog.d.ts +19 -46
- package/dist/tools/syslog.d.ts.map +1 -1
- package/dist/tools/syslog.js +101 -67
- package/dist/tools/syslog.js.map +1 -1
- package/dist/tools/tool-module.d.ts +143 -0
- package/dist/tools/tool-module.d.ts.map +1 -0
- package/dist/tools/tool-module.js +1095 -0
- package/dist/tools/tool-module.js.map +1 -0
- package/dist/tools/update-module.d.ts +51 -0
- package/dist/tools/update-module.d.ts.map +1 -0
- package/dist/tools/update-module.js +111 -0
- package/dist/tools/update-module.js.map +1 -0
- package/dist/tools/update.d.ts +2 -45
- package/dist/tools/update.d.ts.map +1 -1
- package/dist/tools/update.js +9 -41
- package/dist/tools/update.js.map +1 -1
- package/dist/utils.d.ts +68 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +114 -16
- package/dist/utils.js.map +1 -1
- package/dist/version.d.ts +10 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +13 -0
- package/dist/version.js.map +1 -0
- package/dist/write-value-policy.d.ts +56 -0
- package/dist/write-value-policy.d.ts.map +1 -0
- package/dist/write-value-policy.js +310 -0
- package/dist/write-value-policy.js.map +1 -0
- package/docs/ADDING-TOOLS.md +227 -0
- package/docs/CLIENT-SETUP.md +914 -0
- package/docs/CONTAINER-DEPLOYMENT.md +310 -0
- package/docs/CROSS-CLIENT-RELEASE-MATRIX.md +63 -0
- package/docs/ENTERPRISE-RELEASE-BOUNDARY.md +149 -0
- package/docs/OPERATIONS-RUNBOOK.md +383 -0
- package/docs/PRIVATE-CHATGPT-CONNECTIVITY.md +347 -0
- package/docs/PRODUCTION-SECURITY.md +368 -0
- package/docs/PROFILE-CREDENTIALS.md +126 -0
- package/docs/RELEASE-VALIDATION.md +140 -0
- package/docs/TESTING-OAUTH.md +101 -0
- package/docs/V2-MIGRATION.md +493 -0
- package/package.json +60 -13
- package/scripts/inspector.mjs +140 -0
- package/scripts/release-validate.mjs +201 -0
- package/scripts/smoke-test.mjs +274 -0
- package/tools/inspector/package-lock.json +3812 -0
- package/tools/inspector/package.json +12 -0
package/dist/utils.js
CHANGED
|
@@ -5,18 +5,47 @@
|
|
|
5
5
|
* @module utils
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.MAX_RESPONSE_BYTES_MAX = exports.MAX_RESPONSE_BYTES_MIN = exports.MAX_RESPONSE_BYTES_DEFAULT = void 0;
|
|
8
9
|
exports.ok = ok;
|
|
10
|
+
exports.stripEmpty = stripEmpty;
|
|
9
11
|
exports.err = err;
|
|
10
12
|
exports.formatError = formatError;
|
|
13
|
+
exports.withWarnings = withWarnings;
|
|
11
14
|
exports.buildTableParams = buildTableParams;
|
|
15
|
+
exports.escapeQueryValue = escapeQueryValue;
|
|
12
16
|
exports.truncate = truncate;
|
|
17
|
+
exports.serializedBytes = serializedBytes;
|
|
18
|
+
const encoded_query_policy_js_1 = require("./encoded-query-policy.js");
|
|
19
|
+
const tool_error_js_1 = require("./tool-error.js");
|
|
13
20
|
/**
|
|
14
21
|
* Format a successful tool result as MCP text content.
|
|
22
|
+
* Objects are serialized as compact JSON (no pretty-print indent).
|
|
15
23
|
*/
|
|
16
24
|
function ok(data) {
|
|
17
|
-
const text = typeof data === "string" ? data : JSON.stringify(data
|
|
25
|
+
const text = typeof data === "string" ? data : JSON.stringify(data);
|
|
18
26
|
return { content: [{ type: "text", text }] };
|
|
19
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Deep-strip empty values from record payloads: removes object entries
|
|
30
|
+
* whose value is "" or null. Keeps false, 0, and empty arrays. Recurses
|
|
31
|
+
* into nested objects and arrays. ServiceNow records are full of empty
|
|
32
|
+
* strings -- stripping them cuts serialized size substantially.
|
|
33
|
+
*/
|
|
34
|
+
function stripEmpty(value) {
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
return value.map((item) => stripEmpty(item));
|
|
37
|
+
}
|
|
38
|
+
if (value !== null && typeof value === "object") {
|
|
39
|
+
const out = {};
|
|
40
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
41
|
+
if (entry === "" || entry === null)
|
|
42
|
+
continue;
|
|
43
|
+
out[key] = stripEmpty(entry);
|
|
44
|
+
}
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
20
49
|
/**
|
|
21
50
|
* Format an error tool result as MCP text content.
|
|
22
51
|
*/
|
|
@@ -24,29 +53,49 @@ function err(message) {
|
|
|
24
53
|
return { content: [{ type: "text", text: `ERROR: ${message}` }], isError: true };
|
|
25
54
|
}
|
|
26
55
|
/**
|
|
27
|
-
*
|
|
56
|
+
* Convert an untrusted exception into a fixed, caller-safe failure category.
|
|
57
|
+
*
|
|
58
|
+
* Exception messages, details, causes, response bodies, URLs, headers, and
|
|
59
|
+
* stack text are deliberately ignored. Upstream libraries commonly embed
|
|
60
|
+
* credentials and query values in those fields, and incomplete regex
|
|
61
|
+
* redaction cannot make arbitrary text safe. Only module-private trusted
|
|
62
|
+
* provenance can retain a category; every other value becomes `internal`.
|
|
28
63
|
*/
|
|
29
64
|
function formatError(error) {
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
65
|
+
if ((0, encoded_query_policy_js_1.isEncodedQueryPolicyError)(error)) {
|
|
66
|
+
return encoded_query_policy_js_1.ENCODED_QUERY_MIGRATION_MESSAGE;
|
|
67
|
+
}
|
|
68
|
+
return (0, tool_error_js_1.formatToolError)(error);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Attach a list of per-request failure warnings to a success payload.
|
|
72
|
+
*
|
|
73
|
+
* No-op when there are no warnings -- the success shape is unchanged.
|
|
74
|
+
* With warnings, plain objects gain a `warnings` key; arrays are wrapped
|
|
75
|
+
* as `{ results, warnings }` and scalars as `{ result, warnings }` since
|
|
76
|
+
* neither can carry extra keys. This lets tools that fan out over several
|
|
77
|
+
* sub-requests report partial failures (e.g. an ACL-denied table) instead
|
|
78
|
+
* of silently returning fewer results.
|
|
79
|
+
*/
|
|
80
|
+
function withWarnings(data, warnings) {
|
|
81
|
+
if (warnings.length === 0)
|
|
82
|
+
return data;
|
|
83
|
+
if (Array.isArray(data))
|
|
84
|
+
return { results: data, warnings };
|
|
85
|
+
if (data !== null && typeof data === "object") {
|
|
86
|
+
return { ...data, warnings };
|
|
40
87
|
}
|
|
41
|
-
|
|
42
|
-
return error.message;
|
|
43
|
-
return String(error);
|
|
88
|
+
return { result: data, warnings };
|
|
44
89
|
}
|
|
45
90
|
/**
|
|
46
91
|
* Build a query parameter map for table API requests.
|
|
92
|
+
* Always excludes reference links (link+value objects are pure URL noise
|
|
93
|
+
* in tool output).
|
|
47
94
|
*/
|
|
48
95
|
function buildTableParams(opts) {
|
|
49
|
-
const params = {
|
|
96
|
+
const params = {
|
|
97
|
+
sysparm_exclude_reference_link: "true",
|
|
98
|
+
};
|
|
50
99
|
if (opts.limit !== undefined)
|
|
51
100
|
params.sysparm_limit = String(opts.limit);
|
|
52
101
|
if (opts.query)
|
|
@@ -59,8 +108,42 @@ function buildTableParams(opts) {
|
|
|
59
108
|
params.sysparm_orderby = opts.orderby;
|
|
60
109
|
if (opts.displayValue)
|
|
61
110
|
params.sysparm_display_value = opts.displayValue;
|
|
111
|
+
if (opts.noCount)
|
|
112
|
+
params.sysparm_no_count = "true";
|
|
62
113
|
return params;
|
|
63
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Neutralize encoded-query metacharacters in a user-supplied VALUE that
|
|
117
|
+
* is interpolated into a sysparm_query string.
|
|
118
|
+
*
|
|
119
|
+
* ServiceNow's encoded-query syntax has NO escape sequence: `^` always
|
|
120
|
+
* terminates the current condition, and `^OR` / `^NQ` / `^EQ` chain new
|
|
121
|
+
* ones, so a literal `^` inside a value cannot be represented at all.
|
|
122
|
+
* The only fail-closed strategy is to strip `^` before interpolation:
|
|
123
|
+
* a stripped value can no longer inject extra conditions (e.g. a ci_name
|
|
124
|
+
* of "x^ORactive=false" becomes the harmless literal "xORactive=false"),
|
|
125
|
+
* at the cost that field values genuinely containing `^` cannot be
|
|
126
|
+
* matched through the convenience filters -- a platform limitation, not
|
|
127
|
+
* a tool one.
|
|
128
|
+
*
|
|
129
|
+
* ServiceNow additionally EVALUATES a value that starts with
|
|
130
|
+
* "javascript:" server-side (the same mechanism the tools use
|
|
131
|
+
* deliberately, e.g. sys_created_on>=javascript:gs.minutesAgoStart()),
|
|
132
|
+
* so a leading javascript: prefix would let an interpolated value alter
|
|
133
|
+
* query semantics without any `^`. No legitimate literal field-value
|
|
134
|
+
* filter starts with it, so the prefix is stripped (repeatedly, to
|
|
135
|
+
* defeat javascript:javascript: nesting) -- also fail-closed.
|
|
136
|
+
*
|
|
137
|
+
* Raw `query` parameters that accept a full encoded query are
|
|
138
|
+
* intentionally passed through untouched.
|
|
139
|
+
*/
|
|
140
|
+
function escapeQueryValue(value) {
|
|
141
|
+
let v = value.replace(/\^/g, "");
|
|
142
|
+
while (/^\s*javascript:/i.test(v)) {
|
|
143
|
+
v = v.replace(/^\s*javascript:/i, "");
|
|
144
|
+
}
|
|
145
|
+
return v;
|
|
146
|
+
}
|
|
64
147
|
/**
|
|
65
148
|
* Truncate a string if it exceeds maxLen, appending "...".
|
|
66
149
|
*/
|
|
@@ -69,4 +152,19 @@ function truncate(str, maxLen) {
|
|
|
69
152
|
return str;
|
|
70
153
|
return str.slice(0, maxLen) + "...";
|
|
71
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Bounds for the max_response_bytes guard shared by sn_query / sn_get.
|
|
157
|
+
* Referenced from both the hand-written JSON schemas and the zod schemas
|
|
158
|
+
* so the two cannot drift.
|
|
159
|
+
*/
|
|
160
|
+
exports.MAX_RESPONSE_BYTES_DEFAULT = 100000;
|
|
161
|
+
exports.MAX_RESPONSE_BYTES_MIN = 1000;
|
|
162
|
+
exports.MAX_RESPONSE_BYTES_MAX = 1000000;
|
|
163
|
+
/**
|
|
164
|
+
* UTF-8 byte length of a value's compact-JSON serialization -- the exact
|
|
165
|
+
* size `ok()` would emit for it.
|
|
166
|
+
*/
|
|
167
|
+
function serializedBytes(data) {
|
|
168
|
+
return Buffer.byteLength(JSON.stringify(data), "utf8");
|
|
169
|
+
}
|
|
72
170
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;;GAIG
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAYH,gBAGC;AAQD,gCAaC;AAKD,kBAKC;AAWD,kCAKC;AAYD,oCAOC;AAOD,4CAoBC;AA2BD,4CAMC;AAKD,4BAGC;AAeD,0CAEC;AApKD,uEAGmC;AACnC,mDAAkD;AAElD;;;GAGG;AACH,SAAgB,EAAE,CAAC,IAAa;IAC9B,MAAM,IAAI,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACpE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAC/C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAI,KAAQ;IACpC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAiB,CAAC;IAC/D,CAAC;IACD,IAAI,KAAK,KAAK,IAA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G,CAAC,MAAM,IAAI,MAAM;QAAE,OAAO,GAAG,CAAC;IACrC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC;AACtC,CAAC;AAED;;;;GAIG;AACU,QAAA,0BAA0B,GAAG,MAAM,CAAC;AACpC,QAAA,sBAAsB,GAAG,IAAI,CAAC;AAC9B,QAAA,sBAAsB,GAAG,OAAO,CAAC;AAE9C;;;GAGG;AACH,SAAgB,eAAe,CAAC,IAAa;IAC3C,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single source of truth for the package version at runtime.
|
|
3
|
+
*
|
|
4
|
+
* Keep in sync with package.json "version" -- test/version.test.ts
|
|
5
|
+
* asserts the two match, so a release bump cannot silently drift.
|
|
6
|
+
*
|
|
7
|
+
* @module version
|
|
8
|
+
*/
|
|
9
|
+
export declare const VERSION = "2.1.0";
|
|
10
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Single source of truth for the package version at runtime.
|
|
4
|
+
*
|
|
5
|
+
* Keep in sync with package.json "version" -- test/version.test.ts
|
|
6
|
+
* asserts the two match, so a release bump cannot silently drift.
|
|
7
|
+
*
|
|
8
|
+
* @module version
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.VERSION = void 0;
|
|
12
|
+
exports.VERSION = "2.1.0";
|
|
13
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEU,QAAA,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded, code-owned value policy for generic creates and updates.
|
|
3
|
+
*
|
|
4
|
+
* Which tables may be written is decided entirely by the configured
|
|
5
|
+
* `tableAccess` and field policies -- this module never gates on table
|
|
6
|
+
* identity. It only bounds the *values* a write may carry, so a grant the
|
|
7
|
+
* operator issued is the grant that takes effect. The `incident` table keeps
|
|
8
|
+
* a strict typed value map because its ordinary fields are a known, closed
|
|
9
|
+
* set; every other table gets generic bounds.
|
|
10
|
+
*/
|
|
11
|
+
export declare const INCIDENT_SHORT_DESCRIPTION_MAX_CHARACTERS = 160;
|
|
12
|
+
export declare const INCIDENT_SHORT_DESCRIPTION_MAX_UTF8_BYTES = 640;
|
|
13
|
+
export declare const INCIDENT_LONG_TEXT_MAX_CHARACTERS = 4000;
|
|
14
|
+
export declare const INCIDENT_LONG_TEXT_MAX_UTF8_BYTES = 16000;
|
|
15
|
+
export declare const INCIDENT_CHOICE_MAX_CHARACTERS = 80;
|
|
16
|
+
export declare const INCIDENT_CHOICE_MAX_UTF8_BYTES = 320;
|
|
17
|
+
type WriteMode = "create" | "update";
|
|
18
|
+
export type WriteValuePolicyFailureReason = "unsupported_table" | "invalid_mode" | "missing_short_description" | "invalid_value";
|
|
19
|
+
/**
|
|
20
|
+
* Generic bounds for tables without a typed value map. Large enough for real
|
|
21
|
+
* script and template bodies; small enough that a single field cannot be used
|
|
22
|
+
* to push an unbounded payload upstream.
|
|
23
|
+
*/
|
|
24
|
+
export declare const GENERIC_WRITE_VALUE_MAX_CHARACTERS = 100000;
|
|
25
|
+
export declare const GENERIC_WRITE_VALUE_MAX_UTF8_BYTES = 400000;
|
|
26
|
+
export declare class WriteValuePolicyError extends Error {
|
|
27
|
+
readonly reason: WriteValuePolicyFailureReason;
|
|
28
|
+
readonly table?: string;
|
|
29
|
+
constructor(reason: WriteValuePolicyFailureReason, table?: string);
|
|
30
|
+
}
|
|
31
|
+
export declare function isWriteValuePolicyError(error: unknown): error is WriteValuePolicyError;
|
|
32
|
+
/**
|
|
33
|
+
* Safe fixed guidance per failure reason. A bounded-value denial is not a
|
|
34
|
+
* table-access denial: it is not fixed in tableAccess.writeTables, so
|
|
35
|
+
* reporting it as a table denial points the operator at a key that cannot
|
|
36
|
+
* change the outcome. Only the already-normalized table identifier is ever
|
|
37
|
+
* interpolated.
|
|
38
|
+
*/
|
|
39
|
+
export declare function writeValueDenialMessage(error: WriteValuePolicyError, tool?: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Normalize a caller-supplied table name into the canonical identifier used
|
|
42
|
+
* for both the policy decision and the upstream request path, so the value
|
|
43
|
+
* evaluated is the value used.
|
|
44
|
+
*/
|
|
45
|
+
export declare function normalizeWriteTable(candidate: unknown): string;
|
|
46
|
+
/**
|
|
47
|
+
* Validate keys through the shared field policy, then validate and
|
|
48
|
+
* canonicalize every value.
|
|
49
|
+
*
|
|
50
|
+
* The table itself is never gated here: whether a table may be written is the
|
|
51
|
+
* configured table policy's decision, evaluated by the dispatcher. Incident
|
|
52
|
+
* keeps its typed value map; every other granted table gets generic bounds.
|
|
53
|
+
*/
|
|
54
|
+
export declare function prepareWriteFieldValues(mode: WriteMode, tableCandidate: unknown, fieldsCandidate: unknown): Readonly<Record<string, string>>;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=write-value-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-value-policy.d.ts","sourceRoot":"","sources":["../src/write-value-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,eAAO,MAAM,yCAAyC,MAAM,CAAC;AAC7D,eAAO,MAAM,yCAAyC,MAAM,CAAC;AAC7D,eAAO,MAAM,iCAAiC,OAAQ,CAAC;AACvD,eAAO,MAAM,iCAAiC,QAAS,CAAC;AACxD,eAAO,MAAM,8BAA8B,KAAK,CAAC;AACjD,eAAO,MAAM,8BAA8B,MAAM,CAAC;AAElD,KAAK,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAUrC,MAAM,MAAM,6BAA6B,GACrC,mBAAmB,GACnB,cAAc,GACd,2BAA2B,GAC3B,eAAe,CAAC;AAEpB;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,SAAU,CAAC;AAC1D,eAAO,MAAM,kCAAkC,SAAU,CAAC;AA+B1D,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,MAAM,EAAE,6BAA6B,CAAC;IAC/C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,6BAA6B,EAAE,KAAK,CAAC,EAAE,MAAM;CAUlE;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,qBAAqB,CAMhC;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,qBAAqB,EAC5B,IAAI,CAAC,EAAE,MAAM,GACZ,MAAM,CA+BR;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,CAM9D;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,SAAS,EACf,cAAc,EAAE,OAAO,EACvB,eAAe,EAAE,OAAO,GACvB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA2BlC"}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bounded, code-owned value policy for generic creates and updates.
|
|
4
|
+
*
|
|
5
|
+
* Which tables may be written is decided entirely by the configured
|
|
6
|
+
* `tableAccess` and field policies -- this module never gates on table
|
|
7
|
+
* identity. It only bounds the *values* a write may carry, so a grant the
|
|
8
|
+
* operator issued is the grant that takes effect. The `incident` table keeps
|
|
9
|
+
* a strict typed value map because its ordinary fields are a known, closed
|
|
10
|
+
* set; every other table gets generic bounds.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.WriteValuePolicyError = exports.GENERIC_WRITE_VALUE_MAX_UTF8_BYTES = exports.GENERIC_WRITE_VALUE_MAX_CHARACTERS = exports.INCIDENT_CHOICE_MAX_UTF8_BYTES = exports.INCIDENT_CHOICE_MAX_CHARACTERS = exports.INCIDENT_LONG_TEXT_MAX_UTF8_BYTES = exports.INCIDENT_LONG_TEXT_MAX_CHARACTERS = exports.INCIDENT_SHORT_DESCRIPTION_MAX_UTF8_BYTES = exports.INCIDENT_SHORT_DESCRIPTION_MAX_CHARACTERS = void 0;
|
|
14
|
+
exports.isWriteValuePolicyError = isWriteValuePolicyError;
|
|
15
|
+
exports.writeValueDenialMessage = writeValueDenialMessage;
|
|
16
|
+
exports.normalizeWriteTable = normalizeWriteTable;
|
|
17
|
+
exports.prepareWriteFieldValues = prepareWriteFieldValues;
|
|
18
|
+
const node_buffer_1 = require("node:buffer");
|
|
19
|
+
const field_policy_js_1 = require("./field-policy.js");
|
|
20
|
+
const servicenow_identifiers_js_1 = require("./servicenow-identifiers.js");
|
|
21
|
+
const table_policy_js_1 = require("./table-policy.js");
|
|
22
|
+
exports.INCIDENT_SHORT_DESCRIPTION_MAX_CHARACTERS = 160;
|
|
23
|
+
exports.INCIDENT_SHORT_DESCRIPTION_MAX_UTF8_BYTES = 640;
|
|
24
|
+
exports.INCIDENT_LONG_TEXT_MAX_CHARACTERS = 4_000;
|
|
25
|
+
exports.INCIDENT_LONG_TEXT_MAX_UTF8_BYTES = 16_000;
|
|
26
|
+
exports.INCIDENT_CHOICE_MAX_CHARACTERS = 80;
|
|
27
|
+
exports.INCIDENT_CHOICE_MAX_UTF8_BYTES = 320;
|
|
28
|
+
/**
|
|
29
|
+
* Generic bounds for tables without a typed value map. Large enough for real
|
|
30
|
+
* script and template bodies; small enough that a single field cannot be used
|
|
31
|
+
* to push an unbounded payload upstream.
|
|
32
|
+
*/
|
|
33
|
+
exports.GENERIC_WRITE_VALUE_MAX_CHARACTERS = 100_000;
|
|
34
|
+
exports.GENERIC_WRITE_VALUE_MAX_UTF8_BYTES = 400_000;
|
|
35
|
+
const FIELD_KINDS = Object.freeze({
|
|
36
|
+
short_description: "short_text",
|
|
37
|
+
description: "long_text",
|
|
38
|
+
caller_id: "reference",
|
|
39
|
+
assignment_group: "reference",
|
|
40
|
+
assigned_to: "reference",
|
|
41
|
+
impact: "impact_urgency",
|
|
42
|
+
urgency: "impact_urgency",
|
|
43
|
+
priority: "priority",
|
|
44
|
+
category: "choice",
|
|
45
|
+
subcategory: "choice",
|
|
46
|
+
state: "state",
|
|
47
|
+
close_code: "choice",
|
|
48
|
+
close_notes: "long_text",
|
|
49
|
+
contact_type: "choice",
|
|
50
|
+
});
|
|
51
|
+
const UNSAFE_SINGLE_LINE = /[\p{Cc}\p{Cf}\p{Cs}\p{Zl}\p{Zp}]/u;
|
|
52
|
+
const UNSAFE_MULTILINE = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\p{Cf}\p{Cs}\p{Zl}\p{Zp}]/u;
|
|
53
|
+
const UNSAFE_CHOICE_METACHARACTER = /[\^=,]/u;
|
|
54
|
+
const LEADING_JAVASCRIPT = /^javascript:/iu;
|
|
55
|
+
const STATE_TOKEN = /^-?[0-9]{1,4}$/u;
|
|
56
|
+
const ISSUED_WRITE_VALUE_POLICY_ERRORS = new WeakSet();
|
|
57
|
+
/** Normalized table identifiers are the only value ever placed in a message. */
|
|
58
|
+
const SAFE_TABLE_NAME = /^[a-z][a-z0-9_]{0,79}$/u;
|
|
59
|
+
class WriteValuePolicyError extends Error {
|
|
60
|
+
reason;
|
|
61
|
+
table;
|
|
62
|
+
constructor(reason, table) {
|
|
63
|
+
super("Write denied by the bounded value policy");
|
|
64
|
+
this.name = "WriteValuePolicyError";
|
|
65
|
+
this.reason = reason;
|
|
66
|
+
if (typeof table === "string" && SAFE_TABLE_NAME.test(table)) {
|
|
67
|
+
this.table = table;
|
|
68
|
+
}
|
|
69
|
+
ISSUED_WRITE_VALUE_POLICY_ERRORS.add(this);
|
|
70
|
+
Object.freeze(this);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.WriteValuePolicyError = WriteValuePolicyError;
|
|
74
|
+
function isWriteValuePolicyError(error) {
|
|
75
|
+
return (typeof error === "object" &&
|
|
76
|
+
error !== null &&
|
|
77
|
+
ISSUED_WRITE_VALUE_POLICY_ERRORS.has(error));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Safe fixed guidance per failure reason. A bounded-value denial is not a
|
|
81
|
+
* table-access denial: it is not fixed in tableAccess.writeTables, so
|
|
82
|
+
* reporting it as a table denial points the operator at a key that cannot
|
|
83
|
+
* change the outcome. Only the already-normalized table identifier is ever
|
|
84
|
+
* interpolated.
|
|
85
|
+
*/
|
|
86
|
+
function writeValueDenialMessage(error, tool) {
|
|
87
|
+
const subject = typeof tool === "string" && tool.trim() !== "" ? tool.trim() : "This tool";
|
|
88
|
+
switch (error.reason) {
|
|
89
|
+
case "unsupported_table":
|
|
90
|
+
return (`Write denied by policy: ${subject} received a table name that is not a ` +
|
|
91
|
+
`valid ServiceNow identifier. ` +
|
|
92
|
+
(error.table === undefined
|
|
93
|
+
? "Pass a table name such as \"incident\"."
|
|
94
|
+
: `Table ${JSON.stringify(error.table)} is not usable.`));
|
|
95
|
+
case "missing_short_description":
|
|
96
|
+
return (`Write denied by policy: ${subject} requires a non-empty bounded ` +
|
|
97
|
+
`short_description when creating an incident.`);
|
|
98
|
+
case "invalid_value":
|
|
99
|
+
return (`Write denied by policy: ${subject} rejected a field value. The field is ` +
|
|
100
|
+
`not writable under the configured field policy for this table, or its ` +
|
|
101
|
+
`value is outside the bounds this code policy enforces. On the incident ` +
|
|
102
|
+
`table only the approved ordinary fields are accepted, and journal fields ` +
|
|
103
|
+
`require the dedicated sn_incident_add_comment and sn_incident_add_work_note ` +
|
|
104
|
+
`tools.`);
|
|
105
|
+
case "invalid_mode":
|
|
106
|
+
return `Write denied by policy: ${subject} requested an unsupported write mode.`;
|
|
107
|
+
default:
|
|
108
|
+
return `Write denied by policy: ${subject} denied the write by the bounded value policy.`;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Normalize a caller-supplied table name into the canonical identifier used
|
|
113
|
+
* for both the policy decision and the upstream request path, so the value
|
|
114
|
+
* evaluated is the value used.
|
|
115
|
+
*/
|
|
116
|
+
function normalizeWriteTable(candidate) {
|
|
117
|
+
try {
|
|
118
|
+
return (0, table_policy_js_1.normalizeTableName)(candidate);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
throw new WriteValuePolicyError("unsupported_table");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Validate keys through the shared field policy, then validate and
|
|
126
|
+
* canonicalize every value.
|
|
127
|
+
*
|
|
128
|
+
* The table itself is never gated here: whether a table may be written is the
|
|
129
|
+
* configured table policy's decision, evaluated by the dispatcher. Incident
|
|
130
|
+
* keeps its typed value map; every other granted table gets generic bounds.
|
|
131
|
+
*/
|
|
132
|
+
function prepareWriteFieldValues(mode, tableCandidate, fieldsCandidate) {
|
|
133
|
+
if (mode !== "create" && mode !== "update") {
|
|
134
|
+
throw new WriteValuePolicyError("invalid_mode");
|
|
135
|
+
}
|
|
136
|
+
const table = normalizeWriteTable(tableCandidate);
|
|
137
|
+
const approved = (0, field_policy_js_1.validateWritableFields)(table, fieldsCandidate);
|
|
138
|
+
if (table !== "incident") {
|
|
139
|
+
const generic = {};
|
|
140
|
+
for (const [field, value] of Object.entries(approved)) {
|
|
141
|
+
defineValue(generic, field, genericValue(value));
|
|
142
|
+
}
|
|
143
|
+
return Object.freeze(generic);
|
|
144
|
+
}
|
|
145
|
+
if (mode === "create" && !Object.hasOwn(approved, "short_description")) {
|
|
146
|
+
throw new WriteValuePolicyError("missing_short_description", table);
|
|
147
|
+
}
|
|
148
|
+
const output = {};
|
|
149
|
+
for (const [field, value] of Object.entries(approved)) {
|
|
150
|
+
if (!Object.hasOwn(FIELD_KINDS, field)) {
|
|
151
|
+
throw new WriteValuePolicyError("invalid_value", table);
|
|
152
|
+
}
|
|
153
|
+
defineValue(output, field, canonicalValue(FIELD_KINDS[field], value));
|
|
154
|
+
}
|
|
155
|
+
return Object.freeze(output);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Bounded canonicalization for a table with no typed value map. Field
|
|
159
|
+
* *selection* is already the field policy's decision; this only ensures the
|
|
160
|
+
* value is a plain bounded scalar that cannot smuggle control characters or
|
|
161
|
+
* an unbounded payload upstream. An empty string is allowed so a granted
|
|
162
|
+
* field can be cleared.
|
|
163
|
+
*/
|
|
164
|
+
function genericValue(value) {
|
|
165
|
+
try {
|
|
166
|
+
if (typeof value === "boolean")
|
|
167
|
+
return String(value);
|
|
168
|
+
if (typeof value === "number") {
|
|
169
|
+
if (!Number.isSafeInteger(value))
|
|
170
|
+
throw new Error("invalid numeric primitive");
|
|
171
|
+
return String(value);
|
|
172
|
+
}
|
|
173
|
+
if (typeof value !== "string")
|
|
174
|
+
throw new Error("value must be a scalar");
|
|
175
|
+
if (!isWellFormedUnicode(value))
|
|
176
|
+
throw new Error("value is not Unicode");
|
|
177
|
+
if (UNSAFE_MULTILINE.test(value)) {
|
|
178
|
+
throw new Error("value contains an unsafe control character");
|
|
179
|
+
}
|
|
180
|
+
if ([...value].length > exports.GENERIC_WRITE_VALUE_MAX_CHARACTERS) {
|
|
181
|
+
throw new Error("value exceeds the character limit");
|
|
182
|
+
}
|
|
183
|
+
if (node_buffer_1.Buffer.byteLength(value, "utf8") > exports.GENERIC_WRITE_VALUE_MAX_UTF8_BYTES) {
|
|
184
|
+
throw new Error("value exceeds the byte limit");
|
|
185
|
+
}
|
|
186
|
+
return value;
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
throw new WriteValuePolicyError("invalid_value");
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function canonicalValue(kind, value) {
|
|
193
|
+
try {
|
|
194
|
+
switch (kind) {
|
|
195
|
+
case "short_text":
|
|
196
|
+
return boundedText(value, {
|
|
197
|
+
maximumCharacters: exports.INCIDENT_SHORT_DESCRIPTION_MAX_CHARACTERS,
|
|
198
|
+
maximumBytes: exports.INCIDENT_SHORT_DESCRIPTION_MAX_UTF8_BYTES,
|
|
199
|
+
multiline: false,
|
|
200
|
+
trim: true,
|
|
201
|
+
});
|
|
202
|
+
case "long_text":
|
|
203
|
+
return boundedText(value, {
|
|
204
|
+
maximumCharacters: exports.INCIDENT_LONG_TEXT_MAX_CHARACTERS,
|
|
205
|
+
maximumBytes: exports.INCIDENT_LONG_TEXT_MAX_UTF8_BYTES,
|
|
206
|
+
multiline: true,
|
|
207
|
+
trim: false,
|
|
208
|
+
});
|
|
209
|
+
case "reference":
|
|
210
|
+
return (0, servicenow_identifiers_js_1.normalizeServiceNowSysId)(value);
|
|
211
|
+
case "impact_urgency":
|
|
212
|
+
return boundedInteger(value, 1, 3);
|
|
213
|
+
case "priority":
|
|
214
|
+
return boundedInteger(value, 1, 5);
|
|
215
|
+
case "state": {
|
|
216
|
+
const token = primitiveString(value);
|
|
217
|
+
if (!STATE_TOKEN.test(token))
|
|
218
|
+
throw new Error("invalid state token");
|
|
219
|
+
const numeric = Number(token);
|
|
220
|
+
if (!Number.isSafeInteger(numeric) || numeric < -9_999 || numeric > 9_999) {
|
|
221
|
+
throw new Error("state token is out of range");
|
|
222
|
+
}
|
|
223
|
+
return String(numeric);
|
|
224
|
+
}
|
|
225
|
+
case "choice": {
|
|
226
|
+
const choice = boundedText(value, {
|
|
227
|
+
maximumCharacters: exports.INCIDENT_CHOICE_MAX_CHARACTERS,
|
|
228
|
+
maximumBytes: exports.INCIDENT_CHOICE_MAX_UTF8_BYTES,
|
|
229
|
+
multiline: false,
|
|
230
|
+
trim: true,
|
|
231
|
+
});
|
|
232
|
+
if (UNSAFE_CHOICE_METACHARACTER.test(choice) ||
|
|
233
|
+
LEADING_JAVASCRIPT.test(choice)) {
|
|
234
|
+
throw new Error("unsafe choice token");
|
|
235
|
+
}
|
|
236
|
+
return choice;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
throw new WriteValuePolicyError("invalid_value", "incident");
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function boundedInteger(value, minimum, maximum) {
|
|
245
|
+
const token = primitiveString(value);
|
|
246
|
+
if (!/^[0-9]{1,3}$/u.test(token)) {
|
|
247
|
+
throw new Error("invalid integer token");
|
|
248
|
+
}
|
|
249
|
+
const numeric = Number(token);
|
|
250
|
+
if (!Number.isSafeInteger(numeric) || numeric < minimum || numeric > maximum) {
|
|
251
|
+
throw new Error("integer token is out of range");
|
|
252
|
+
}
|
|
253
|
+
return String(numeric);
|
|
254
|
+
}
|
|
255
|
+
function primitiveString(value) {
|
|
256
|
+
if (typeof value === "number") {
|
|
257
|
+
if (!Number.isSafeInteger(value))
|
|
258
|
+
throw new Error("invalid numeric primitive");
|
|
259
|
+
return String(value);
|
|
260
|
+
}
|
|
261
|
+
if (typeof value !== "string")
|
|
262
|
+
throw new Error("value must be a string or integer");
|
|
263
|
+
const trimmed = value.trim();
|
|
264
|
+
if (trimmed.length === 0)
|
|
265
|
+
throw new Error("value must not be blank");
|
|
266
|
+
return trimmed;
|
|
267
|
+
}
|
|
268
|
+
function boundedText(value, options) {
|
|
269
|
+
if (typeof value !== "string")
|
|
270
|
+
throw new Error("value must be a string");
|
|
271
|
+
const canonical = options.trim ? value.trim() : value;
|
|
272
|
+
if (canonical.trim().length === 0)
|
|
273
|
+
throw new Error("value must not be blank");
|
|
274
|
+
if (!isWellFormedUnicode(canonical))
|
|
275
|
+
throw new Error("value is not Unicode");
|
|
276
|
+
if ((options.multiline ? UNSAFE_MULTILINE : UNSAFE_SINGLE_LINE).test(canonical)) {
|
|
277
|
+
throw new Error("value contains an unsafe control character");
|
|
278
|
+
}
|
|
279
|
+
if ([...canonical].length > options.maximumCharacters) {
|
|
280
|
+
throw new Error("value exceeds the character limit");
|
|
281
|
+
}
|
|
282
|
+
if (node_buffer_1.Buffer.byteLength(canonical, "utf8") > options.maximumBytes) {
|
|
283
|
+
throw new Error("value exceeds the byte limit");
|
|
284
|
+
}
|
|
285
|
+
return canonical;
|
|
286
|
+
}
|
|
287
|
+
function isWellFormedUnicode(value) {
|
|
288
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
289
|
+
const codeUnit = value.charCodeAt(index);
|
|
290
|
+
if (codeUnit >= 0xd800 && codeUnit <= 0xdbff) {
|
|
291
|
+
const next = value.charCodeAt(index + 1);
|
|
292
|
+
if (next < 0xdc00 || next > 0xdfff)
|
|
293
|
+
return false;
|
|
294
|
+
index += 1;
|
|
295
|
+
}
|
|
296
|
+
else if (codeUnit >= 0xdc00 && codeUnit <= 0xdfff) {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
function defineValue(target, key, value) {
|
|
303
|
+
Object.defineProperty(target, key, {
|
|
304
|
+
value,
|
|
305
|
+
enumerable: true,
|
|
306
|
+
configurable: false,
|
|
307
|
+
writable: false,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
//# sourceMappingURL=write-value-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-value-policy.js","sourceRoot":"","sources":["../src/write-value-policy.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAoFH,0DAQC;AASD,0DAkCC;AAOD,kDAMC;AAUD,0DA+BC;AA3LD,6CAAqC;AAErC,uDAA2D;AAC3D,2EAA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